aboutsummaryrefslogtreecommitdiffstats
path: root/youtube-turn-off-annotations.user.js
diff options
context:
space:
mode:
authorTeddy Wing2018-07-28 08:25:01 +0200
committerTeddy Wing2018-07-28 08:25:01 +0200
commitac1fe4a89b63eebca21538779e4113d792e481e9 (patch)
tree2300e6918a6ee7e5e18d41469ee8acd7abc1236d /youtube-turn-off-annotations.user.js
parent2b0a82f1a21a719f82413d00c4757f02a0fe03e1 (diff)
downloadyoutube-turn-off-annotations-ac1fe4a89b63eebca21538779e4113d792e481e9.tar.bz2
Move annotation shutoff code into interval
Still not working, just an idea while figuring out what's going on & how to get access to the menu item.
Diffstat (limited to 'youtube-turn-off-annotations.user.js')
-rw-r--r--youtube-turn-off-annotations.user.js58
1 files changed, 31 insertions, 27 deletions
diff --git a/youtube-turn-off-annotations.user.js b/youtube-turn-off-annotations.user.js
index eaaf889..6691df6 100644
--- a/youtube-turn-off-annotations.user.js
+++ b/youtube-turn-off-annotations.user.js
@@ -6,37 +6,41 @@
// ==/UserScript==
-var annotations_menu_item = document.evaluate(
- "//div[contains(@class, 'ytp-settings-menu')] \
- //div[ \
- @aria-checked='true' and \
+var find_annotations_interval = window.setInterval(function() {
+ var annotations_is_present = document.evaluate(
+ "//div[contains(@class, 'ytp-settings-menu')] \
//div[ \
contains(@class, 'ytp-menuitem-label') and \
contains(., 'Annotations') \
- ] \
- ]",
- document,
- null,
- XPathResult.FIRST_ORDERED_NODE_TYPE,
- null
-);
+ ]",
+ document,
+ null,
+ XPathResult.FIRST_ORDERED_NODE_TYPE,
+ null
+ );
-// if (annotations_menu_item) {
-// annotations_menu_item.singleNodeValue.click();
-// }
+ console.log(annotations_is_present);
+ if (annotations_is_present) {
+ var annotations_menu_item = document.evaluate(
+ "//div[contains(@class, 'ytp-settings-menu')] \
+ //div[ \
+ @aria-checked='true' and \
+ //div[ \
+ contains(@class, 'ytp-menuitem-label') and \
+ contains(., 'Annotations') \
+ ] \
+ ]",
+ document,
+ null,
+ XPathResult.FIRST_ORDERED_NODE_TYPE,
+ null
+ );
-window.setInterval(function() {
-var annotations = document.evaluate(
- "//div[contains(@class, 'ytp-settings-menu')] \
- //div[ \
- contains(@class, 'ytp-menuitem-label') and \
- contains(., 'Annotations') \
- ]",
- document,
- null,
- XPathResult.FIRST_ORDERED_NODE_TYPE,
- null
-);
+ if (annotations_menu_item.singleNodeValue) {
+ annotations_menu_item.singleNodeValue.click();
+ console.log(annotations_menu_item.singleNodeValue);
+ }
- console.log(annotations.singleNodeValue);
+ // window.clearInterval(find_annotations_interval);
+ }
}, 1000);