// ==UserScript==
// @name Customize Zeit Online
// @namespace https://greasyfork.org/en/users/689160-georg-vogt
// @version 2.3.1
// @description Entferne unerwünschte Artikel/Abschnitte aus Zeit Online
// @author Georg Vogt
// @match https://www.zeit.de/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
'use strict';
var customBadSections = {};
var customBadHeadings = {};
var customBadQueries = {};
customBadSections = GM_getValue("customBadSections", {});
customBadHeadings = GM_getValue("customBadHeadings", {});
customBadQueries = GM_getValue("customBadQueries", {});
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Customize
// customBadSections["newsticker"] = true;
// customBadHeadings["Video"] = true;
// customBadQueries["*[href='https://www.zeit.de/kaenguru-comics-marc-uwe-kling-bernd-kissel ']"] = 2;
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
GM_setValue("customBadSections", customBadSections);
GM_setValue("customBadHeadings", customBadHeadings);
GM_setValue("customBadHeadings", customBadQueries);
console.log("TM: Custom settings:", customBadSections, customBadHeadings, customBadQueries);
function hideNode(node) {
try {
node.style.display = 'none';
// node.style.background = 'red'; // debug
} catch {}
}
function hideParent(node, num) {
for (var i=0; i<num; i++) {
node = node?.parentElement;
}
hideNode(node);
}
// remove sections
const defaultBadSections = {
"wochenmarkt": true,// Wochenmarkt
"headed-zplus": true,// zplus
"headed-zett": true,// zett
"headed-brandeins": false,// brand eins
"headed-zar": false,// Zeit Arbeit
"headed-zmo": false,// Zeit Magazin
"shop": true,// Shop
"headed-zco": false,// Zeit Campus
};
const defaultBadHeadings = {
"DAS BESTE AUS Z+": true,
"DAS BESTE AUS Z+\n:\nUnsere Leseempfehlungen": true,
"Diese Woche in der ZEIT": true,
"Beliebte Artikel": true,
"Politik": false,
"Gesellschaft": false,
"Podcasts": true,
"Wirtschaft": false,
"Kultur": false,
"Video": true,
"Wissen": false,
"Digital": false,
"Entdecken": false,
"Mobilität": false,
"Hamburg": false,
"Sport": false,
"Spiele": true,
};
const badSections = {...defaultBadSections, ...customBadSections};
const badHeadings = {...defaultBadHeadings, ...customBadHeadings};
const sections = document.querySelectorAll("section");
for (const section of sections) {
if (badSections[section.getAttribute("data-ct-context")]??false) {
hideNode(section.parentElement);
} else if (badHeadings[section.querySelector("h2")?.innerText]??false) {
hideNode(section.parentElement);
}
}
// remove other articles
const articles = document.querySelectorAll("main article");
const zplusKeywords = [
"zplus",// pay to read
"zplus-register",// register to read
// "zplus-dynamic",// unknown zplus article type, can still be accessed
];
for (const article of articles) {
// remove zplus article
if (zplusKeywords.includes(article.getAttribute("data-zplus"))) {
hideNode(article);
}
// remove zett article
if (article.getAttribute("data-unique-id")?.includes("zett")) {
hideNode(article);
}
// remove Verlagsangebot
if (article.querySelector("h3")?.innerText.includes("VERLAGSANGEBOT")) {
hideNode(article);
}
}
const defaultBadQueries = {
"aside.joblisting": 2,// Stellenangebot
"*[class='frame frame--quiz']": 2,// Quiz
"*[class='zg-wiegehtsesihnen-appwrapper']": 1,// Stimmungsumfrage
"*[href='https://www.zeit.de/kaenguru-comics-marc-uwe-kling-bernd-kissel']": 2,// Känguru comic
};
const badQueries = {...defaultBadQueries, ...customBadQueries};
for (const [query, num] of Object.entries(badQueries)) {
if (num >= 0) {
hideParent(document.querySelector(query), num);
}
}
// remove sidebar Zeit+
const sideBox = document.querySelector("aside.topicbox");
if (sideBox?.childNodes[1]?.childNodes[1]?.innerText == "DAS BESTE AUS Z+") {
hideNode(sideBox);
}
// remove paywall footer
const callback = function(mutationsList, observer) {
for(const mutation of mutationsList) {
for (const node of mutation.addedNodes) {
try {
if (node.getAttribute("class") == "paywall-footer paywall-footer--expandable ") {
hideNode(node);
}
} catch {}
}
}
};
const observer = new MutationObserver(callback);
observer.observe(document.body, {childList: true});