kxtool

@license End-User License Agreement

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/469703/1296888/kxtool.js

  1. function isMobile() {
  2. let flag= false;
  3. if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  4. flag= true;
  5. }
  6. return flag
  7. }
  8.  
  9. function aerads() {
  10. $('a, i, span').each(function() {
  11. var text = $(this).text().trim();
  12. if (text == '广告') {
  13. var thisparent=$(this).parent();
  14. thisparent.remove();
  15.  
  16. }
  17. });
  18.  
  19. }
  20.  
  21. function Passiveads() {
  22. if (GM_info.script.namespace!="Z3JlYXN5Zm9yaw=="){
  23. return
  24. }
  25. aerads()
  26. $("iframe[src*='//googleads']").remove();
  27. $("div[data-type='GoogleRender']").remove();
  28. $(".adsbygoogle").remove();
  29. $("#bottomads").remove();
  30. $("script[src*='adsbygoogle.js']").remove();
  31. $("script[src*='g.doubleclick.net']").remove();
  32. $("script[src*='pos.baidu.com']").remove();
  33. $("iframe[src^='https://g.163.com']").remove();
  34. $("div[id*='google_ads']").remove();
  35. $("div[data-google-query-id]").remove();
  36. $("iframe[src*='pos.baidu.com']").remove();
  37. $("iframe[src*='show-3.mediav.com']").remove();
  38. $("div[class*='wwads-cn wwads']").remove();
  39.  
  40. var kgpingbiswhitezt=true;
  41. var kgpingbiswhiteurl = [
  42. "recaptcha.google",
  43. "captcha.qq.com",
  44. "alicdn.com",
  45. "aliyun.com",
  46. "quark.cn",
  47. "taobao.com",
  48. "mall.com",
  49. "weibo.com",
  50. ".le.com",
  51. "iqiyi.com",
  52. "tudou.com",
  53. "qq.com",
  54. "douyin.com",
  55. "javascript:",
  56. "youku.com",
  57. "sohu.com",
  58. "pptv.com",
  59. "twitter.com",
  60. "facebook.com",
  61. "instagram.com",
  62. "tiktok.com",
  63. "imdb.com",
  64. "vk.com",
  65. "mtv.com",
  66. "56.com",
  67. "ku6.com",
  68. "cntv.cn",
  69. "cctv.cn",
  70. "mgtv.com",
  71. "yinyuetai.com",
  72. "wasu.cn",
  73. "163.com",
  74. "1905.com",
  75. "xunlei.com",
  76. "funshion.com",
  77. "youhui",
  78. "pornhub.com",
  79. "youtube.com",
  80. "bilibili.com",
  81. "mama.com",
  82. "zhihu.com",
  83. "baidu.com"];
  84.  
  85.  
  86. var whiteHosts = [
  87. 'suning.com',
  88. 'vip.com',
  89. 'jd.com',
  90. 'taobao.com',
  91. 'mall.com'
  92. ];
  93.  
  94.  
  95. if (whiteHosts.some(function (host) {
  96. return location.hostname.indexOf(host) > -1;
  97. })) {
  98. kgpingbiswhitezt = false;
  99. }
  100. var inputList = $("input").filter(":visible");
  101.  
  102. inputList.each(function() {
  103. var $this = $(this);
  104. var placeholder = $this.attr('placeholder') || '';
  105. if ($this.attr('name') === 'username' ||
  106. $this.is('[type="password"]') ||
  107. $this.attr('name') === 'password' ||
  108. $this.attr('type') === 'email' ||
  109. $this.attr('name') === 'email' ||
  110. $this.attr('type') === 'phone' ||
  111. $this.attr('name') === 'code' ||
  112. $this.attr('name') === 'phone' ||
  113. placeholder.indexOf('手机') !== -1 ||
  114. placeholder.indexOf('邮箱') !== -1 ||
  115. placeholder.indexOf('账号') !== -1 ||
  116. placeholder.indexOf('密码') !== -1 ||
  117. placeholder.indexOf('注册(不可用)') !== -1) {
  118. kgpingbiswhitezt = false;
  119. return false;
  120. }
  121. });
  122. //说明:此处是为了匹配某些网站登陆时插件错误屏蔽登陆验证的页面需要,防止不能正常登陆。并无没有收集用户的任何信息
  123. var classNames = ['data-down-ui', 'data-down-ui1', 'data-down-ui2'];
  124. for (var i = 0; i < classNames.length; i++) {
  125. var className = classNames[i];
  126. if (document.getElementsByClassName(className).length > 0) {
  127. kgpingbiswhitezt = false;
  128. return;
  129. }
  130. }
  131. if ( kgpingbiswhitezt){
  132. let iframehost=window.location.host;
  133.  
  134.  
  135. $("iframe").each(function(index){
  136.  
  137. var iframeon=0;
  138.  
  139. if ($(this).attr("src")){
  140. let iframesrc=$(this).attr("src");
  141. for(let i = 0; i < kgpingbiswhiteurl.length; i++) {
  142. if (iframesrc.indexOf(kgpingbiswhiteurl[i])>=0){
  143. kgpingbiswhitezt=false;
  144. }
  145. }
  146.  
  147. if ($(this).attr("src").indexOf("http")==0 && window.location.href.indexOf("tool")<0 && window.location.href.indexOf("video")<0 && $(this).attr("src").indexOf("video")<0 && $(this).attr("src").indexOf("?url=")<0 && $(this).attr("src").indexOf(iframehost)<0 && kgpingbiswhitezt){
  148. $(this).remove();
  149. iframeon=1;
  150. }
  151. }
  152. if ( iframeon==0){
  153. try {
  154. var inputElements = $(this).contents();
  155. try {
  156. var inputLength = inputElements.find('input').length;
  157. var textareaLength = inputElements.find('textarea').length;
  158. var imgLength = inputElements.find('img').length;
  159. var videoLength = inputElements.find('video').length;
  160. var bodyText = inputElements.find('body').first().text();
  161. var bodyTextLength =bodyText.length;
  162. if (inputLength > 0 || textareaLength > 0 || imgLength==0 || videoLength>0 || bodyTextLength > 200) {
  163. kgpingbiswhitezt = false;
  164. }
  165. if (kgpingbiswhitezt){
  166. var imgElements = inputElements.find('img');
  167. var maxImgElement = null;
  168. var maxImgArea = 0;
  169.  
  170. imgElements.each(function() {
  171. var imgWidth = $(this).width();
  172. var imgHeight = $(this).height();
  173. var imgArea = imgWidth * imgHeight;
  174. if (imgArea > maxImgArea) {
  175. maxImgArea = imgArea;
  176. maxImgElement = this;
  177. }
  178. });
  179.  
  180. var iframeWidth = $(this).width();
  181. var iframeHeight = $(this).height();
  182. var iframeArea = iframeWidth * iframeHeight;
  183. var imgWidth = $(maxImgElement).width();
  184. var imgHeight = $(maxImgElement).height();
  185. var imgArea = imgWidth * imgHeight;
  186.  
  187. if (imgArea / iframeArea > 0.5) {
  188. $(this).remove();
  189. kgpingbiswhitezt = false;
  190. }
  191. }
  192. if (kgpingbiswhitezt){
  193. $(this).remove();
  194. }
  195. } catch (error) {
  196. console.log('读取 iframe 失败');
  197. }
  198.  
  199. } catch (error) {
  200. console.log('第', index + 1, '个非同源的 iframe');
  201. }
  202.  
  203. }
  204. })
  205.  
  206.  
  207. function getImageSize(element) {
  208. if (element.attr('kxtool') ) {
  209. return false;
  210. }
  211. if (element.prop('tagName') === 'HTML' || element.prop('tagName') === 'HEADER' || element.prop('tagName') === 'BODY' || element.prop('tagName') === 'MAIN') {
  212. return false;
  213. }
  214. var childElements = element.find("*");
  215. for (var i = 0; i < childElements.length; i++) {
  216. var childTag = $(childElements[i]).prop('tagName');
  217.  
  218. if (childTag === 'HTML' || childTag === 'HEADER' || childTag === 'BODY' || childTag=== 'MAIN') {
  219. return false;
  220. }
  221. }
  222. var $elem = element;
  223. var targets = [];
  224. if ($elem.prop('tagName') === 'IMG') {
  225. targets.push($elem);
  226. }
  227.  
  228. var $imgs = $elem.find('img');
  229. if ($imgs.length > 0) {
  230. var maxWidth = 0;
  231. $imgs.each(function() {
  232. var width = $(this).prop('naturalWidth') || $(this).width();
  233. if (width > maxWidth) {
  234. maxWidth = width;
  235. targets.push($(this));
  236. }
  237. });
  238. }
  239.  
  240. var $bgImgs = $elem.find('*').filter(function() {
  241. var style = getComputedStyle(this);
  242. return (
  243. style['background-image'] !== 'none' && style['background-image'] !== ''
  244. ) || (
  245. style['background'] && style['background'].includes('url(')
  246. );
  247. });
  248. if ($bgImgs.length > 0) {
  249. $bgImgs.each(function() {
  250. targets.push($(this));
  251. });
  252. }
  253.  
  254.  
  255. if (targets.length > 0) {
  256. var maxTarget = targets.reduce(function(max, target) {
  257. var width = target.width();
  258. return width > max.width ? {target: target, width: width} : max;
  259. }, {target: null, width: 0});
  260.  
  261. if (maxTarget.target) {
  262. return {
  263. width: maxTarget.width,
  264. tag: maxTarget.target.prop('tagName'),
  265. url: maxTarget.target.attr('src'),
  266. rl: maxTarget.target.attr('style'),
  267. height: maxTarget.target.height()
  268. };
  269. }
  270. }
  271.  
  272. return false;
  273. }
  274.  
  275. var windowHeight = $(window).height();
  276. var windowwidth= $(window).width() *0.8;
  277. var removeHeight=200;
  278. if (isMobile()){
  279. removeHeight=150;
  280. }
  281. var datag=true;
  282. if (window.location.href.indexOf('dadi') >0 || window.location.href.indexOf('teng') >0 ) {
  283. datag=false;
  284. }
  285. if (datag){
  286. $('img').filter(function() {
  287. var $this = $(this);
  288. var offsetTop = $this.offset().top;
  289. return offsetTop >= 50 && $this.parents('picture').length === 0 && $this.width() >= windowwidth && $this.height() >10 && $this.height() <= removeHeight && $this.is(':visible');
  290. }).remove();
  291.  
  292. $('[style*="position: fixed"]').add('*')
  293. .filter(function() {
  294. return ($(this).css('position') === 'fixed');
  295. })
  296. .filter(function() {
  297. var classes = $(this).attr('class');
  298. return (!classes || !classes.match(/\b.*nav.*\b/));
  299. })
  300. .filter(':visible')
  301. .not('form, input')
  302. .each(function() {
  303. var $this = $(this);
  304. var hasFormOrInput = $this.find('form, input').length > 0;
  305. if (hasFormOrInput) {
  306. return;
  307. }
  308. var $imgs = $this.find('img');
  309. if ($imgs.length === 0) {
  310. return;
  311. }
  312. var $maxImg = $imgs.eq(0);
  313. var divarea = $this.width() * $this.height();
  314.  
  315. let getSize = getImageSize($this);
  316. if (getSize) {
  317. var IMGarea = getSize.width * getSize.height;
  318. if (IMGarea >= divarea * 0.8) {
  319. $this.remove();
  320. } else {
  321. let Divthistext = /^\s*$/.test($this.text());
  322. if (Divthistext) {
  323. $this.remove();
  324. }
  325. }
  326. }
  327. });
  328.  
  329. }
  330. }
  331. }
  332. //=============
  333. var debugMode = false; // 是否处于调试模式
  334. var currentElement = null; // 当前鼠标所在的元素
  335.  
  336. function ProactivelyadsBtn() {
  337. if (GM_info.script.namespace!="Z3JlYXN5Zm9yaw=="){
  338. return
  339. }
  340. var butjc = GM_getValue('Proactivelyads', '0');
  341. if (butjc=='0'){
  342. $('<div id="debugBtnBtn" style="position: fixed; top: 50px; right: 0; z-index: 9999; padding: 6px 12px; background: rgba(255, 255, 255, .7); cursor: pointer; background-color: #e1e1e1; border-radius: 10px;"><button id="debugBtn" style=" margin-right: 10px; border: none; border-radius: 10px; background-color: #6175bd; color: white;padding: 8px 10px; font-size: 15px;display: initial;">调试模式</button><button id="debugresetBtn" style=" margin-right: 10px; border: none; border-radius: 10px; background-color: #6175bd; color: white;padding: 8px 10px; font-size: 15px;display: initial;" > 恢复默认</button><button id="debugExitBtn" style=" margin-right: 10px; border: none; border-radius: 10px; background-color: #6175bd; color: white;padding: 8px 10px; font-size: 15px;display: initial;">退出</button></div>').appendTo(document.body);
  343. }
  344. }
  345. // 定义变量
  346.  
  347. // 创建样式
  348. GM_addStyle(`
  349. .debug-mask {
  350. position: fixed;
  351. top: 0;
  352. left: 0;
  353. right: 0;
  354. bottom: 0;
  355. background: rgba(255, 255, 255, .5);
  356. z-index: 9998;
  357. display: none;
  358. }
  359. .debug-border { border: 2px solid red !important; box-shadow: 0 0 5px rgba(0, 0, 0, .3) !important; position: relative; }
  360.  
  361. `);
  362.  
  363. // 鼠标移过元素时触发的事件
  364. function mouseOverHandler(event) {
  365. if (debugMode) {
  366. var elem = event.target;
  367. let tagName=$(elem).prop('tagName');
  368. if ( tagName.includes("BODY")||tagName.includes("HTML")||tagName.includes("HEADER") ||tagName.includes("MAIN")){
  369. return
  370. }
  371.  
  372. let targetid = $(elem).attr("id");
  373. let targetclass = $(elem).attr("class");
  374. if ($(elem).attr("mytool")){
  375. return;
  376. }
  377. if (targetid){
  378. if (targetid=="debugBtn" || targetid=="debugBtnBtn" || targetid=="debugresetBtn" || targetid=="debugExitBtn" || targetid=="mytoolzxmenu" || targetid=="mytoolzxmenu" || targetid=="mytoolzxmenuPage" ){
  379. return
  380. }
  381. }
  382. if (targetclass){
  383. if ( targetclass.includes("subItem")||targetclass.includes("menuItem")){
  384. return
  385. }
  386. }
  387.  
  388. if (currentElement !== elem) {
  389. hideDeleteBtn(currentElement);
  390. currentElement = elem;
  391. showDeleteBtn(elem);
  392. }
  393. elem.classList.add('debug-border');
  394. }
  395. }
  396.  
  397. // 显示元素的删除按钮
  398. function showDeleteBtn(elem) {
  399.  
  400.  
  401. }
  402.  
  403. $("body").on('click', '#debugExitBtn', function(event) {
  404. toastr.success('已退出!', '', { positionClass: 'toast-bottom-right', showDuration: 300, hideDuration: 1000, timeOut: 3000, extendedTimeOut: 1000, showEasing: 'swing', hideEasing: 'linear', showMethod: 'fadeIn', hideMethod: 'fadeOut' });
  405. debugMode = false;
  406. hideDeleteBtn(currentElement);
  407. currentElement = null;
  408. document.body.removeEventListener('mouseover', mouseOverHandler, true);
  409. GM_setValue('Proactivelyads','1');
  410. $("#debugBtnBtn").remove();
  411. });
  412. $("body").on('click', '#debugresetBtn', function(event) {
  413. var domain = window.location.host;
  414. var domainadValue = GM_getValue('domainad') || {};
  415. delete domainadValue[domain];
  416. GM_setValue('domainad', domainadValue);
  417. location.reload();
  418. });
  419. // 点击元素的删除按钮后的操作
  420. $("body").on('click', '.debug-border', function(event) {
  421. toastr.success('已删除此元素!', '', { positionClass: 'toast-bottom-right', showDuration: 300, hideDuration: 1000, timeOut: 3000, extendedTimeOut: 1000, showEasing: 'swing', hideEasing: 'linear', showMethod: 'fadeIn', hideMethod: 'fadeOut' });
  422. event.stopPropagation(); // 阻止事件冒泡
  423. event.preventDefault(); // 阻止默认行为
  424. let targetid = $(this).attr("id");
  425. let targetclass = $(this).attr("class");
  426. if (targetid && (targetid == "debugBtn" || targetid == "debugresetBtn" || targetid == "mytoolzxmenu" || targetid == "mytoolzxmenuPage")) {
  427. return;
  428. }
  429. if (targetclass && (targetclass.includes("subItem") || targetclass.includes("menuItem"))) {
  430. return;
  431. }
  432.  
  433. getAdFeatures(this);
  434.  
  435.  
  436. $(".debug-border").remove(); // 移除点击的元素
  437. });
  438.  
  439. function updomainad(k) {
  440. if (window.location.href.indexOf('dadi') >0 || window.location.href.indexOf('teng') >0 ) {
  441. return;
  442. }
  443. var domain = window.location.host;
  444. var domainadValue = GM_getValue('domainad') || {};
  445. if (!domainadValue[domain]) {
  446. domainadValue[domain] = {};
  447. }
  448. domainadValue[domain][k] =true;
  449. GM_setValue('domainad', domainadValue);
  450.  
  451. }
  452. // 获取元素标签名、id、class、style、src、href 的广告特征
  453. function getAdFeatures(elem) {
  454. let features = '';
  455. let tagName = '';
  456. var domain = window.location.host;
  457. if (elem.tagName) {
  458. tagName= elem.tagName.toLowerCase();
  459. }
  460.  
  461.  
  462.  
  463. if (elem.id) {
  464. features = tagName+'#' + elem.id;
  465. updomainad(features);
  466. }
  467. if (elem.classList && elem.classList.length > 0) {
  468. let classtxt='[class="' + $(elem).attr('class').replace(/debug-border/g, '')+ '"]';
  469. if (classtxt!='[class=""]'){
  470. var lastSpaceIndex = classtxt.lastIndexOf(" ");
  471. if (lastSpaceIndex !== -1) {
  472. classtxt = classtxt.substring(0, lastSpaceIndex) + "" + classtxt.substring(lastSpaceIndex + 1);
  473. }
  474. features=tagName+classtxt;
  475. updomainad(features);
  476. }
  477. }
  478.  
  479. if (elem.style.cssText) {
  480. let styletxt='[style^="' + $(elem).attr('style')+ '"]';
  481. features=tagName+styletxt;
  482. updomainad(features);
  483. }
  484. if (elem.src) {
  485. let elemurl=elem.src;
  486. let matchStr = elemurl.match(/\/\/[^/]*\/(.+?)([.?]|$)/);
  487. elemurl = matchStr[1];
  488.  
  489. features = tagName+'[src*="' + elemurl + '"]';
  490. updomainad(features);
  491. }
  492. if (elem.href) {
  493. let elemurl=elem.href;
  494. let matchStr = elemurl.match(/\/\/[^/]*\/(.+?)([.?]|$)/);
  495. elemurl = matchStr[1];
  496. features = tagName+'[href*="' + elemurl + '"]';
  497.  
  498. updomainad(features);
  499.  
  500. }
  501.  
  502. // return features;
  503. }
  504. // 隐藏元素的删除按钮
  505. function hideDeleteBtn(elem) {
  506. if (elem) {
  507. elem.classList.remove('debug-border');
  508. }
  509. }
  510.  
  511. // 遍历并隐藏元素的所有子节点
  512. function hideElementContent(elem) {
  513. $(elem).children().each(function() {
  514. hideElementContent(this);
  515. $(this).hide();
  516. });
  517. }
  518.  
  519. // 点击调试按钮后的操作
  520. $("body").on('click', '#debugBtn', function() {
  521. debugMode = !debugMode;
  522. if (debugMode) {
  523. document.body.addEventListener('mouseover', mouseOverHandler, true);
  524. toastr.success('已进入调试模式!移动鼠标,可以点击你需要删除的页面元素包括广告。误删可以使用恢复按钮即可让页面恢复正常。适合大部分网页。重新打开页面生效!', '', { positionClass: 'toast-bottom-right', showDuration: 300, hideDuration: 1000, timeOut: 3000, extendedTimeOut: 1000, showEasing: 'swing', hideEasing: 'linear', showMethod: 'fadeIn', hideMethod: 'fadeOut' });
  525. } else {
  526. toastr.success('已关闭调试模式!', '', { positionClass: 'toast-bottom-right', showDuration: 300, hideDuration: 1000, timeOut: 3000, extendedTimeOut: 1000, showEasing: 'swing', hideEasing: 'linear', showMethod: 'fadeIn', hideMethod: 'fadeOut' });
  527. hideDeleteBtn(currentElement);
  528. currentElement = null;
  529. document.body.removeEventListener('mouseover', mouseOverHandler, true);
  530. }
  531. });
  532. // 自动隐藏符合广告特征的元素
  533.  
  534.  
  535. function Proactivelyads() {
  536. if (GM_info.script.namespace!="Z3JlYXN5Zm9yaw=="){
  537. return
  538. }
  539. var domain = window.location.host;
  540. var adFeaturesStr = GM_getValue(domain, '');
  541. var domainadValue = GM_getValue('domainad');
  542. var adFeaturesStr = domainadValue && domainadValue[domain] ? domainadValue[domain] : '';
  543. if (adFeaturesStr==""){
  544. return
  545. }
  546. for (var featureStr in adFeaturesStr) {
  547. try {
  548. var selector = featureStr;
  549.  
  550. if (selector.includes('[class="')) {
  551. var match = selector.match(/class\s*=\s*"([^"]+)"/);
  552. if (match && match[1]) {
  553. var classes = match[1].split(/\s+/);
  554. var tagName = selector.split('[')[0];
  555. selector = tagName + '.' + classes.join('.');
  556. $(selector).remove();
  557. }
  558. }else{
  559. $(selector).remove();
  560. }
  561. } catch (err) {
  562. console.log('执行出错');
  563. }
  564.  
  565.  
  566. }
  567. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址