From ccdfdab01aa65445a252783958810747f5efd2ad Mon Sep 17 00:00:00 2001 From: datguysheepy <36929645+datguysheepy@users.noreply.github.com> Date: Fri, 2 Oct 2020 18:02:50 +0200 Subject: [PATCH] remove all the awards via css file --- manifest.json | 4 +-- no-awards.css | 44 ++++++++++++++++++++++++++++++++ no-awards.js | 69 --------------------------------------------------- 3 files changed, 46 insertions(+), 71 deletions(-) create mode 100644 no-awards.css delete mode 100644 no-awards.js diff --git a/manifest.json b/manifest.json index d3897b3..0e47532 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 2, - "version": "1.2", + "version": "2.0", "name": "No awards for Reddit", "description": "Hide awards on posts and comments for redesigned and also old Reddit.", @@ -15,7 +15,7 @@ "content_scripts": [ { "matches": ["*://*.reddit.com/*"], - "js": ["no-awards.js"] + "css": ["no-awards.css"] } ] } diff --git a/no-awards.css b/no-awards.css new file mode 100644 index 0000000..ad83178 --- /dev/null +++ b/no-awards.css @@ -0,0 +1,44 @@ +/* + div wrapper used both for comments and posts + ONLY FOR NEW REDDIT +*/ +._1wgnb6w6OJogtEV2N4B3lD { + display: none; +} +/* + cross-posted posts have different div wrapper for the awards + this styling hides it completely - USED ON NEW REDDIT.COM +*/ +._3XoW0oYd5806XiOr24gGdb { + display: none; +} + +/* wrapper div for awards used only on OLD.REDDIT.COM */ +.awardings-bar { + display: none; +} + +/* + div used for animated awards - remove red box-shadow + ONLY FOR NEW REDDIT +*/ +._3VH2iGVh92XtlKq0-eVoEN { + box-shadow: none !important; +} + +/* + div wrapper with an animated award svg element + ONLY FOR NEW REDDIT +*/ +._28x1bnTjOY6zWZfooCxkKQ { + display: none; +} + +/* + comments with big(?) ammount of awards have yellowish gradient set as a background + this removes it + ONLY FOR NEW REDDIT +*/ +.TmlaIdEplCzZ0F1aRGYQh { + background: inherit; +} diff --git a/no-awards.js b/no-awards.js deleted file mode 100644 index 14cfe9a..0000000 --- a/no-awards.js +++ /dev/null @@ -1,69 +0,0 @@ -console.log( - "Thanks for using No awards for Reddit! \nGo to github.com/datguysheepy/no-awards-fr for source code" -); - -// because Reddit (after redesign) uses infinite scroll we need to -// hide awards as the user scrolls, and for that we use MutationObserver - -// target and config for the observer -const targetNode = document.body; -const config = { - attributes: false, - childList: true, - subtree: true, -}; - -// Callback function to execute when mutations are observed -const callback = (mutationsList, observer) => { - // hide awards on posts and comments - // used only in new Reddit - const NEW_AWARDS_BAR = document.getElementsByClassName( - "_1wgnb6w6OJogtEV2N4B3lD" - ); - for (let i = 0; i < NEW_AWARDS_BAR.length; i++) { - NEW_AWARDS_BAR[i].style.display = "none"; - } - - // hide awards on cross-posted posts - // used only in new Reddit - const CROSS_POST_NEW_AWARDS_BAR = document.getElementsByClassName( - "_3XoW0oYd5806XiOr24gGdb" - ); - for (let i = 0; i < CROSS_POST_NEW_AWARDS_BAR.length; i++) { - CROSS_POST_NEW_AWARDS_BAR[i].style.display = "none"; - } - - // hide awards at old.reddit.com (on posts and comments) - const OLD_AWARDS_BAR = document.getElementsByClassName("awardings-bar"); - for (let i = 0; i < OLD_AWARDS_BAR.length; i++) { - OLD_AWARDS_BAR[i].style.display = "none"; - } - - // hide animated awards (both icon and the box-shadow arround the comment) - // used only in new Reddit - const ANIMATED_BOX = document.getElementsByClassName( - "_3VH2iGVh92XtlKq0-eVoEN" - ); - for (let i = 0; i < ANIMATED_BOX.length; i++) { - ANIMATED_BOX[i].style.display = "none"; - } - - const ANIMATED_ICON = document.getElementsByClassName( - "_28x1bnTjOY6zWZfooCxkKQ" - ); - for (let i = 0; i < ANIMATED_ICON.length; i++) { - ANIMATED_ICON[i].style.display = "none"; - } - - // hide background-gradient for comments with a lot of awards(?) - // used only in new Reddit - const BOX_WITH_GRADIENT = document.getElementsByClassName( - "TmlaIdEplCzZ0F1aRGYQh" - ); - for (let i = 0; i < BOX_WITH_GRADIENT.length; i++) { - BOX_WITH_GRADIENT[i].style.background = "inherit"; - } -}; - -const observer = new MutationObserver(callback); -observer.observe(targetNode, config);