內容農場阻擋器

阻擋農場搜尋引擎顯示農場網站

目前為 2023-09-05 提交的版本,檢視 最新版本

// ==UserScript==
// @name         內容農場阻擋器
// @namespace    
// @version      0.1
// @description  阻擋農場搜尋引擎顯示農場網站
// @author       Danny H.
// @match        *://www.google.com/search*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
// @grant        GM_xmlhttpRequest
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let blockList = [];
    let lastScrollHeight = 0;

    function fetchBlockList() {
        GM_xmlhttpRequest({
            method: 'GET',
            url: 'https://gist.githubusercontent.com/HCYT/0f2a0083eff6f084d0f14caca7af3bbc/raw/d24fd17153d60b86e4c8bcb2e5b877c7a9762495/gistfile1.txt',
            onload: function(response) {
                blockList = response.responseText.split('\n').filter(Boolean);
                filterResults();
            }
        });
    }

    function filterResults() {
        let results = document.querySelectorAll('.g');
        results.forEach(result => {
            let link = result.querySelector('a');
            if (link) {
                let href = link.href;
                if (blockList.some(blocked => href.includes(blocked))) {
                    result.remove();
                }
            }
        });
    }

    function infiniteScroll() {
        let scrollHeight = document.documentElement.scrollHeight;
        if (window.scrollY + window.innerHeight >= scrollHeight - 500 && lastScrollHeight !== scrollHeight) {
            lastScrollHeight = scrollHeight;
            window.scrollTo(0, scrollHeight);
        }
    }

    // 初始化
    fetchBlockList();
    window.addEventListener('scroll', () => {
        infiniteScroll();
        filterResults();
    });

})();

QingJ © 2025

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