Greasy Fork

樱花动漫 去除所有广告 主页添加搜索框

可以去除所有广告,并在主页增加了的优美的支持Enter键搜索框.

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

// ==UserScript==
// @name         樱花动漫 去除所有广告 主页添加搜索框
// @namespace    http://tampermonkey.net/
// @version      2.6.1
// @description  可以去除所有广告,并在主页增加了的优美的支持Enter键搜索框.
// @author       Ayouth
// @include      *.imomoe.*
// @include      https://v.jialingmm.net/mmletv/*
// @include      https://api.xiaomingming.org/*
// @grant    GM_registerMenuCommand
// @grant    unsafeWindow
// @icon    https://z3.ax1x.com/2021/05/29/2Acqmt.png
// ==/UserScript==

(function () {
    if("undefined" != typeof GM_registerMenuCommand){
        GM_registerMenuCommand("✅ 给作者留言",function(){
            window.open("http://dev.ayouth.xyz/msgboard");
        });
    }
    else{
        console.log("GM函数不存在");
    }
    //隐藏节点功能函数
    let hideNode = (ad) => {
        if (ad) {

            ad.style.display = "none";
        }
    }
    //主域名
    let domain = "imomoe.live";
    //主页广告去除
    let homePageAD = () => {
        let ad = document.querySelector("#fix_bottom_dom");
        hideNode(ad);
        ad = document.querySelector("#HMcoupletDivleft");
        hideNode(ad);
        ad = document.querySelector("#HMcoupletDivright");
        hideNode(ad);
        ad = document.querySelector("#HMRichBox");
        hideNode(ad);
        ad = document.querySelector("#HMcoupletDivleft");
        hideNode(ad);
    }
    homePageAD();//去除主页广告
    setInterval(homePageAD, 100);//防止延迟失败
    //播放页广告
    let playerAD = () => {
        let ad = document.querySelector("#HMCOVER_ID1");
        var i = setInterval(function () {
            let ad = document.querySelector("#HMCOVER_ID1");
            if (ad) {
                ad.remove();
                clearInterval(i);
            }
        }, 200);
    }
    if (window.location.href.indexOf('player') > -1) {
        playerAD();
    }
    var dataUrl = "imomoe.live/player";

    var currentUrl = window.location.href;
    let addStyles = function () {
        let head = document.querySelector("head");
        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 node = document.createElement("style");
        node.setAttribute("type", "text/css");
        node.innerHTML = style;
        head.appendChild(node);
    }
    let addTags = function () {
        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=\"search\" /></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 setSearch = function () {
        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 p = /^https?:\/\/www\.imomoe\.live\/$/;;
    if (p.test(currentUrl)) {
        addStyles();
        addTags();
        setSearch();
    }
    let setDifferentBrower = function () {
        var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
        var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
        var isIE = userAgent.indexOf("compatible") > -1
            && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
        var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
        var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
        var isSafari = userAgent.indexOf("Safari") > -1
            && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
        var isChrome = userAgent.indexOf("Chrome") > -1
            && userAgent.indexOf("Safari") > -1; //判断Chrome浏览器

        if (isIE) {
            var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
            reIE.test(userAgent);
            var fIEVersion = parseFloat(RegExp["$1"]);
            if (fIEVersion == 7) {
                return "IE7";
            } else if (fIEVersion == 8) {
                return "IE8";
            } else if (fIEVersion == 9) {
                return "IE9";
            } else if (fIEVersion == 10) {
                return "IE10";
            } else if (fIEVersion == 11) {
                return "IE11";
            } else {
                return "0";
            }//IE版本过低
            return "IE";
        }
        if (isOpera) {
            return "Opera";
        }
        if (isEdge) {
            return "Edge";
        }
        if (isFF) {
            var bs = document.querySelector("#button_search");
            if (bs) {
                bs.style.bottom = "-3px";
            }
            return "FireFox";
        }
        if (isSafari) {
            return "Safari";
        }
        if (isChrome) {
            return "Chrome";
        }
    }
    console.log("Browser:" + setDifferentBrower());

    if (document.querySelector('.dplayer-video-current')) {
        var t_PlayAD = -1;
        document.querySelector('.dplayer-video-current').addEventListener('pause', function () {
            if (document.getElementById('adv_wrap_hh'))   //去除暂停的广告
            {
                t_PlayAD = setInterval(function () { document.getElementById('adv_wrap_hh').style.display = 'none'; });
            }
        });
        document.querySelector('.dplayer-video-current').addEventListener('play', function () { //播放开始执行的函数
            if (t_PlayAD != -1) {
                console.log("清除成功");
                clearInterval(t_PlayAD);

            }
        });

    }
})();