From 7b74311278d0857ad10db1ff610ca69456be3a60 Mon Sep 17 00:00:00 2001 From: kappa Date: Fri, 3 Jan 2020 12:48:26 +0100 Subject: [PATCH] Initial git commit --- README.md | 11 +++++++++++ manifest.json | 25 +++++++++++++++++++++++++ options.html | 17 +++++++++++++++++ options.js | 16 ++++++++++++++++ styles.css | 40 ++++++++++++++++++++++++++++++++++++++++ styles.js | 17 +++++++++++++++++ 6 files changed, 126 insertions(+) create mode 100644 README.md create mode 100644 manifest.json create mode 100644 options.html create mode 100644 options.js create mode 100644 styles.css create mode 100644 styles.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..56281ac --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +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 + +# youtube-feed-hider +A Chrome extension for hiding the feed on Youtube.com + +Install here: +https://chrome.google.com/webstore/detail/fkhfakakdbjcdipdgnbfngaljiecclaf/ + +Also see this related extension from Stanford: +https://habitlab.stanford.edu/ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..0336097 --- /dev/null +++ b/manifest.json @@ -0,0 +1,25 @@ +{ + "name": "Youtube UnHooked", + "version": "0.9", + "description": "Hides parts of Youtube that are unneeded/addictive: recommendations, related videos, comments.", + "content_scripts": [ + { + "matches": ["https://www.youtube.com/*"], + "css": ["styles.css"], + "js": ["styles.js"] + } + ], + "browser_specific_settings": { + "gecko": { + "id": "youtube-unhooked@ffffff.gov" + } + }, + "manifest_version": 2, + "options_ui": { + "page": "options.html", + "browser_style": true + }, + "permissions": [ + "storage" + ] +} diff --git a/options.html b/options.html new file mode 100644 index 0000000..97a1ac7 --- /dev/null +++ b/options.html @@ -0,0 +1,17 @@ + + + + + + + + +
+
+ Disable Comments?
+
+ +
+ + + diff --git a/options.js b/options.js new file mode 100644 index 0000000..ae532cd --- /dev/null +++ b/options.js @@ -0,0 +1,16 @@ +function saveOptions(e) { + browser.storage.sync.set({ + commentsRemove: document.getElementById("commentsRemoveCheck").checked + }); + e.preventDefault(); +} + +function restoreOptions() { + var gettingItem = browser.storage.sync.get({commentsRemove: false}); + gettingItem.then((res) => { + document.getElementById("commentsRemoveCheck").checked = res.commentsRemove; + }); +} + +document.addEventListener('DOMContentLoaded', restoreOptions); +document.querySelector("form").addEventListener("submit", saveOptions); diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..5213709 --- /dev/null +++ b/styles.css @@ -0,0 +1,40 @@ +/** Youtube CSS overrides **/ + +/** FRONT PAGE FEED **/ + +/** Displayed while loading, grey boxes **/ +#home-page-skeleton { + display: none !important; +} + +/** + Must use visibility instead of display as otherwise + it thinks that the user has scrolled and tries to load + additional feed items repeatedly. + **/ +ytd-browse[role="main"][page-subtype="home"] #contents { + visibility: hidden !important; +} + +/** RELATED VIDEOS (SIDEBAR) **/ + +/** Displayed while loading, grey boxes **/ +#related-skeleton, .watch-skeleton { + display: none !important; +} + +ytd-watch-next-secondary-results-renderer { + visibility: hidden !important; +} + +/** COMMENTS **/ + +/* changed +ytd-comments { + visibility: visible !important; +} */ + +/** RELATED VIDEOS (END OF VIDEO SCREEN) **/ +.ytp-videowall-still, .ytp-endscreen-previous, .ytp-endscreen-next { + display: none !important; +} diff --git a/styles.js b/styles.js new file mode 100644 index 0000000..0c8dcc1 --- /dev/null +++ b/styles.js @@ -0,0 +1,17 @@ +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"; +} + +function onGot(result) { + var remove = result.commentsRemove; + setComments(remove); + // Sets the visibility of the comments section depending on the storage vairable +} +function onFailure(error) { + alert(`Error: ${error}`); +} + +gettingItem.then(onGot, onFailure);