QUOTE(chjj30 @ Dec 18 2023, 03:37)

各位,我想在论坛用油猴屏蔽所有包含 href="某指定链接" 的元素,但我不会写脚本也看不懂语言,我去搜只能找到“屏蔽包含指定元素的链接”的写法,但找不到“屏蔽包
含指定链接的元素”的写法,各位能帮我出出主意么?
CODE
// ==UserScript==
// @name Delete forum regex URL
// @namespace http://tampermonkey.net/
// @version 2023-12-18
// @description Delete ehentai forum match regex URL
// @author yuanqiuye
// @match https://forums.e-hentai.org/*
// @require http://code.jquery.com/jquery-1.12.4.min.js
// @grant none
// ==/UserScript==
(function() {
const blockURL = [
"hentaiverse.org",
"blockedword"
];
const regexList = blockURL.map(pattern => new RegExp(pattern));
function removeBlockedElements() {
const elements = document.querySelectorAll('*');
elements.forEach(element => {
for (const regex of regexList) {
if (regex.test(element.href)) {
element.remove();
break;
}
}
});
}
removeBlockedElements();
})();
用chatgpt寫了個簡單的脚本,在blockURL裏面修改你想要屏蔽的regex,[
regex101.com]
You can test it here,沒寫過油猴的UI,所以修改要手動編輯脚本麻煩點
話説現在chatgpt寫這種簡單邏輯的script正確率都不低,頂多自己稍微修改一下就好,時代真的變了QAQ,如果在三年
前跟我說可以像Sirl一樣寫Script,我是不信的哈哈
This post has been edited by yuanqiuye24: Dec 18 2023, 14:22