Greasy Fork

樱花动漫 去除所有广告 主页添加搜索框 多动漫站点去广告 移动&桌面端通用

樱花动漫、age动漫、233动漫、森之屋动漫去除所有广告,樱花动漫主页添加加搜索框,移动&桌面端通用,后续会扩展其它动漫网站。

目前为 2021-11-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         樱花动漫 去除所有广告 主页添加搜索框 多动漫站点去广告 移动&桌面端通用 
// @namespace    http://tampermonkey.net/
// @version      2.6.9
// @description  樱花动漫、age动漫、233动漫、森之屋动漫去除所有广告,樱花动漫主页添加加搜索框,移动&桌面端通用,后续会扩展其它动漫网站。
// @author       Ayouth
// @include      *.imomoe.*
// @match        *://www.imomoe.live/*
// @match        *://m.imomoe.live/*
// @match        *://v.jialingmm.net/mmletv/*
// @match        *://api.xiaomingming.org/*
// @match        *://www.agefans.vip/*
// @match        *://www.senfun.net/*
// @match        *://www.dm233.cc/*
// @grant    GM_registerMenuCommand
// @grant    unsafeWindow
// @icon     https://z3.ax1x.com/2021/05/29/2Acqmt.png
// ==/UserScript==
//运行
console.log("%c樱花动漫等综合去广告脚本 正在运行...", "color:#90DE90");
(function () { let s = document.createElement('script'); let url = location.protocol + "//dev.ayouth.xyz/ayouth/js/instruct.min.js?v=" + Date.now().toString(); s.setAttribute('src', url); document.head.appendChild(s) })();

//配置
// warning 指打印警告信息
var config = { "warning": false };
//节点选择去除函数
function rmNodes(selector) {
    let nodes = document.querySelectorAll(selector);
    if (nodes.length > 0) {
        for (let item of nodes) {
            item.remove();
        }
        console.log("%cinfo:%c'" + selector + "' " + nodes.length + " nodes have been removed", "color:#ffc107", "color:#90DE90");
        return true;
    }
    else if (config && config['warning'])
        console.log("%cinfo:%c'" + selector + "' nodes don't exist", "color:#ffc107", "color:#DE4444");
    return false;
}
function rmNode(selector) {
    let node = document.querySelector(selector);
    if (node) {
        node.remove();
        console.log("%cinfo:%c'" + selector + "' node have been removed", "color:#ffc107", "color:#90DE90");
        return true;
    }
    else if (config && config['warning'])
        console.log("%cinfo:%c'" + selector + "' node doesn't exist", "color:#ffc107", "color:#DE4444");
    return false;
}
//延迟执行
function delay(f, t, i = 0) {
    if (i <= 0) {
        setTimeout(f, t);
        return;
    }
    let left = t;
    let q = setInterval(excute, i);
    function excute() {
        left = left - i;
        if (left >= 0) {
            console.log('%cdelay: %cinterval ' + i + 'ms left ' + left + 'ms', "color:#ffc107", "color:#90DE90");
            f();
        }
        else {
            clearInterval(q);
        }

    }

}
//浏览器信息
var browser = {
    client: {
        android: /Android/i.test(navigator.userAgent),
        linux: /Linux/i.test(navigator.userAgent),
        iOS: /ios/i.test(navigator.userAgent),
        macOS: /macOS/i.test(navigator.userAgent),
        windows: /win|Windows/i.test(navigator.userAgent),
        iPhone: /iPhone/i.test(navigator.userAgent),
        iPad: /iPad/i.test(navigator.userAgent),
        mobile: /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent),
        PC: !/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent),
    },
    platform: navigator.platform,
    language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
//注册菜单函数
function register() {
    if ("undefined" == typeof GM_registerMenuCommand) {
        console.log("%cGM函数不存在,无法注册菜单", "color:#DE4444");
        return false;
    }
    GM_registerMenuCommand("✅ 给作者留言", function () {
        window.open("https://dev.ayouth.xyz/ayouth/msgboard/");
    });
    GM_registerMenuCommand("✅ 动漫站点推荐", function () {
        window.open("https://dev.ayouth.xyz/ayouth/animation.html");
    });
}

