This commit is contained in:
Slava Rogozhkin 2025-09-18 07:57:38 +03:00
parent 4b3439a757
commit 057a3e634f
2 changed files with 69 additions and 4 deletions

8
cw
View File

@ -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
}

View File

@ -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
});