2024-03-21 11:29:13 +00:00
|
|
|
// Inspired by the Stylus app: <https://addons.mozilla.org/en-GB/firefox/addon/styl-us/>
|
2023-02-05 02:21:30 +00:00
|
|
|
|
2024-07-20 21:25:54 +00:00
|
|
|
// NOTE: This file is moved to /opt/rosenrot, so editing it here doesn't have direct effects on the runtime!!
|
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
// Main part of the code: switch on the domain and select the corresponding style
|
2023-02-15 02:24:47 +00:00
|
|
|
var styles = null;
|
2024-07-20 21:25:54 +00:00
|
|
|
// console.log(document.domain);
|
2024-03-21 11:47:57 +00:00
|
|
|
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;
|
2024-03-24 11:44:44 +00:00
|
|
|
case "search.brave.com":
|
|
|
|
styles = `
|
|
|
|
.download-button,
|
|
|
|
a[href^="https://brave.com/download/"] {
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
break;
|
2024-03-21 11:47:57 +00:00
|
|
|
case "search.nunosempere.com":
|
|
|
|
styles = `
|
|
|
|
/*
|
|
|
|
body {
|
|
|
|
zoom: 1.8;
|
|
|
|
}
|
|
|
|
*/
|
2023-02-15 02:24:47 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
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,
|
2024-03-24 11:07:29 +00:00
|
|
|
.promotedlink,
|
|
|
|
.promoted
|
2024-03-21 11:47:57 +00:00
|
|
|
{
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
break;
|
|
|
|
case "twitter.com":
|
2024-07-20 21:25:54 +00:00
|
|
|
case "x.com":
|
2024-03-21 11:47:57 +00:00
|
|
|
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;
|
|
|
|
}
|
2024-03-21 11:29:13 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
/* hide what's happening section */
|
|
|
|
:has(meta[property="og:site_name"][content="Twitter"])
|
|
|
|
[aria-label="Timeline: Trending now"] {
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
[data-testid^="sidebarColumn"] {
|
2024-07-20 21:25:54 +00:00
|
|
|
display: none !important;
|
2024-03-21 11:47:57 +00:00
|
|
|
}
|
2024-03-21 11:29:13 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
/* Hide DMs v2 */
|
|
|
|
[data-testid^="DMDrawerHeader"] {
|
|
|
|
display: none;
|
|
|
|
}
|
2024-03-21 11:29:13 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
2024-03-21 11:29:13 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
2023-02-05 02:21:30 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
/* hide video */
|
|
|
|
[data-testid^="videoPlayer"] {
|
|
|
|
display: none !important;
|
|
|
|
}
|
2023-06-26 10:26:53 +00:00
|
|
|
|
2024-03-29 18:13:13 +00:00
|
|
|
/*
|
|
|
|
No change of colors in hover: seemed like a good idea
|
|
|
|
but it fucks up going back and forth
|
2024-03-21 11:47:57 +00:00
|
|
|
*:hover {
|
2024-03-29 18:13:13 +00:00
|
|
|
background-color: white !important;
|
|
|
|
background-color: inherit !important;
|
2024-03-21 11:47:57 +00:00
|
|
|
transition: none !important;
|
2024-03-29 18:13:13 +00:00
|
|
|
}
|
|
|
|
*/
|
2024-03-21 11:47:57 +00:00
|
|
|
/* Hide go to top button */
|
|
|
|
[aria-label^="New posts are available. Push the period key to go to the them."]{
|
|
|
|
display: none;
|
|
|
|
}
|
2024-03-21 11:40:09 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
/* No transparency at the top */
|
|
|
|
[aria-live^="polite"]{
|
|
|
|
background: white !important;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
break;
|
|
|
|
default:
|
2024-07-20 21:25:54 +00:00
|
|
|
console.log(`Domain: ${document.domain}`)
|
2024-03-21 11:47:57 +00:00
|
|
|
console.log("No custom style");
|
2024-03-21 11:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (styles != null) {
|
|
|
|
var styleSheet = document.createElement("style");
|
|
|
|
styleSheet.innerText = styles;
|
|
|
|
document.head.appendChild(styleSheet);
|
|
|
|
console.log("Style changed");
|
|
|
|
}
|
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
// Extra: Replace default alert with new function
|
2024-03-21 11:40:09 +00:00
|
|
|
// 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);
|
|
|
|
};
|
2023-12-29 17:37:50 +00:00
|
|
|
}
|
2023-11-28 16:30:56 +00:00
|
|
|
|
2024-03-21 11:40:09 +00:00
|
|
|
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");
|
|
|
|
};
|
2023-11-08 23:18:10 +00:00
|
|
|
|
2024-03-21 11:47:57 +00:00
|
|
|
// Extra: hide video players on twitter
|
2024-06-12 11:40:59 +00:00
|
|
|
if (document.domain == "twitter.com" || document.domain == "x.com") {
|
2023-11-08 23:18:55 +00:00
|
|
|
// Function to hide the grandparent of video players
|
2024-03-21 11:40:09 +00:00
|
|
|
// takes 0.014ms to run, so performance is not the concern here.
|
|
|
|
// timed with console.time, console.timeEnd
|
|
|
|
|
2023-11-08 23:18:55 +00:00
|
|
|
function hideVideoPlayerGrandparent() {
|
|
|
|
document
|
|
|
|
.querySelectorAll('[data-testid="videoPlayer"]')
|
|
|
|
.forEach(function (videoPlayer) {
|
2024-03-21 11:29:13 +00:00
|
|
|
var grandparentElement =
|
|
|
|
videoPlayer.parentElement.parentElement.parentElement.parentElement
|
|
|
|
.parentElement.parentElement;
|
|
|
|
var newTextElement = document.createElement("div");
|
|
|
|
newTextElement.textContent = " [ twitter video ] ";
|
2023-11-20 10:54:40 +00:00
|
|
|
newTextElement.style["margin-top"] = "10px";
|
|
|
|
newTextElement.style["margin-left"] = "10px";
|
|
|
|
newTextElement.style["margin-bottom"] = "10px";
|
2023-11-09 10:13:11 +00:00
|
|
|
grandparentElement.replaceWith(newTextElement);
|
2023-11-08 23:18:55 +00:00
|
|
|
});
|
|
|
|
}
|
2023-11-08 23:18:10 +00:00
|
|
|
|
2023-11-08 23:18:55 +00:00
|
|
|
// 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
|
|
|
|
}
|
2023-11-08 23:18:10 +00:00
|
|
|
});
|
|
|
|
});
|
2023-11-08 23:18:55 +00:00
|
|
|
|
|
|
|
// 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();
|
2023-05-06 00:08:53 +00:00
|
|
|
}
|
|
|
|
|
2024-03-24 11:07:29 +00:00
|
|
|
// document.body.style.visibility = "visible";
|