From 057a3e634f49bc477b2f0c5da1207cef69cd0c38 Mon Sep 17 00:00:00 2001 From: Slava Rogozhkin Date: Thu, 18 Sep 2025 07:57:38 +0300 Subject: [PATCH] monkey --- cw | 8 ++-- firefox/renametab_in_zyphyr_player.js | 65 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 firefox/renametab_in_zyphyr_player.js diff --git a/cw b/cw index c53e46f..c871740 100755 --- a/cw +++ b/cw @@ -51,8 +51,8 @@ get_orientation_img() { # Получить вертикальную обоину get_vertical_wall() { while true; do - img=$(get_path_img) - orientation=$(get_orientation_img $img) + local img=$(get_path_img) + local orientation=$(get_orientation_img $img) [[ $orientation -eq 'vertical' ]] && { printf $img; break ; } done } @@ -60,8 +60,8 @@ get_vertical_wall() { # Получить горизонтальную обоину get_horizontal_wall() { while true; do - img=$(get_path_img) - orientation=$(get_orientation_img $img) + local img=$(get_path_img) + local orientation=$(get_orientation_img $img) [[ $orientation -eq 'horizontal' ]] && { printf $img; break ; } done } diff --git a/firefox/renametab_in_zyphyr_player.js b/firefox/renametab_in_zyphyr_player.js new file mode 100644 index 0000000..bf607cd --- /dev/null +++ b/firefox/renametab_in_zyphyr_player.js @@ -0,0 +1,65 @@ +// ==UserScript== +// @name TabName_in_ZephyrPlayer +// @namespace Violentmonkey Scripts +// @match https://jira.astralinux.ru/secure/Tests.jspa* +// @grant none +// @version 1.0 +// @author - +// @description 17.09.2025, 17:12:31 +// ==/UserScript== + +// Ожидание элемента -- искомый элемент находится в h2.title +function waitForElm(selector) { + return new Promise(resolve => { + if (document.querySelector(selector)) { + return resolve(document.querySelector(selector)); + } + + const observer = new MutationObserver(mutations => { + if (document.querySelector(selector)) { + observer.disconnect(); + resolve(document.querySelector(selector)); + } + }); + + observer.observe(document.body, { + childList: true, + subtree: true + }); + }); +} + +// ждём и немного логируем +waitForElm("h2").then((elm) => { + console.log("Element is ready"); + console.log(elm.title); +}, 1000); + +// Включаем наблюдателя по доке MutationObserver +var mutationObserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + + // Трындец какой костыль. Но иначе я не смог + if (mutation.type === 'attributes') { + const element = mutation.target; + const attributeName = mutation.attributeName; + const oldValue = mutation.oldValue; + const newValue = element.getAttribute(attributeName); + + if (attributeName === 'title' && element.tagName === 'H2' ) { + document.title = newValue + } + + } + }); +}); + +// Наблюдаем за различными параметрами. Пытался определить какой именно нужный, чтобы меньше отслижвать - всё ломалось, поэтому отслеживаю всё. +mutationObserver.observe(document.documentElement, { + attributes: true, + characterData: true, + childList: true, + subtree: true, + attributeOldValue: true, + characterDataOldValue: true +});