format
This commit is contained in:
parent
0a8b4c059e
commit
d73968c5ed
@ -13,47 +13,47 @@
|
|||||||
// from https://developer.mozilla.org/en-US/docs/Web/API/Node#recurse_through_child_nodes
|
// from https://developer.mozilla.org/en-US/docs/Web/API/Node#recurse_through_child_nodes
|
||||||
function eachNode(rootNode, callback) {
|
function eachNode(rootNode, callback) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
const nodes = []
|
const nodes = [];
|
||||||
eachNode(rootNode, function (node) {
|
eachNode(rootNode, function (node) {
|
||||||
nodes.push(node)
|
nodes.push(node);
|
||||||
})
|
});
|
||||||
return nodes
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === callback(rootNode)) {
|
if (false === callback(rootNode)) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootNode.hasChildNodes()) {
|
if (rootNode.hasChildNodes()) {
|
||||||
const nodes = rootNode.childNodes
|
const nodes = rootNode.childNodes;
|
||||||
for (let i = 0, l = nodes.length; i < l; ++i) {
|
for (let i = 0, l = nodes.length; i < l; ++i) {
|
||||||
if (false === eachNode(nodes[i], callback)) {
|
if (false === eachNode(nodes[i], callback)) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const observer = new MutationObserver(function (mutationList) {
|
const observer = new MutationObserver(function (mutationList) {
|
||||||
for (const mutation of mutationList) {
|
for (const mutation of mutationList) {
|
||||||
for (const addedNode of mutation.addedNodes) {
|
for (const addedNode of mutation.addedNodes) {
|
||||||
// recurses through all child nodes as well
|
// recurses through all child nodes as well
|
||||||
eachNode(addedNode, function (node) {
|
eachNode(addedNode, function (node) {
|
||||||
node.nodeName == 'DIV' &&
|
node.nodeName == "DIV" &&
|
||||||
node.classList.contains('ytp-autonav-toggle-button') &&
|
node.classList.contains("ytp-autonav-toggle-button") &&
|
||||||
node.getAttribute('aria-checked') == "true" &&
|
node.getAttribute("aria-checked") == "true" &&
|
||||||
node.click();
|
node.click();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
observer.observe(document, {
|
observer.observe(document, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true,
|
subtree: true,
|
||||||
attributes: true
|
attributes: true,
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user