// ==UserScript== // @name 邦德提取网页广告链接ajax // @namespace http://tampermonkey.net/ // @version 1.6 // @description 提取网页(如色情)广告链接 // @author 木木 // @match htt*://*/* // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js // @downloadURL none // ==/UserScript== (function() { // 'use strict'; // Your code here... var r1 = /.*?(gif|png|jpg|css|js)$/gi; var r2 = new RegExp("javascript|mailto:|#|mqq:|sinaweibo:|alipays:|weixin:|sms:|baidu.com|cnzz.com|qq.com|{|function|bootcdn|\.google|http.*http|tel:[0-9]+|" + location.host ,"gi"); var r3 = new RegExp(location.host ,"gi"); var r4 = new RegExp("https?:\/\/[^\/]+?(\/)?$" ,"g"); var r5 = new RegExp("https?:\/\/[^\"\(;\s]+(?=\"|\')" ,"g"); // var r_word = new RegExp("^[\sa-zA-Z0-9_\u4e00-\u9fa5]+$" ,"g"); var r_word = new RegExp("^[\sa-zA-Z0-9_\u4e00-\u9fa5:;()-_,<>]+$" ,"g"); var r6 = new RegExp("https?:\/\/.+" ,"g"); var is_send = 1; window.onload=function(){ setTimeout(function(){ show_adhref(1,1); }, 5000); } $(document).ready(function(){ show_adhref(0,1); }) function show_adhref(is_onload = 0, is_right = 1) { if (is_right === 1) { var right_field = "right"; } else { var right_field = "left"; } if (is_onload === 1 && $("#textarea_getad")) { //如果onload事件, 且ready事件先显示出来了 则不显示onload了 return false; } console.log(111, $("img:not([title])").parents("a")); //当前域名 var alist = $("img:not([title])").parents("a"); console.log(333, alist); var ahref = []; var ahref_samedomain = []; var alist_script = []; for (var index in alist) { if (alist[index].href && !alist[index].href.match(r1) && !alist[index].href.match(r2) && alist[index].href.match(r6)) { ahref.push(alist[index].href); } if (alist[index].href && alist[index].href.match(r3)) { ahref_samedomain.push(alist[index].href); } } console.log(1, ahref.length) if (!ahref.length) { //如果没有a标签存在的话 去js中查询 // alist = $("img").parents("a"); var scripts = $("script"); if ($("script").length) { for(var index4 in scripts) { if (scripts[index4].text) { var scripts_content = scripts[index4].text; if (scripts_content.match) { var scripts_content_match = scripts_content.match(r5); if (scripts_content_match && scripts_content_match.length) { alist_script = alist_script.concat(scripts_content_match); } } } } } else if (scripts.text) { if (scripts.text.match) { alist_script = scripts.text.match(r5); } } console.log(83, alist_script) } if (alist_script.length) { for (index5 in alist_script) { if (alist_script[index5].match) { if (alist_script[index5] && !alist_script[index5].match(r1) && !alist_script[index5].match(r2)) { ahref.push(alist_script[index5]); } if (alist_script[index5] && alist_script[index5].match(r3)) { ahref_samedomain.push(alist_script[index5]); } } } } console.log(2, ahref.length); if (!ahref.length) { //如果没有a标签存在的话 去所有a>img中查询 alist = $("img").parents("a"); console.log(3, alist); var deal_res = deal_ad_href(alist); ahref = deal_res[0]; ahref_samedomain = deal_res[1]; } ahref = unique(ahref); var ahref1 = []; var ahref2 = []; for (var index3 in ahref) { if (ahref[index3].match && ahref[index3].match(r4)) { ahref1.push(ahref[index3]); } else { ahref2.push(ahref[index3]); } } ahref = ahref1.concat(ahref2) ahref_samedomain = unique(ahref_samedomain); console.log(222,ahref); console.log(555,ahref_samedomain); var ahref_content = ahref.join("\r\n"); var ahref_samedomain_content = ahref_samedomain.join("\r\n"); var ahref_samedomain_a_str = ''; for (var index2 in ahref_samedomain) { var current_ahref = ahref_samedomain[index2]; ahref_samedomain_a_str += `
`; } //查询文字a标签 var a_word = $("a"); var ahref_word = []; var ahref_word_a_str = ''; console.log(139, a_word); for (var index = 0; index < a_word.length; index++) { console.log(141, a_word[index],a_word[index].innerHTML, ((a_word[index].innerHTML && a_word[index].innerHTML.match && a_word[index].innerHTML.match(r_word)) || a_word[index].innerHTML == '') , ahref.indexOf(a_word[index]) === -1 , a_word[index].href , !a_word[index].href.match(r1) , !a_word[index].href.match(r2)); if (((a_word[index].innerHTML && a_word[index].innerHTML.match) || a_word[index].innerHTML == '') && ahref.indexOf(a_word[index]) === -1 && a_word[index].href && !a_word[index].href.match(r1) && !a_word[index].href.match(r2)) { ahref_word.push(a_word[index].href); } } ahref_word = unique(ahref_word); for (var index = 0; index < ahref_word.length; index++) { var current_ahref_word = ahref_word[index]; ahref_word_a_str += ``; } console.log(148, ahref_word_a_str, ahref_word); var show_content = ''; console.log(556, $("iframe").length,Boolean($("iframe"))); if ($("iframe") && $("iframe").length) { //存在iframe, 不在iframe中 var position1 = '450px'; var position2 = '700px'; var desc = ""; } else { var position1 = '20px'; var position2 = '300px'; var desc = ''; } if (ahref_content !== '' ) { show_content += ` `; } if (ahref_samedomain_a_str !== '') { show_content += `