Now using more effective way to change comment visibility

This commit is contained in:
kappa 2020-01-16 21:35:32 +01:00
parent 7b74311278
commit d3fd1b8645
3 changed files with 14 additions and 3 deletions

View file

@ -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. A fork of the original Youtube UnHooked, with some added features, including the ability to toggle comment visibility in the extension preferences.
The content of the original README follows 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 # youtube-feed-hider
A Chrome extension for hiding the feed on Youtube.com A Chrome extension for hiding the feed on Youtube.com

View file

@ -4,6 +4,7 @@
"description": "Hides parts of Youtube that are unneeded/addictive: recommendations, related videos, comments.", "description": "Hides parts of Youtube that are unneeded/addictive: recommendations, related videos, comments.",
"content_scripts": [ "content_scripts": [
{ {
"run_at": "document_start",
"matches": ["https://www.youtube.com/*"], "matches": ["https://www.youtube.com/*"],
"css": ["styles.css"], "css": ["styles.css"],
"js": ["styles.js"] "js": ["styles.js"]

View file

@ -2,7 +2,12 @@ let gettingItem = browser.storage.sync.get({commentsRemove: false});
// Retrieves the storage variable to determine whether comments should be removed // Retrieves the storage variable to determine whether comments should be removed
function setComments(remove) { 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) { function onGot(result) {