Compare commits

...

2 Commits

@ -1,164 +1,253 @@
// Inspired by the Stylus app: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/> // 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; var styles = null;
switch (document.domain) {
/* case "forum.effectivealtruism.org":
styles = `
.class /*
#id
*/
if (document.domain == "forum.effectivealtruism.org") {
styles = `
/*
.Layout-main { .Layout-main {
margin-left: 100px; margin-left: 100px;
} }
.SingleColumnSection-root { .SingleColumnSection-root {
width: 1000px !important; width: 1000px !important;
max-width: 1400px !important; max-width: 1400px !important;
padding-left: 100px !important; padding-left: 100px !important;
} }
.NavigationStandalone-sidebar { .NavigationStandalone-sidebar {
display: none; display: none;
} }
.intercom-lightweight-app{ .intercom-lightweight-app{
display: none; 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;
}
*/
if (document.domain == "nationstates.net") { footer {
styles = ` display: none;
.adidentifier { }
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;
}
if (document.domain == "mail.proton.me") { /* hide what's happening section */
styles = ` :has(meta[property="og:site_name"][content="Twitter"])
/* [aria-label="Timeline: Trending now"] {
.item-container-row.read, .item-container.read { display: none !important;
background-color: white; }
} [data-testid^="sidebarColumn"] {
.item-container-row.unread, .item-container.unread { display: none;
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; */
}
footer { /* Hide DMs v2 */
display: none; [data-testid^="DMDrawerHeader"] {
} display: none;
`; }
}
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 */ /* Tweak main column */
:has(meta[property="og:site_name"][content="Twitter"]) [data-testid^="primaryColumn"] {
[aria-label="Timeline: Trending now"] { min-width: 900px;
display: none !important; max-width: 900px;
} }
[data-testid^="sidebarColumn"] { [data-testid^="cellInnerDiv"] {
display: none; min-width: 700px;
} max-width: 700px;
}
[aria-label^="Timeline: Conversation"]{
margin-left: 145px;
}
[data-testid^="DMDrawer"]{
display: none;
}
/* Hide DMs v2 */ /* Delete a few unused or annoying elements */
[data-testid^="DMDrawerHeader"] { [aria-label^="Verified Orgs"] {
display: none; display: none;
} }
[aria-label^="Lists"] {
display: none;
}
[aria-label^="Communities"] {
display: none;
}
[aria-label^="Primary"] {
margin-top: 50px;
}
[role^="progressbar"]{
display: none;
}
/* Tweak main column */ /* hide video */
[data-testid^="primaryColumn"] { [data-testid^="videoPlayer"] {
min-width: 900px; display: none !important;
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 */ /* No change of colors in hover */
[aria-label^="Verified Orgs"] { *:hover {
display: none; /* background-color: white !important; */
} background-color: !important;
[aria-label^="Lists"] { transition: none !important;
display: none; }*/
} /*
[aria-label^="Communities"] { *:hover {
display: none; background-color: inherit !important;
} transition: none !important;
[aria-label^="Primary"] { }*/
margin-top: 50px; /* Hide go to top button */
} [aria-label^="New posts are available. Push the period key to go to the them."]{
[role^="progressbar"]{ display: none;
display: none; }
}
/* hide video */ /* No transparency at the top */
[data-testid^="videoPlayer"] { [aria-live^="polite"]{
display: none !important; background: white !important;
} }
`;
break;
default:
console.log("No custom style");
}
/* No change of colors in hover */ if (styles != null) {
*:hover { var styleSheet = document.createElement("style");
/* background-color: white !important; */ styleSheet.innerText = styles;
background-color: !important; document.head.appendChild(styleSheet);
transition: none !important; console.log("Style changed");
}*/ }
/*
*: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 */ // Extra: Replace default alert with new function
[aria-live^="polite"]{ // whose style can be changed!
background: white !important; window.alert = (message) => {
let alertDiv = document.getElementById("customAlert");
if (!alertDiv) {
const html = `
<div id="customAlert" class="custom-alert">
<div class="custom-alert-content">
<p id="alertMessage"></p>
<button id="alertOkButton">OK</button>
</div>
</div>
<style>
.custom-alert {
display: none;
position: fixed;
z-index: 999;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
}
.custom-alert-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
font-family: monospace; /* Use monospace font */
}
.visible {
display: block;
}
</style>
`;
document.body.insertAdjacentHTML("beforeend", html);
alertDiv = document.getElementById("customAlert");
document.getElementById("alertOkButton").onclick = () => {
alertDiv.classList.remove("visible");
document.removeEventListener("keydown", dismissAlert);
};
} }
`; const dismissAlert = (event) => {
if (
event.key === "Enter" /*&& event.ctrlKey*/ &&
alertDiv.classList.contains("visible")
) {
alertDiv.classList.remove("visible");
document.removeEventListener("keydown", dismissAlert);
}
};
document.addEventListener("keydown", dismissAlert);
document.getElementById("alertMessage").textContent = message;
alertDiv.classList.add("visible");
};
// Extra: hide video players on twitter
if (document.domain == "twitter.com") {
// Function to hide the grandparent of video players // 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() { function hideVideoPlayerGrandparent() {
document document
.querySelectorAll('[data-testid="videoPlayer"]') .querySelectorAll('[data-testid="videoPlayer"]')
@ -194,92 +283,4 @@ if (document.domain == "twitter.com") {
hideVideoPlayerGrandparent(); 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;
}
`;
}
if (styles != null) {
var styleSheet = document.createElement("style");
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);
console.log("Style changed");
}
// Replace default alert with new function
// whose style can be changed!
window.alert = (message) => {
let alertDiv = document.getElementById("customAlert");
if (!alertDiv) {
const html = `
<div id="customAlert" class="custom-alert">
<div class="custom-alert-content">
<p id="alertMessage"></p>
<button id="alertOkButton">OK</button>
</div>
</div>
<style>
.custom-alert {
display: none;
position: fixed;
z-index: 999;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.4);
}
.custom-alert-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
font-family: monospace; /* Use monospace font */
}
.visible {
display: block;
}
</style>
`;
document.body.insertAdjacentHTML("beforeend", html);
alertDiv = document.getElementById("customAlert");
document.getElementById("alertOkButton").onclick = () => {
alertDiv.classList.remove("visible");
document.removeEventListener("keydown", dismissAlert);
};
}
const dismissAlert = (event) => {
if (
event.key === "Enter" /*&& event.ctrlKey*/ &&
alertDiv.classList.contains("visible")
) {
alertDiv.classList.remove("visible");
document.removeEventListener("keydown", dismissAlert);
}
};
document.addEventListener("keydown", dismissAlert);
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
document.body.style.visibility = "visible"; document.body.style.visibility = "visible";

Loading…
Cancel
Save