diff options
author | NunoSempere <nuno.semperelh@protonmail.com> | 2024-03-21 08:47:57 -0300 |
---|---|---|
committer | NunoSempere <nuno.semperelh@protonmail.com> | 2024-03-21 08:47:57 -0300 |
commit | 38eee1eb4459b5b4ec2397e888f17a970f22e31f (patch) | |
tree | a20df0cc10120bdd6018a22803f00c38e638003f /plugins/style | |
parent | 8829166139f18c000bf3083eea3635d43fcb847e (diff) |
rework style code to use a switch statement
Diffstat (limited to 'plugins/style')
-rw-r--r-- | plugins/style/style.js | 338 |
1 files changed, 166 insertions, 172 deletions
diff --git a/plugins/style/style.js b/plugins/style/style.js index 1c0983b..e3eeda7 100644 --- a/plugins/style/style.js +++ b/plugins/style/style.js @@ -1,97 +1,178 @@ // Inspired by the Stylus app: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/> +// Main part of the code: switch on the domain and select the corresponding style var styles = null; +switch (document.domain) { + case "forum.effectivealtruism.org": + styles = ` + /* + .Layout-main { + margin-left: 100px; + } + .SingleColumnSection-root { + width: 1000px !important; + max-width: 1400px !important; + padding-left: 100px !important; + } + .NavigationStandalone-sidebar { + display: none; + } + .intercom-lightweight-app{ + display: none; + } + */ + `; + break; + case "nationstates.net": + styles = ` + .adidentifier { + display: none; + } + `; + break; + case "mail.proton.me": + styles = ` + /* + .item-container-row.read, .item-container.read { + background-color: white; + } + .item-container-row.unread, .item-container.unread { + background-color: #E8E8E8; + } + .selection .item-container-row.item-is-selected, .item-container.item-is-selected { + background-color: var(--selection-background-color) !important; + } + zoom: 0.625 !important; + */ + `; + break; + case "forum.nunosempere.com": + styles = ` + body { + zoom: 0.625 !important; + } + `; + break; + case "search.nunosempere.com": + styles = ` + /* + body { + zoom: 1.8; + } + */ -/* + footer { + display: none; + } + `; + break; + case "reddit.com": + // fallthrough + case "old.reddit.com": + styles = ` + /* kill sidebar ads */ + .ad-container, + a[href^="https://alb.reddit.com"] + a[href="/premium"], + [data-promoted^="true"], + #eu-cookie-policy, + .infobar-toaster-container, + .listingsignupbar, + .native-ad-container, + .native-sidebar-ad, + .premium-banner-outer, + { + display: none !important; + } + `; + break; + case "twitter.com": + styles = ` + /* hide promoted tweets */ + :has(meta[property="og:site_name"][content="Twitter"]) + [data-testid="cellInnerDiv"]:has(svg + [dir="auto"]) { + display: none; + } + [data-testid^="placementTracking"] { + display: none; + } -.class -#id + /* hide what's happening section */ + :has(meta[property="og:site_name"][content="Twitter"]) + [aria-label="Timeline: Trending now"] { + display: none !important; + } + [data-testid^="sidebarColumn"] { + display: none; + } -*/ + /* Hide DMs v2 */ + [data-testid^="DMDrawerHeader"] { + display: none; + } -if (document.domain == "forum.effectivealtruism.org") { - styles = ` - /* - .Layout-main { - margin-left: 100px; - } - .SingleColumnSection-root { - width: 1000px !important; - max-width: 1400px !important; - padding-left: 100px !important; - } - .NavigationStandalone-sidebar { - display: none; - } - .intercom-lightweight-app{ - display: none; - } - */ - `; -} + /* Tweak main column */ + [data-testid^="primaryColumn"] { + min-width: 900px; + max-width: 900px; + } + [data-testid^="cellInnerDiv"] { + min-width: 700px; + max-width: 700px; + } + [aria-label^="Timeline: Conversation"]{ + margin-left: 145px; + } + [data-testid^="DMDrawer"]{ + display: none; + } -if (document.domain == "nationstates.net") { - styles = ` - .adidentifier { - display: none; - } - `; -} + /* Delete a few unused or annoying elements */ + [aria-label^="Verified Orgs"] { + display: none; + } + [aria-label^="Lists"] { + display: none; + } + [aria-label^="Communities"] { + display: none; + } + [aria-label^="Primary"] { + margin-top: 50px; + } + [role^="progressbar"]{ + display: none; + } -if (document.domain == "mail.proton.me") { - styles = ` - /* - .item-container-row.read, .item-container.read { - background-color: white; - } - .item-container-row.unread, .item-container.unread { - background-color: #E8E8E8; - } - .selection .item-container-row.item-is-selected, .item-container.item-is-selected { - background-color: var(--selection-background-color) !important; - } - zoom: 0.625 !important; - */ - `; -} -if (document.domain == "forum.nunosempere.com") { - styles = ` - body { - zoom: 0.625 !important; - } - `; -} -if (document.domain == "search.nunosempere.com") { - styles = ` - /* - body { - zoom: 1.8; - } - */ + /* hide video */ + [data-testid^="videoPlayer"] { + display: none !important; + } - footer { - display: none; - } - `; -} + /* No change of colors in hover */ + *:hover { + /* background-color: white !important; */ + background-color: !important; + transition: none !important; + }*/ + /* + *:hover { + background-color: inherit !important; + transition: none !important; + }*/ + /* Hide go to top button */ + [aria-label^="New posts are available. Push the period key to go to the them."]{ + display: none; + } -if (document.domain == "reddit.com" || document.domain == "old.reddit.com") { - styles = ` - /* kill sidebar ads */ - .ad-container, - a[href^="https://alb.reddit.com"] - a[href="/premium"], - [data-promoted^="true"], - #eu-cookie-policy, - .infobar-toaster-container, - .listingsignupbar, - .native-ad-container, - .native-sidebar-ad, - .premium-banner-outer, - { - display: none !important; - } - `; + /* No transparency at the top */ + [aria-live^="polite"]{ + background: white !important; + } + `; + break; + default: + console.log("No custom style"); } if (styles != null) { @@ -101,95 +182,7 @@ if (styles != null) { console.log("Style changed"); } - -if (document.domain == "twitter.com") { - styles = ` - /* hide promoted tweets */ - :has(meta[property="og:site_name"][content="Twitter"]) - [data-testid="cellInnerDiv"]:has(svg + [dir="auto"]) { - display: none; - } - [data-testid^="placementTracking"] { - display: none; - } - - /* hide what's happening section */ - :has(meta[property="og:site_name"][content="Twitter"]) - [aria-label="Timeline: Trending now"] { - display: none !important; - } - [data-testid^="sidebarColumn"] { - display: none; - } - - /* Hide DMs v2 */ - [data-testid^="DMDrawerHeader"] { - display: none; - } - - /* Tweak main column */ - [data-testid^="primaryColumn"] { - min-width: 900px; - max-width: 900px; - } - [data-testid^="cellInnerDiv"] { - min-width: 700px; - max-width: 700px; - } - [aria-label^="Timeline: Conversation"]{ - margin-left: 145px; - } - [data-testid^="DMDrawer"]{ - display: none; - } - - /* Delete a few unused or annoying elements */ - [aria-label^="Verified Orgs"] { - display: none; - } - [aria-label^="Lists"] { - display: none; - } - [aria-label^="Communities"] { - display: none; - } - [aria-label^="Primary"] { - margin-top: 50px; - } - [role^="progressbar"]{ - display: none; - } - - /* hide video */ - [data-testid^="videoPlayer"] { - display: none !important; - } - - /* No change of colors in hover */ - *:hover { - /* background-color: white !important; */ - background-color: !important; - transition: none !important; - }*/ - /* - *:hover { - background-color: inherit !important; - transition: none !important; - }*/ - /* Hide go to top button */ - [aria-label^="New posts are available. Push the period key to go to the them."]{ - display: none; - } - - /* No transparency at the top */ - [aria-live^="polite"]{ - background: white !important; - } - `; - -} - -// Replace default alert with new function +// Extra: Replace default alert with new function // whose style can be changed! window.alert = (message) => { let alertDiv = document.getElementById("customAlert"); @@ -249,6 +242,7 @@ window.alert = (message) => { alertDiv.classList.add("visible"); }; +// Extra: hide video players on twitter if (document.domain == "twitter.com") { // Function to hide the grandparent of video players // takes 0.014ms to run, so performance is not the concern here. |