邦德提取网页广告链接

提取网页(如色情)广告链接

当前为 2021-10-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         邦德提取网页广告链接
// @namespace    http://tampermonkey.net/
// @version      0.8
// @description  提取网页(如色情)广告链接
// @author       木木
// @match        htt*://*/*
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    console.log(0.8);

     window.onload=function(){
       show_adhref();
     }

    function show_adhref() {
         console.log(111, $("img:not([title])").parents("a"));
        //当前域名
        var alist = $("img:not([title])").parents("a:not([title])");
        console.log(333, alist);
        var ahref = [];
        var ahref_all = [];
        var r1 = /.*?(gif|png|jpg)/gi;
        var r2 = new RegExp("javascript|mailto:|#|mqq:|sinaweibo:|alipays:|weixin:|sms:|baidu.com|" + location.host ,"gi");
        for (var index in alist) {
            if (alist[index].href && !alist[index].href.match(r1) && !alist[index].href.match(r2)) {
                ahref.push(alist[index].href);
            }
            if (alist[index].href) {
                ahref_all.push(alist[index].href);
            }

        }

        ahref = unique(ahref);
        ahref_all = unique(ahref_all);
        console.log(222,ahref);
        console.log(555,ahref_all);
        var ahref_content = ahref.join("\r\n");
        var ahref_all_content = ahref_all.join("\r\n");
        var ahref_all_a_str = '';
        for (var index2 in ahref_all) {
            var current_ahref = ahref_all[index2];
            ahref_all_a_str += `<p><a target="_blank" href="${current_ahref}">${current_ahref}</a></p>`;

        }
        if (ahref_content !== '') {
            $("body").append(`<textarea id="textarea_getad" style="position:fixed;top:5px;right:20px;z-index:10000000;width: 400px;height:300px;">${ahref_content}</textarea>
                <div id="" style="color:#000;overflow: scroll;text-align: left;cursor:pointer;background:#fff;position:fixed;top:400px;right:20px;z-index:10000000;width: 400px;height:300px;">过滤之前:\r\n${ahref_all_a_str}</div>
                <button style="cursor:pointer;position:fixed;top:700px;right:300px;z-index:10000000;" onclick="window.multi_open_youhou()" class="btn">批量打开网址</button>
                `);
        }
    }


    function unique(arr) {
        if (!Array.isArray(arr)) {
            console.log('type error!')
            return
        }
        var array = [];
        for (var i = 0; i < arr.length; i++) {
            if (array .indexOf(arr[i]) === -1) {
                array .push(arr[i])
            }
        }
        return array;
    }
    unsafeWindow.multi_open_youhou = function multi_open_youhou() {
        var alist = $("img:not([title])").parents("a:not([title])");
        console.log(666, alist);
        for (var index in alist) {
            if (alist[index].href) {
                window.open(alist[index].href);
            }
        }
    }
})();