【手机】去除百度跳转及去推广,标识csdn下载

由于手机搜索东西搜到cdsn下载的网站,特意标识一下防止误进恶心人,自动加载搜索结果的下一页(默认关闭)

目前為 2021-12-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         【手机】去除百度跳转及去推广,标识csdn下载
// @namespace    http://tampermonkey.net/
// @version      0.3.8.1
// @description  由于手机搜索东西搜到cdsn下载的网站,特意标识一下防止误进恶心人,自动加载搜索结果的下一页(默认关闭)
// @author       MT-戒酒的李白染
// @include    *://m.baidu.com/*
// @include    *://www.baidu.com/*
// @include    *://baijiahao.baidu.com/*
// @include    *://tieba.baidu.com/*
// @include    *://wk.baidu.com/*
// @include    *://jingyan.baidu.com/*
// @include    *://baike.baidu.com/*
// @include    *://zhidao.baidu.com/*
// @connect    www.baidu.com
// @connect    m.baidu.com
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @grant        GM_listValues
// @grant        GM_xmlhttpRequest
// @require	     http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';
    var Flag_Title_css = `
    .component-box .praise {
        padding-right: 20px;
        background: #ff5722;
        text-indent: 1em;
        border-top-left-radius: 50px;
        border-top-right-radius: 50px;
        border-bottom-left-radius: 50px;
        border-bottom-right-radius: 50px;
        background: -webkit-linear-gradient(left,#ff5722,#f78d6b);
        background: -o-linear-gradient(right,#ff5722,#f78d6b);
        background: -moz-linear-gradient(right,#ff5722,#f78d6b);
        background: linear-gradient(to right,#ff5722,#f78d6b);
    }
    .component-box .praise,.component-box .share {
        /*width: 110px;
        height: 34px;
        line-height: 34px;*/
        height:auto;line-height:normal;color: #fff;
    }
    .component-box a {
        display: inline-block;
        font-size: 14px;
    }
    .component-box {
        /*margin: 0 auto;
        text-align: center;
        display: inline;*/
        display: flex;
        margin: 0;
        text-align: left;
        font-size: 0;
        position: relative;
        width: 260px;
    }
`
    const isloading_css = `
    #whitesev-isloading-outside,
    #whitesev-isloading-within{
        position: absolute;
        margin-left: 140px;
    }
    #whitesev-isloading-outside {
        background-color: rgba(0, 0, 0, 0);
        border: 5px solid rgba(0, 183, 229, 0.9);
        opacity: .9;
        border-right: 5px solid rgba(0, 0, 0, 0);
        border-left: 5px solid rgba(0, 0, 0, 0);
        border-radius: 50px;
        box-shadow: 0 0 35px #2187e7;
        width: 20px;
        height: 20px;
        margin: 0 auto;
        /*position: fixed;
        left: 50%;
        top: 50%;
        margin-left: -25px;
        margin-top: -25px;*/
        -moz-animation: spinPulse 1s infinite ease-in-out;
        -webkit-animation: spinPulse 1s infinite ease-in-out;
        -o-animation: spinPulse 1s infinite ease-in-out;
        -ms-animation: spinPulse 1s infinite ease-in-out
    }
    #whitesev-isloading-within {
        background: rgba(0, 0, 0, 0) no-repeat center center;
        border: 5px solid rgba(0, 183, 229, 0.9);
        opacity: .9;
        border-top: 5px solid rgba(0, 0, 0, 0);
        border-bottom: 5px solid rgba(0, 0, 0, 0);
        border-radius: 50px;
        box-shadow: 0 0 15px #2187e7;
        width: 20px;
        height: 20px;
        margin: 0 auto;
        /*position: fixed;
        left: 50%;
        top: 50%;
        margin-left: -15px;
        margin-top: -15px;*/
        -moz-animation: spinoffPulse 3s infinite linear;
        -webkit-animation: spinoffPulse 3s infinite linear;
        -o-animation: spinoffPulse 3s infinite linear;
        -ms-animation: spinoffPulse 3s infinite linear
    }
    @-moz-keyframes spinPulse {
        0% {
            -moz-transform: rotate(160deg);
            opacity: 0;
            box-shadow: 0 0 1px #505050
        }
        50% {
            -moz-transform: rotate(145deg);
            opacity: 1
        }
        100% {
            -moz-transform: rotate(-320deg);
            opacity: 0
        }
    }
    @-moz-keyframes spinoffPulse {
        0% {
            -moz-transform: rotate(0deg)
        }
        100% {
            -moz-transform: rotate(360deg)
        }
    }
    @-webkit-keyframes spinPulse {
        0% {
            -webkit-transform: rotate(160deg);
            opacity: 0;
            box-shadow: 0 0 1px #505050
        }
        50% {
            -webkit-transform: rotate(145deg);
            opacity: 1
        }
        100% {
            -webkit-transform: rotate(-320deg);
            opacity: 0
        }
    }
    @-webkit-keyframes spinoffPulse {
        0% {
            -webkit-transform: rotate(0deg)
        }
        100% {
            -webkit-transform: rotate(360deg)
        }
    }
    @-o-keyframes spinPulse {
        0% {
            -o-transform: rotate(160deg);
            opacity: 0;
            box-shadow: 0 0 1px #505050
        }
        50% {
            -o-transform: rotate(145deg);
            opacity: 1
        }
        100% {
            -o-transform: rotate(-320deg);
            opacity: 0
        }
    }
    @-o-keyframes spinoffPulse {
        0% {
            -o-transform: rotate(0deg)
        }
        100% {
            -o-transform: rotate(360deg)
        }
    }
    @-ms-keyframes spinPulse {
        0% {
            -ms-transform: rotate(160deg);
            opacity: 0;
            box-shadow: 0 0 1px #505050
        }
        50% {
            -ms-transform: rotate(145deg);
            opacity: 1
        }
        100% {
            -ms-transform: rotate(-320deg);
            opacity: 0
        }
    }
    @-ms-keyframes spinoffPulse {
        0% {
            -ms-transform: rotate(0deg)
        }
        100% {
            -ms-transform: rotate(360deg)
        }
    }
    `

    function repalceLink_Event() {
        function repalceA_Tag(DOM, new_href) {
            let aTag = Array.from(DOM.getElementsByTagName("a"));
            aTag.forEach((item) => {
                item.href = new_href;
            })
            removeControl();
        }

        function addWebsiteFlag(DOM) {
            let WebsiteTitle = Array.from(DOM.getElementsByClassName("c-title-text"));
            if (WebsiteTitle.length) {
                console.log(WebsiteTitle[0]);
                let Title_Div = document.createElement("div");
                Title_Div.className = 'component-box';
                Title_Div.innerHTML = `<a class="praise" href="javascript:;">CSDN下载</a>`;
                WebsiteTitle[0].append(Title_Div);
            }

        }

        function removeControl() {
            // 移除元素
            if ($(".icon-logo").length) {
                $(".icon-logo")[0].remove(); //底部下一页前面图标删除
            }

            $("#page-relative").remove(); //末尾 ===>>  大家都在搜  广告位
            $(".c-recomm-wrap.new-ux-recom-wrapper.c-bg-color-white.animation").remove(); //中间 ===>>  大家都在搜  广告位
            $("#pop-up").remove(); //跳转百度app提示
            $(".ec_wise_ad").parent().remove(); // 顶部的部分商品广告
            let searchWebSitePages = $(".c-result.result");
            searchWebSitePages = Array.from(searchWebSitePages);
            searchWebSitePages.forEach((items, index) => {
                let searchArticleOriginal_link = JSON.parse(items.dataset.log)['mu'];
                if (searchArticleOriginal_link.match(/recommend_list.baidu.com/g)) {
                    console.log('%c%s', 'color:blue;', "删除广告==>大家都在搜");
                    items.remove();
                }
                if (items.outerText.substr(0, 5) == "大家还在搜") {
                    console.log('%c%s', 'color:blue;', "删除广告==>大家都在搜:显示出来的");
                    items.remove();
                }
                if (items.childNodes.length > 1) {
                    if (items.outerText.match(/(大家还在搜|百度APP内打开)/)) {
                        console.log('%c%s', 'color:blue;', "删除广告==>大家都在搜:隐藏的(点击后,跳出来的)");
                        items.childNodes[1].remove();
                    }
                }
                let bottom_logo_text = items.getElementsByClassName("c-color-source"); //底部标识
                if (bottom_logo_text != null) {
                    let bottom_remove_flag = false;
                    let bottom_logo = Array.from(bottom_logo_text);
                    bottom_logo.forEach((items_b, index_b) => {
                        let it_text = items_b.outerText;
                        if (it_text.match(/百度(APP内打开|手机助手)/)) {
                            bottom_remove_flag = true;
                        }
                    })
                    if (bottom_remove_flag) {
                        console.log('%c%s', 'color:blue;', "删除广告==>百度APP内打开");
                        items.remove();
                    }
                }
                if (items.getElementsByClassName('component-box').length == 0 && searchArticleOriginal_link.match(/http(s|):\/\/(download.csdn.net|www.iteye.com\/resource)/g)) {
                    addWebsiteFlag(items);
                    console.log("插入csdn标题");
                }
                if (items.hasAttribute("srcid") && items.attributes.srcid.value.match(/(sigma|vid_fourfold)/g)) {
                    console.log('%c%s', 'color:blue;', "删除推荐==>xxx 相关 xxx");
                    items.remove();
                }
            })
            let every_result = $("span");
            every_result = Array.from(every_result);
            every_result.forEach((items, index) => {
                let result_parent = items.parentElement.parentElement;
                if (items.outerText.match(/百度APP内打开/) || result_parent.getAttribute("data-from") == "etpl") {
                    console.log("存在隐藏");
                    every_result[index].parentElement.parentElement.remove();
                }
            })
        }

        function replaceLink() {
            let searchWebSitePages = $(".c-result.result");
            searchWebSitePages = Array.from(searchWebSitePages);
            searchWebSitePages.forEach((items, index) => {
                let searchArticleOriginal_link = JSON.parse(items.dataset.log)['mu'];
                if (searchArticleOriginal_link) {
                    let BaiduSearchReplaceAfter = items.getElementsByTagName("article")[0];
                    if (BaiduSearchReplaceAfter && BaiduSearchReplaceAfter.hasAttribute('rl-link-href')) {
                        let BaiduSearchReplaceAfterValue = BaiduSearchReplaceAfter.getAttributeNode("rl-link-href").value;
                        if (!BaiduSearchReplaceAfterValue.match(/http(s|):\/\/m.baidu.com\/from/g)) {
                            console.info('%c%s', 'color:red;', "当前" + runNum + "的 ===>> " + BaiduSearchReplaceAfterValue);
                            if (GM_getValue("menu_showisdirect")) {
                                let getIsRedirectIcon = $(items).find(".white-bdsearch-isredirecrt");
                                if (getIsRedirectIcon.length === 0) {
                                    let title_text_element = $(items).find(".c-title-text");
                                    let is_redirect_icon = document.createElement("div");
                                    is_redirect_icon.className = "white-bdsearch-isredirecrt";
                                    is_redirect_icon.innerHTML = "<span>重</span>";
                                    title_text_element.prepend(is_redirect_icon);
                                }
                            }
                            return
                        }
                        if (BaiduSearchReplaceAfterValue.match(/http:\/\/www.internal.video.baidu.com/g) || searchArticleOriginal_link.match(/http:\/\/www.internal.video.baidu.com/g)) {

                            let internalVideo = decodeURIComponent(BaiduSearchReplaceAfter.getAttribute("rl-link-data-log"));
                            let internalVideoMatch = internalVideo.match(/\/sf\?pd=video_pag(.*?)={/g);
                            if (internalVideoMatch) {
                                internalVideoMatch = internalVideoMatch[0];
                                let newinternalVideo = internalVideoMatch.substring(0, internalVideoMatch.length - 2);
                                console.log('%c%s', 'color:orange;', "修复后的视频:" + newinternalVideo);
                                BaiduSearchReplaceAfter.setAttribute("rl-link-href", newinternalVideo);
                                repalceA_Tag(items, newinternalVideo);
                            }
                        } else if (searchArticleOriginal_link.match(/http:\/\/m.baidu.com\/productcard/g)) {
                            console.info('%c%s', 'color:red;', "该链接不予替换");
                        } else {
                            BaiduSearchReplaceAfter.setAttribute("rl-link-href", searchArticleOriginal_link);
                            repalceA_Tag(items, searchArticleOriginal_link);
                            //console.info('%c%s','color:red;',"修复后的 ===>> "+searchArticleOriginal_link);
                        }
                    }
                }
            })
        }

        function main() {
            removeControl();
            replaceLink();
        }
        main();
    }
    var runNum = 0;

    function replaceLink() {
        Array.from($("script")).forEach((items, index) => {
            if (items.text.match(/define\(\"@molecule\/aftclk\/index\",/g)) {
                console.log('%c%s', 'color:blue;', "删除跳转百度app提示js==>");
                items.remove();
            }
        })
        $(".search-page").bind("DOMNodeInserted", function () {
            console.log("当前执行次数:" + runNum);
            repalceLink_Event();
            runNum = runNum + 1;
        })
    }
    let baidu = {
        current_url: window.location.href,
        init() {
            this.search();
            this.baijiahao();
            this.tieba();
            this.wenku();
            this.jingyan();
            this.baike();
            this.baiketashuo();
            this.zhidao();
        },
        css: {
            search: `
            .c-container.na-ec-item,
            .c-container.ec-container,
            div[data-type="ad"],
            .c-result.sfc-log[data-tpl="adv_wenku_fc"],
            .c-recomm-wrap.new-ux-recom-wrapper.animation,
            #results-pre,
            .video-recommend,
            .c-result.sfc-log[data-tpl="search_recomm"],
            .sfc-image-content-waterfall-item[wat-item-data-id="no-img"],
            .se-results-pre,
            .ec_wise_ad,
            div#copyright + div{
                display:none !important;
            }
            .searchboxtop.newsearch-white-style .se-form {
                border-color: #4e6ef2 !important;
            }
            .searchboxtop.newsearch-white-style .se-bn {
                color: #fff !important;
                background: #4e6ef2 !important;
            }
            .se-head-logo .se-logo img {
                display: inherit !important;
            }
            .se-head-tablink {
                border-bottom: 1px solid #e6e6e6 !important;
                background-color: #fff !important;
            }
            a.se-tabitem span{
                color: #000 !important;
            }
            div.c-peak-layer{
                display:none !important;
            }
            .se-tablink-scroll-wrapper .se-tab-cur:after{
                border-bottom: 2px solid #38f !important;
            }
            .c-tags-scroll.c-padding-x{
                display: none !important;
            }
            .white-bdsearch-isredirecrt{  
                display: inline-flex;
                background: #43ba76;
                color: #fff;
                width: 28px;
                font-size: 16px;
                line-height: 25px;
                justify-content: center;
                align-items: center;
                border-radius: 5px;
                margin: 0 auto;
                margin-right: 6px;
            }
            `,
            baijiahao: `
            .layer-wrap,
            .openImg,
            .oPadding,
            .infinite-scroll-component__outerdiv,
            .bottomTTSStruct,
            .undefined,
            .headDeflectorContainer,
            .followSuper,
            #searchwordSdk ~ div:nth-child(n+4),
            #searchwordSdk,
            div#commentModule div div span:last-child{
              display:none !important;
            }
            body.scrollHide{
              overflow:auto !important;
            }
            .mainContent{
              height:  auto !important;
            }
            `,
            tieba: `
            .tb-backflow-defensive,
            .fixed-nav-bar-defensive,
            .post-cut-guide,
            .ertiao-wrap-defensive,
            .feed-warp.gray-background,
            .pb-page-wrapper.app-view.transition-fade nav:first-child,
            .banner-wrapper-defensive{
              display:none !important;
            }
            body.tb-modal-open{
              overflow:auto !important;
            }`,
            wenku: `
            .reader-pop-manager-view-containter,
            .core-download,
            .card-wrap.card-vip,
            #app{
              display:none !important;
            }
            .reader-wrap{
              height:auto !important;
            }
            #view-app,
            #view-rr-app{
              max-height: 100% !important;
            }
            .top-card{
                margin-top: 10px !important;
            }
            *{
              -webkit-touch-callout: inherit !important;
              -khtml-user-select: auto !important;
              -moz-user-select: auto !important;
              -ms-user-select: auto !important;
              user-select: auto !important;
            }
            `,
            jingyan: `
            .article-feed-next,
            .wgt-rel-exp-feed,
            .article-feed-btn-fixed,
            .read-whole-mask.app{
              display:none !important;
            }
            .exp-content-container{
              max-height: 100% !important;
              overflow:auto !important;
            }
            `,
            baike: `
            .BK-after-content-wrapper,
            .yitiao-container,
            .BK-content-load,
            #J-tashuo-button-fixed,
            #J-super-layer-promote{
              display:none !important;
            }
            #J-other-content{
                display:block !important;
            }
            `,
            zhidao: `
            #feed-recommend,
            .dec,
            .dec + div,
            .wgt-topic-hot,
            #respect-footer,
            #wap-youx-change-asp,
            div.question-line + div,
            .wgt-asp-youx,
            .w-detail-display-btn,
            #knowledge-answer-list{
                display:none !important;
            }
            .w-detail-container{
                max-height: 100% !important;
                overflow: auto !important;
            }
            `,
        },
        search() {
            // 百度搜索
            if (this.current_url.match(/(m|www).baidu.com/g)) {
                GM_addStyle(this.css.search)
                $(function () {
                    main_start();
                })
            }
        },
        baijiahao() {
            // 百家号
            if (this.current_url.indexOf("baijiahao.baidu.com") != -1) {
                GM_addStyle(this.css.baijiahao);
            }
        },
        tieba() {
            //  贴吧
            if (this.current_url.indexOf("tieba.baidu.com") != -1) {
                GM_addStyle(this.css.tieba);
            }
        },
        wenku() {
            // 文库
            if (this.current_url.indexOf("wk.baidu.com") != -1) {
                GM_addStyle(this.css.wenku);
            }
        },
        jingyan() {
            // 经验
            if (this.current_url.indexOf("jingyan.baidu.com") != -1) {
                GM_addStyle(this.css.jingyan);
            }
        },
        baike() {
            // 百科
            if (this.current_url.indexOf("baike.baidu.com") != -1) {
                GM_addStyle(this.css.baike);
                let page_ = 1;
                let page_interval_lock = false;
                let more_url = "https://baike.baidu.com" + window.location.pathname;
                let ele_url;
                try {
                    ele_url = document.getElementById("J-gotoPC-top").href;
                } catch (err) {
                    return;
                }
                let match_id = ele_url.match(/item\/.*\/(\d*)/);
                function set_normal_img_size(){
                    //GM_xmlhttpRequest获取到的图片大小要重新设置
                    let col_para = document.getElementsByClassName("col-para");
                    $.each(col_para, (i, n) => {
                        n.setAttribute("style", "width: 42.936vw;margin: 0 auto;");
                        let content_img_item = n.getElementsByClassName("content-img-item");
                        let content_img_link = n.getElementsByClassName("content-img-link");
                        let content_album = n.getElementsByClassName("content-album");
                        if (content_album.length != 0) {
                            content_album[0].setAttribute("style", "");
                            content_img_item = n.getElementsByClassName("content-album-item");
                            content_img_link = n.getElementsByClassName("content-album-link");
                        }
                        if (content_img_item.length != 0) {
                            content_img_item[0].setAttribute("style", "max-height: 39vw;max-width: 30vw;border-radius: 0.09rem;margin: 0 auto;overflow: hidden;");
                        }
                        if (content_img_link.length != 0) {
                            content_img_link[0].setAttribute("style", "width: 30vw;");
                        }

                    })
                }
                function insert_img(){
                    // GM_xmlhttpRequest获取到的要重新将图片链接插入到img标签中
                    let content_img = document.getElementsByClassName("lazy-img");
                    $.each(content_img, (i, n) => {
                        let content_img = n.parentElement.parentElement.parentElement;
                        let img_url = content_img.getAttribute("data-src") ? content_img.getAttribute("data-src") : n.getAttribute("data-url");
                        if (img_url != null) {
                            n.innerHTML = '<img src="' + img_url + '"></img>';
                        }
                    })
                }
                function loadMore() {
                    // 循环加载更多内容
                    if (match_id.length >= 2) {
                        // 由于不知道有多少页,定时器加载判断
                        var page_interval = setInterval(function () {
                            console.log("定时器loading");
                            if (page_interval_lock == false) {
                                page_interval_lock = true;
                                more_url = more_url + "?wpf=3&ldr=1&page=" + page_ + "&insf=1&_=" + new Date().getTime();
                                console.log(more_url);
                                
                                GM_xmlhttpRequest({
                                    url: more_url,
                                    timeout: 5000,
                                    method: "GET",
                                    async: false,
                                    headers: {
                                        "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Mobile Safari/537.36 Edg/96.0.1054.62"
                                    },
                                    onload: function (resp) {
                                        let $_resp = $(resp.response);
                                        let main_content = $_resp.find(".BK-main-content");
                                        let new_content = main_content.prevObject[0].innerHTML;
                                        if (new_content.trim() == `<a name="u0"></a>`) {
                                            console.log("已到达最大页"+(page_ - 1));
                                            insert_img();
                                            set_normal_img_size();
                                            clearInterval(page_interval);
                                        }else{
                                            $(".BK-main-content").append($(new_content));
                                        };
                                        page_ = page_ + 1;
                                        page_interval_lock = false;
                                    },
                                    onerror: function (resp) {
                                        console.log(resp);
                                        console.log("请求失败");
                                        insert_img();
                                        set_normal_img_size();
                                        clearInterval(page_interval);
                                    }
                                })
                            }

                        }, 1000)

                    } else {
                        console.log("匹配id失败");
                    }

                }
                setTimeout(function () {
                    loadMore(page_);
                }, 3000);
            }
        },
        baiketashuo(){
            if (this.current_url.indexOf("baike.baidu.com/tashuo") != -1) {
                setTimeout(function(){remove_bottom_ad();},2000)
                function remove_bottom_ad(){
                    // 去除底部广告
                    let index_tashuo_list_bottom = document.getElementById("index_tashuo_list").children;
                    for(let i =0;i<index_tashuo_list_bottom.length;i++){
                        let item = index_tashuo_list_bottom[i];
                        let class_name = item.className;
                        if(class_name != "J-hot-item-container"){
                            console.log("TA has ad,remove !");
                            item.remove();
                            i--;
                        }
                    }
                }
            }
        },
        zhidao() {
            // 知道
            if (this.current_url.indexOf("zhidao.baidu.com") != -1) {
                GM_addStyle(this.css.zhidao);
                $(".ec-ad").parent().remove();
            }
        }
    }

    function autoLoadNextPage() {
        var isloding_flag = false;
        let isloading_html = `<div class="page-isloading" style="margin: 0.08rem;background: #999;height: 45px;font-size: 15px;display: flex;text-align: center;align-items: center;width: inherit;justify-content: center;color: #fff;border-radius: 0.12rem;">
        <span class="whitesev-isloading-text" style="">正在加载中...</span>
        <div style="margin:0px 0px 28px 15px;">
            <div id="whitesev-isloading-outside"></div>
            <div id="whitesev-isloading-within"></div>
        </div>
    </div>`;
        $("#page-controller").after($(isloading_html));
        GM_addStyle(isloading_css);
        $(window).bind("scroll", function () {
            // scroll at bottom
            if (Math.ceil($(window).scrollTop() + $(window).height()) >= $(document).height()) {
                // load data
                if (isloding_flag == false) {
                    $(".page-isloading").css("display", "flex");
                    isloding_flag = true;

                    let next_page_url = $(".new-nextpage").attr("href") || $(".new-nextpage-only").attr("href");
                    console.log("正在请求下一页数据", next_page_url);
                    GM_xmlhttpRequest({
                        url: next_page_url,
                        timeout: 5000,
                        method: "GET",
                        onload: function (resp) {
                            $(".page-isloading").css("display", "none");
                            console.log("正在请求的下一页url", next_page_url);
                            let page_html = $(resp.response);
                            let search_result = page_html.find(".c-result.result");
                            let next_html_next_page_html = page_html.find("#page-controller");
                            let this_page_results = $("#results");
                            if (this_page_results != void 0) {
                                $.each(search_result, (i, n) => {
                                    this_page_results.append(n);
                                })
                                $("#page-controller").html(next_html_next_page_html);
                            } else {
                                $(".page-isloading").html("<span>已加载所有的搜索结果</span>");
                                $(window).unbind();
                            }

                            isloding_flag = false;
                        },
                        onerror: function (resp) {
                            console.log(resp);
                            $(".page-isloading").html("<span>加载失败</span>");
                        }
                    })

                } else {
                    console.log("正在加载中请稍后,请勿重复");
                }


            }
        })
    }

    function main_start() {
        replaceLink();
        if (GM_getValue("menu_autoloading")) {
            autoLoadNextPage();
        }

    }
    var GM_menus = [
        ["menu_autoloading", "自动展开下一页", false],
        ["menu_showisdirect", "显示已重定向图标", true]

    ]

    function change_normal_menu() {
        //修改菜单默认值
        // console.log(GM_listValues())
        for (let i = 0; i < GM_menus.length; i++) {
            let get_GM_value = GM_getValue(GM_menus[i][0]);
            if (get_GM_value) {
                GM_menus[i][2] = true;
            } else {
                GM_menus[i][2] = false;
            }
        }
    }

    function register_GM_Menu() {
        //注册油猴菜单
        for (let i = 0; i < GM_menus.length; i++) {
            let current_v = GM_menus[i][0];
            let current_name = GM_menus[i][1];
            let current_status = GM_menus[i][2];
            GM_registerMenuCommand(`[${current_status?"√":"×"}]${current_name}`, function () {
                if (current_status) {
                    GM_deleteValue(current_v);
                } else {
                    GM_setValue(current_v, "1");
                }
                window.location.reload();
            })
        }

    }
    change_normal_menu();
    register_GM_Menu();
    GM_addStyle(Flag_Title_css);
    baidu.init();
})();