Hoi zäme! Ich ha d’Nerve verlore und en Chrome-Erwyterig gmacht, wo Artikel uf 20min.ch usblendet, wo gwüssi Wörter drin händ – z. B. „Sex“, „TikTok“ oder „Social Media“. Wenn ihr au ä Pause vo unnötigem Content uf de Startsiite bruched teili das drum mit eu. So funktioniert’s : Die Erwyterig suecht automatisch Artikel uf dr Site, wo di definierte Wört enthalted, und blendet sie uus. Das gilt au für Inhalt, wo später dynämisch nochglade wird. So installierisch’s
- Mach en neuen Ordner uf dinem Computer, zb. „Remove Trash from 20Min“.
- Erstell d folgende Datei : manifest.json (Eifach de Code imne Texteditor isetze und under dem name speichere) { “manifest_version”: 3, “name”: “Remove Trash from 20Min”, “version”: “1.0”, “description”: “Removes articles containing the words ‘sex’, ‘tiktok’, or ‘social media’ from the front page of 20min.ch”, “permissions”: [“activeTab”, “scripting”], “host_permissions”: [“https://www.20min.ch/"], “background”: { “service_worker”: “background.js” }, “content_scripts”: [ { “matches”: ["https://www.20min.ch/”], “js”: [“content.js”] } ] } Erstell di zweite Datei : background.js chrome.runtime.onInstalled.addListener(() => { console.log(“Extension installed and ready to filter articles on 20min.ch.”); }); Und d dritte Datei: content.js // Function to filter and remove articles containing specific keywords or compound words function removeArticles() { const blockedWords = [“sex”, “tiktok”, “social media”]; // Select all article elements const articles = document.querySelectorAll(“article”); articles.forEach((article) => { // Get the inner text of the article and its child elements const text = article.innerText.toLowerCase(); // Check if any of the blocked words are found in the text (including compound words) if (blockedWords.some((word) => text.includes(word))) { article.style.display = “none”; // Hide the article } }); } // Set up a MutationObserver to detect changes in the DOM const observer = new MutationObserver(() => { removeArticles(); }); // Start observing the body of the document for child changes observer.observe(document.body, { childList: true, subtree: true }); // Run the function once on initial page load document.addEventListener(“DOMContentLoaded”, removeArticles); Öffne chrome://extensions im Browser ., Mach de „Developer mode“ obe rächts a. K lick uf „Load unpacked“. Wähl din entpackte Ordner uus. Fertig , Gang uf 20min.ch , und d Erwyterig blendet Artikel mit de ufgfüehrte Wört us. Eigeni Wörter definiere (Z.B. Hänni) Wenn du ander Wört blockiere wosch, chasch die Datei content.js ändere: • Öffne d Datei mit eme Texteditor. • Suech const blockedWords = [“sex”, “tiktok”, “social media”];. • Ergänz d Lischt mit dine Wört. • Speicher d Datei und lad d Erwyterig no einisch i Chrome. submitted by /u/Natural_Event9189
Originally posted by u/Natural_Event9189 on r/20hirnzelle
You must log in or # to comment.
