rework style code to use a switch statement
This commit is contained in:
parent
8829166139
commit
38eee1eb44
|
@ -1,15 +1,9 @@
|
|||
// 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;
|
||||
|
||||
/*
|
||||
|
||||
.class
|
||||
#id
|
||||
|
||||
*/
|
||||
|
||||
if (document.domain == "forum.effectivealtruism.org") {
|
||||
switch (document.domain) {
|
||||
case "forum.effectivealtruism.org":
|
||||
styles = `
|
||||
/*
|
||||
.Layout-main {
|
||||
|
@ -28,17 +22,15 @@ if (document.domain == "forum.effectivealtruism.org") {
|
|||
}
|
||||
*/
|
||||
`;
|
||||
}
|
||||
|
||||
if (document.domain == "nationstates.net") {
|
||||
break;
|
||||
case "nationstates.net":
|
||||
styles = `
|
||||
.adidentifier {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
if (document.domain == "mail.proton.me") {
|
||||
break;
|
||||
case "mail.proton.me":
|
||||
styles = `
|
||||
/*
|
||||
.item-container-row.read, .item-container.read {
|
||||
|
@ -53,15 +45,15 @@ if (document.domain == "mail.proton.me") {
|
|||
zoom: 0.625 !important;
|
||||
*/
|
||||
`;
|
||||
}
|
||||
if (document.domain == "forum.nunosempere.com") {
|
||||
break;
|
||||
case "forum.nunosempere.com":
|
||||
styles = `
|
||||
body {
|
||||
zoom: 0.625 !important;
|
||||
}
|
||||
`;
|
||||
}
|
||||
if (document.domain == "search.nunosempere.com") {
|
||||
break;
|
||||
case "search.nunosempere.com":
|
||||
styles = `
|
||||
/*
|
||||
body {
|
||||
|
@ -73,9 +65,10 @@ if (document.domain == "search.nunosempere.com") {
|
|||
display: none;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
if (document.domain == "reddit.com" || document.domain == "old.reddit.com") {
|
||||
break;
|
||||
case "reddit.com":
|
||||
// fallthrough
|
||||
case "old.reddit.com":
|
||||
styles = `
|
||||
/* kill sidebar ads */
|
||||
.ad-container,
|
||||
|
@ -92,17 +85,8 @@ if (document.domain == "reddit.com" || document.domain == "old.reddit.com") {
|
|||
display: none !important;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
if (styles != null) {
|
||||
var styleSheet = document.createElement("style");
|
||||
styleSheet.innerText = styles;
|
||||
document.head.appendChild(styleSheet);
|
||||
console.log("Style changed");
|
||||
}
|
||||
|
||||
|
||||
if (document.domain == "twitter.com") {
|
||||
break;
|
||||
case "twitter.com":
|
||||
styles = `
|
||||
/* hide promoted tweets */
|
||||
:has(meta[property="og:site_name"][content="Twitter"])
|
||||
|
@ -186,10 +170,19 @@ if (document.domain == "twitter.com") {
|
|||
background: white !important;
|
||||
}
|
||||
`;
|
||||
|
||||
break;
|
||||
default:
|
||||
console.log("No custom style");
|
||||
}
|
||||
|
||||
// Replace default alert with new function
|
||||
if (styles != null) {
|
||||
var styleSheet = document.createElement("style");
|
||||
styleSheet.innerText = styles;
|
||||
document.head.appendChild(styleSheet);
|
||||
console.log("Style changed");
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user