Compare commits
2 Commits
71751283e1
...
38eee1eb44
Author | SHA1 | Date | |
---|---|---|---|
38eee1eb44 | |||
8829166139 |
|
@ -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,26 +45,48 @@ 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 {
|
||||
/* zoom: 1.8; */
|
||||
zoom: 1.8;
|
||||
}
|
||||
*/
|
||||
|
||||
footer {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
}
|
||||
if (document.domain == "twitter.com") {
|
||||
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"])
|
||||
|
@ -155,62 +169,10 @@ if (document.domain == "twitter.com") {
|
|||
[aria-live^="polite"]{
|
||||
background: white !important;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
// Function to hide the grandparent of video players
|
||||
function hideVideoPlayerGrandparent() {
|
||||
document
|
||||
.querySelectorAll('[data-testid="videoPlayer"]')
|
||||
.forEach(function (videoPlayer) {
|
||||
var grandparentElement =
|
||||
videoPlayer.parentElement.parentElement.parentElement.parentElement
|
||||
.parentElement.parentElement;
|
||||
var newTextElement = document.createElement("div");
|
||||
newTextElement.textContent = " [ twitter video ] ";
|
||||
newTextElement.style["margin-top"] = "10px";
|
||||
newTextElement.style["margin-left"] = "10px";
|
||||
newTextElement.style["margin-bottom"] = "10px";
|
||||
grandparentElement.replaceWith(newTextElement);
|
||||
});
|
||||
}
|
||||
|
||||
// Create a new MutationObserver instance
|
||||
var observer = new MutationObserver(function (mutations) {
|
||||
mutations.forEach(function (mutation) {
|
||||
if (mutation.addedNodes.length) {
|
||||
hideVideoPlayerGrandparent(); // Call the function to hide video players
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Options for the observer (which mutations to observe)
|
||||
var config = { childList: true, subtree: true };
|
||||
|
||||
// Start observing the target node for configured mutations
|
||||
observer.observe(document.body, config);
|
||||
|
||||
// Call the function initially to hide any video players on initial load
|
||||
hideVideoPlayerGrandparent();
|
||||
}
|
||||
|
||||
if (document.domain == "reddit.com" || document.domain == "old.reddit.com") {
|
||||
styles = `
|
||||
/* kill sidebar ads */
|
||||
.native-ad-container,
|
||||
.premium-banner-outer,
|
||||
.native-sidebar-ad,
|
||||
.infobar-toaster-container,
|
||||
#eu-cookie-policy,
|
||||
.ad-container,
|
||||
.listingsignupbar,
|
||||
a[href="/premium"],
|
||||
[data-promoted^="true"],
|
||||
a[href^="https://alb.reddit.com"]
|
||||
{
|
||||
display: none !important;
|
||||
}
|
||||
`;
|
||||
break;
|
||||
default:
|
||||
console.log("No custom style");
|
||||
}
|
||||
|
||||
if (styles != null) {
|
||||
|
@ -220,7 +182,7 @@ if (styles != null) {
|
|||
console.log("Style changed");
|
||||
}
|
||||
|
||||
// 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");
|
||||
|
@ -279,7 +241,46 @@ window.alert = (message) => {
|
|||
document.getElementById("alertMessage").textContent = message;
|
||||
alertDiv.classList.add("visible");
|
||||
};
|
||||
// ^ takes 0.014ms to run, so performance is not the concern here.
|
||||
// timed with console.time, console.timeEnd
|
||||
|
||||
// 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.
|
||||
// timed with console.time, console.timeEnd
|
||||
|
||||
function hideVideoPlayerGrandparent() {
|
||||
document
|
||||
.querySelectorAll('[data-testid="videoPlayer"]')
|
||||
.forEach(function (videoPlayer) {
|
||||
var grandparentElement =
|
||||
videoPlayer.parentElement.parentElement.parentElement.parentElement
|
||||
.parentElement.parentElement;
|
||||
var newTextElement = document.createElement("div");
|
||||
newTextElement.textContent = " [ twitter video ] ";
|
||||
newTextElement.style["margin-top"] = "10px";
|
||||
newTextElement.style["margin-left"] = "10px";
|
||||
newTextElement.style["margin-bottom"] = "10px";
|
||||
grandparentElement.replaceWith(newTextElement);
|
||||
});
|
||||
}
|
||||
|
||||
// Create a new MutationObserver instance
|
||||
var observer = new MutationObserver(function (mutations) {
|
||||
mutations.forEach(function (mutation) {
|
||||
if (mutation.addedNodes.length) {
|
||||
hideVideoPlayerGrandparent(); // Call the function to hide video players
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Options for the observer (which mutations to observe)
|
||||
var config = { childList: true, subtree: true };
|
||||
|
||||
// Start observing the target node for configured mutations
|
||||
observer.observe(document.body, config);
|
||||
|
||||
// Call the function initially to hide any video players on initial load
|
||||
hideVideoPlayerGrandparent();
|
||||
}
|
||||
|
||||
document.body.style.visibility = "visible";
|
||||
|
|
Loading…
Reference in New Issue
Block a user