diff --git a/README.md b/README.md index 56281ac..0ab144e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ -A fork of the original Youtube UnHooked, with soma added features, including the ability to toggle comment visibility in the extension preferences. -The content of the original README follows +A fork of the original Youtube UnHooked, with some added features, including the ability to toggle comment visibility in the extension preferences. +TODOs/bugs: +Make comment visibility automatically change when settings are changed. +Revert comment changes when the extension is disabled/uninstalled (maybe impossible) +Automatically turn off "autoplay" when the extension is run. + +The content of the original README follows: # youtube-feed-hider A Chrome extension for hiding the feed on Youtube.com diff --git a/manifest.json b/manifest.json index 0336097..7e9c5df 100644 --- a/manifest.json +++ b/manifest.json @@ -4,6 +4,7 @@ "description": "Hides parts of Youtube that are unneeded/addictive: recommendations, related videos, comments.", "content_scripts": [ { + "run_at": "document_start", "matches": ["https://www.youtube.com/*"], "css": ["styles.css"], "js": ["styles.js"] diff --git a/styles.js b/styles.js index 0c8dcc1..22b4903 100644 --- a/styles.js +++ b/styles.js @@ -2,7 +2,12 @@ let gettingItem = browser.storage.sync.get({commentsRemove: false}); // Retrieves the storage variable to determine whether comments should be removed function setComments(remove) { - document.getElementsByTagName("ytd-comments")[0].style.visibility = remove ? "hidden" : "visible"; + if (!remove) + return; + var commentStyle = document.createElement('style'); + document.head.appendChild(commentStyle); + + commentStyle.sheet.insertRule("ytd-comments {visibility: hidden !important}"); } function onGot(result) {