Young People in Yaohuo

青少年模式

当前为 2022-11-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         Young People in Yaohuo
// @description  青少年模式
// @version      0.2
// @author       Polygon
// @match        https://yaohuo.me/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_addStyle
// @run-at       document-end
// @namespace https://gf.qytechs.cn/users/788115
// ==/UserScript==

(function() {
    'use strict';
    // 添加一个style,PC端字体有点看不清
    GM_addStyle(`
        body, html {
            font-family: Arial, SimHei !important;
        }
    `)
    const keywords = [
        "小姐姐", 
        "拼夕夕", 
        "老车手",
        "老司机", 
        "PDD", 
        "学习通",
    ]
    let validate = (text) => {
        return keywords.filter((keyword) => {
            return text.match(new RegExp(keyword, "gi"))
        }).length
    }
    let currentURL = window.location.href
    // 判断当前网址是否为主页
    if (currentURL == 'https://yaohuo.me/') {
        console.log("主页")
        // 主页移除关键词
        let items = []
        document.querySelectorAll('.list a').forEach((e) => {
            // 每个节点有两个关键信息:1.href;2.innerText
            let href = e.href
            let text = e.innerText
            if (validate(text)) {
                console.log(`remove ${text}`)
            } else {
                items.push(`${items.length+1}.<a href="${href}">${text}</a>`)
            }
        })
        document.querySelector('.list').innerHTML = items.join("<br>")
    } else if (currentURL.startsWith('https://yaohuo.me/bbs/book_list.aspx?')) {
        // 可能是新帖,也可能是搜索页
        if (currentURL.includes('key=')) {
            console.log("搜索页")
            // 把body下的条目统一放到KL_show_next_list下,便于统一操作
            let searchText = currentURL.match(/\?key=(.+?)&/)[1]
            if (validate(searchText)) {
                setTimeout(() => {
                    alert("你可以遗忘屏蔽词,本脚本将永远不会!\nYou can forget about blocking words, this script will never!")
                }, 233);
            }
        } else {
            console.log("新帖页")
        }
        document.querySelector("#KL_show_next_list").style.display = ""
        document.querySelectorAll(".listdata").forEach((e) => {
            document.querySelector("#KL_show_next_list").appendChild(e.cloneNode(true))
            e.remove()
        })
        let filterList = (mutations, observer) => {
            let items = []
            document.querySelectorAll("#KL_show_next_list div").forEach((e) => {
                // 每个节点有很多元素
                let text = e.innerText
                if (validate(text)) {
                    console.log(`remove ${text}`)
                    e.remove()
                }
            })
        }
        filterList(null, null)
        var observer = new MutationObserver(filterList)
        var node = document.querySelector('#KL_show_tip')
        observer.observe(node, {childList: true})
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址