generalize thread hider & improve URL matching

This commit is contained in:
17ms 2022-11-15 14:12:30 +02:00
parent feb3fb7bb4
commit 7c1f2d9d75
2 changed files with 6 additions and 7 deletions

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @name Expand all images - 4chan.org // @name Expand all images - 4chan.org
// @namespace Violentmonkey Scripts // @namespace Violentmonkey Scripts
// @match *://boards.4channel.org/* // @match *://boards.4channel.org/*/thread/*
// @match *://boards.4chan.org/* // @match *://boards.4chan.org/*/thread/*
// @version 1.0 // @version 1.0
// ==/UserScript== // ==/UserScript==

View File

@ -1,5 +1,5 @@
// ==UserScript== // ==UserScript==
// @name Hide topics from catalog - 4chan.org // @name Hide threads with certain keywords from catalog - 4chan.org
// @namespace Violentmonkey Scripts // @namespace Violentmonkey Scripts
// @match *://boards.4channel.org/*/catalog // @match *://boards.4channel.org/*/catalog
// @match *://boards.4chan.org/*/catalog // @match *://boards.4chan.org/*/catalog
@ -8,14 +8,13 @@
window.addEventListener("load", function () { window.addEventListener("load", function () {
const topics = [] // e.g. ["sdg", "dmp"] const keywords = [] // e.g. ["/sdg/", "luke smith"]
const data = document.getElementsByClassName("teaser") const data = document.getElementsByClassName("teaser")
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
let inner_txt = data[i].innerText let inner_txt = data[i].innerText
for (let j = 0; j < topics.length; ++j) { for (let j = 0; j < keywords.length; ++j) {
let topic_str = "/" + topics[j] + "/" if (inner_txt.includes(keywords[j])) {
if (inner_txt.includes(topic_str)) {
data[i].offsetParent.style.display = "none" data[i].offsetParent.style.display = "none"
} }
} }