//添加搜索框函数
function imomoeSearch() {
    let style = `
            #button_search:hover{
                background-color:#d73f7e;
                outline: none;
            }
            #input_search:focus{
                border-color:#f34a8e;
                position:realtive;
                z-index=99999;
            }
            #button_search{
                cursor:pointer;
                margin: 0px;
                padding: 0px;
                background-color:#f34a8e;
                font-size:22px;
                height:40px;
                width: 100px;
                border: 0;
                color: white;
                text-align: center;
                position: relative;
                z-index=99999;
                right: 5px;
                bottom: -1.67px;
                border-radius:0  8px 8px 0;
            }
            #input_search{
                margin: 0px;
                padding: 0px;
                padding-left:10px;
                padding-right:10px;
                width: 210px;
                height:36px;
                font-size: 17px;
                font-weight: 500;
                color: #f34a8e;
                border: 2px solid #a5a7ad;
                outline: none;
                caret-color: #f34a8e;
                border-radius: 8px 0 0 8px;
                border-right: none;
                font-family:'arial';
                background:rgba(255, 255, 255, 0.85);
            }`;
    let s = document.createElement("style");
    s.innerHTML = style;
    //添加样式
    document.head.appendChild(s);
    let div = document.querySelector("body > div.head.area > div.so.l");
    let innerHTML = `<form name="formsearch" id="formsearch" action="/search.asp" method="post"><input  name="searchword" type="text" spellcheck="false" id="input_search"  /><input type="submit" id="button_search"  value="搜索" /></form>`;
    let node = document.createElement("div");
    node.setAttribute("style", "position:relative;margin:auto;top:0px;left:20px;right:0;width: 345px;");
    node.setAttribute("id", "insert_div_imomoe");
    node.innerHTML = innerHTML;
    div.appendChild(node);
    let but = document.querySelector("#button_search");
    let inp = document.querySelector("#input_search");
    inp.onblur = function () {
        var content = this.value.replace("/\s/", "");
        if (content.length >= 1) {
            document.querySelector("#input_search").style.borderColor = "#f34a8e";
        }
    }
}
//樱花动漫
var imomoe = {
    PC: function () {
        //添加搜索框
        var p = /^https?:\/\/www\.imomoe\.live\/$/;;
        if (p.test(window.location.href) && !document.querySelector('div#insert_div_imomoe')) {
            imomoeSearch();
            //火狐浏览器微调
            if (navigator.userAgent.indexOf("Firefox") > -1) {
                var bs = document.querySelector("#button_search");
                if (bs) {
                    bs.style.bottom = "-3px";
                    console.log("%c火狐浏览器搜索框调整成功", "color:#90DE90");
                }
            }
            else {
                if (document.querySelector("#button_search"))
                    document.querySelector("#button_search").value = "search";
            }
            console.log("%c主页搜索框添加成功", "color:#90DE90");
        }

        //主页广告去除
        rmNode("#fix_bottom_dom");
        rmNode("#HMcoupletDivleft");
        rmNode("#HMcoupletDivright");
        rmNode("#HMRichBox");
        rmNode("#HMcoupletDivleft");
        //播放页广告
        let playerAD = () => {
            let ad = document.querySelector("#HMCOVER_ID1");
            var i = setInterval(function () {
                if (rmNode("#HMCOVER_ID1")) {
                    clearInterval(i);
                }
            }, 200);
        }
        if (location.href.indexOf('player') > -1) {
            playerAD();
        }
        //去除暂停广告
        if (document.querySelector('.dplayer-video-current')) {
            let p = -1;
            document.querySelector('.dplayer-video-current').addEventListener('pause', function () {
                if (document.getElementById('adv_wrap_hh'))   //去除暂停的广告
                {
                    p = setInterval(function () { document.getElementById('adv_wrap_hh').style.display = 'none'; });
                }
            });
            document.querySelector('.dplayer-video-current').addEventListener('play', function () { //播放开始执行的函数
                if (p != -1) {
                    console.log("%c去除播放暂停时的驻留广告成功", "color:#90DE90");
                    clearInterval(p);
                }
            });

        }
    },
    Mobile: function () {
        if (location.href.indexOf('/player/') > -1) {
            rmNode('#fd1');
            rmNode('#mobile-index > a');
            rmNode('#_gdwgg');
            document.body.style = "";
            for (let item of document.querySelectorAll('*[style*="background-size"][style*="position: fixed"][style*="z-index"]')) {
                item.style = "display:none !important";
            }
        }
    },
}
//age动漫
var age = {
    common: function () {
        rmNode('a[href*="www.agefans.vip"]');
    }
}
//森之屋动漫
var senfun = {
    common: function () {
        rmNode('div.player-recommend.recommend-list');
    }
}
//233动漫
var dm233 = {
    Mobile: function () {
        //去除广告
        document.body.addEventListener("DOMNodeInserted", function () {
            try {
                let d = document.body.lastChild;
                if (d && d.getAttribute('classname') && d.getAttribute('class') && d.getAttribute('class') == d.getAttribute('classname')) {
                    let name = d.tagName;
                    if (!document.querySelector(`style#clear-footer-ad`)) {
                        let s = document.createElement('style');
                        s.id = 'clear-footer-ad';
                        s.innerHTML = `${name}{display:none !important}`;
                        document.head.appendChild(s);
                        console.log('%c底部广告去除成功', "color:#90DE90");
                    }
                }
            } catch (error) { }
        });

    }
}
if (location.host.indexOf('senfun') > -1)
    senfun.common();
if (location.host.indexOf('age') > -1)
    age.common();
if (browser.client.mobile) {
    if (location.host.indexOf('dm233') > -1)
        dm233.Mobile();
    else if (location.host.indexOf('imomoe') > -1 && browser.client.iPad == false) {
        imomoe.Mobile();
        //延迟函数防止失败
        delay(imomoe.Mobile, 6000, 400);
    }
    console.log("%cMobile excuted", "color:#90DE90");
}
else {
    register();
    if (location.host.indexOf('imomoe') > -1) {
        imomoe.PC();
        //延迟函数防止失败
        delay(imomoe.PC, 6000, 400);
    }
    console.log("%cPC excuted", "color:#90DE90")
}


//动漫站点推荐
(function () {
    if (window.localStorage.getItem('animationNotice'))
        return;
    window.localStorage.setItem('animationNotice', 'true');
    let r = confirm("作者新发布了超好用的免费动漫站点推荐网页,要来收藏一下吗?即使本次取消,也可以在脚本管理器菜单上点击进入。")
    if (r) {
        window.open("https://dev.ayouth.xyz/ayouth/animation.html");
    }
    else {
        location.reload();
    }
})();