From 6b54383dec32904e9d4531358a42b07f970f9f5b Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 11 Jul 2019 21:19:07 +0200 Subject: [PATCH 1/5] Rehide video suggestions after clicking on one --- ...ube-addiction-control-extension-firefox.js | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/youtube-addiction-control-extension-firefox.js b/youtube-addiction-control-extension-firefox.js index f4e2df2..e42a28a 100644 --- a/youtube-addiction-control-extension-firefox.js +++ b/youtube-addiction-control-extension-firefox.js @@ -6,7 +6,7 @@ Array.from(document.getElementsByClassName(STYLE_CLASS)).forEach((e) => { e.remove(); }); -let ytacCSS = { +window.ytacCSS = { "sidebar": "#related", "comments": "#comments", "endscreen": ".videowall-endscreen", @@ -15,24 +15,37 @@ let ytacCSS = { "other": "#newness-dot, .ytp-spinner" }; -const INVISIBLE = " { display: none !important; }" +const INVISIBLE = " { display: none !important; }"; -let head = document.getElementsByTagName('head')[0]; -for (key of Object.keys(ytacCSS)) { +function addCSS(key) { + if (document.getElementById("ytac" + key) !== null) { + return; + } + let head = document.getElementsByTagName('head')[0]; let e = document.createElement('style'); e.setAttribute('type', 'text/css'); e.setAttribute("class", STYLE_CLASS); e.setAttribute("id", "ytac" + key); if ('textContent' in e) { - e.textContent = ytacCSS[key] + INVISIBLE; + e.textContent = window.ytacCSS[key] + INVISIBLE; } else { - e.styleSheet.cssText = ytacCSS[key] + INVISIBLE; + e.styleSheet.cssText = window.ytacCSS[key] + INVISIBLE; } head.appendChild(e); } +function addClickListeners(key) { + for (el of document.querySelectorAll(window.ytacCSS[key])) { + el.addEventListener("click", (e) => addCSS(key)); + } +} + +for (key of Object.keys(window.ytacCSS)) { + addCSS(key); +} + // browser action listener // Listen for messages from the background script. @@ -47,6 +60,7 @@ window.ytacListener = (message) => { } else if (message.command == "sidebar") { console.log("[YTAC] showing video sidebar"); document.getElementById("ytacsidebar").remove(); + addClickListeners("sidebar"); } else if (message.command == "invideo") { console.log("[YTAC] showing in-video suggestions"); document.getElementById("ytacinvideo").remove(); From fc6341cb486af7c18ae1a1ce970e6ac91b097078 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sat, 13 Jul 2019 12:11:25 +0200 Subject: [PATCH 2/5] Rehide other elements too --- youtube-addiction-control-extension-firefox.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/youtube-addiction-control-extension-firefox.js b/youtube-addiction-control-extension-firefox.js index e42a28a..4cbdf59 100644 --- a/youtube-addiction-control-extension-firefox.js +++ b/youtube-addiction-control-extension-firefox.js @@ -56,7 +56,7 @@ window.ytacListener = (message) => { console.log("[YTAC] received browser action " + message.command); if (message.command == "comments") { console.log("[YTAC] showing comments"); - document.getElementById("ytaccomments").remove(); + document.getElementById("ytaccomments").remove(); } else if (message.command == "sidebar") { console.log("[YTAC] showing video sidebar"); document.getElementById("ytacsidebar").remove(); @@ -64,12 +64,15 @@ window.ytacListener = (message) => { } else if (message.command == "invideo") { console.log("[YTAC] showing in-video suggestions"); document.getElementById("ytacinvideo").remove(); + addClickListeners("invideo"); } else if (message.command == "endscreen") { console.log("[YTAC] showing endscreen"); document.getElementById("ytacendscreen").remove(); + addClickListeners("endscreen"); } else if (message.command == "notification") { console.log("[YTAC] showing notification bell"); document.getElementById("ytacnotification").remove(); + addClickListeners("notification"); } }; browser.runtime.onMessage.addListener(window.ytacListener); From 6abd98e142e8d8b1a14b0c8aae5aee61dc5493a8 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sat, 13 Jul 2019 12:22:28 +0200 Subject: [PATCH 3/5] Add homepage (repo) link --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a5575c4..d447fc3 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "manifest_version": 2, "name": "YT addiction control", "version": "0.1", - "homepage_url": "https://github.repository.todo/", + "homepage_url": "https://gitlab.com/arnekeller/yt-addiction-control", "icons": { "48": "icons/ytac.svg" From 0fde7b618f2a4af5886b0f3afdcf91cbd5d8a51b Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sun, 14 Jul 2019 11:48:15 +0200 Subject: [PATCH 4/5] Hide notification count in tab title --- youtube-addiction-control-extension-firefox.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/youtube-addiction-control-extension-firefox.js b/youtube-addiction-control-extension-firefox.js index 4cbdf59..8cbe82c 100644 --- a/youtube-addiction-control-extension-firefox.js +++ b/youtube-addiction-control-extension-firefox.js @@ -97,4 +97,14 @@ function modifyThings() { showMoreButton[0].click(); } } -modifyThings(); \ No newline at end of file +modifyThings(); + +// attempt to hide the notification count in the title + +function hideNotificationCount() { + let a = document.getElementsByTagName("title")[0]; + if (a.innerText.match("^\\(\\d+\\).*")) { + a.innerText = a.innerText.substr(a.innerText.indexOf(")") + 2); + } +} +setInterval(hideNotificationCount, 1000); \ No newline at end of file From 349d175b784799c3e3e945d6b923342bee9d5155 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Tue, 23 Jul 2019 11:03:34 +0200 Subject: [PATCH 5/5] Bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index d447fc3..372bbc7 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "description": "Enables you to fight your youtube addiction by disabling video suggestions and related 'features' of YouTube's website.", "manifest_version": 2, "name": "YT addiction control", - "version": "0.1", + "version": "0.1.1", "homepage_url": "https://gitlab.com/arnekeller/yt-addiction-control", "icons": {