// ==UserScript== // @name good target click // @namespace http://tampermonkey.net/ // @version 0.3 // @description 自动点击csdn zhihu 弹出的target 自动点击,如果失效的话,后续改成直接跳转! // @author lich // @match https://xie.infoq.cn/link?target=* // @match https://cloud.tencent.com/developer/tools/blog-entry?target=* // @match https://nav.qixinpro.com/sites/* // @match https://link.csdn.net/?target=* // @match https://link.zhihu.com/?target=* // @match https://link.juejin.cn/?target=* // @icon https://www.google.com/s2/favicons?sz=64&domain=infoq.cn // @grant none // @run-at document-end // @license MIT // @downloadURL none // ==/UserScript== /** * 如何开始 * 将需要添加的附属到 function是类上 */ (function() { 'use strict'; var count = 100; var functions = {} var href = window.location.href; function lazyTrigger(func) { var dom = func() if(count-- <0 || dom) { dom && (function(dom) { dom.target && (dom.target = '') dom.click() })(dom) return; } setTimeout(function() { lazyTrigger(func) }, 200); } // infoq functions['infoq.cn'] = function() { return document.querySelector('.Button_button_3onsJ'); } // cloud.tencent.com/developer functions['cloud.tencent.com/developer'] = function() { return document.querySelector('.mod-external-link-btn a'); } // nav.qixinpro.com/sites functions['nav.qixinpro.com/sites'] = function() { return document.querySelector('.site-go-url a'); } // csdn functions['link.csdn.net'] = function() { return document.querySelector('#apesar-loading'); } // link zhihu functions['link.zhihu'] = function() { return document.querySelector('.button'); } // link.juejin.cn functions['link.juejin.cn'] = function() { return document.querySelector('.btn'); } Object.keys(functions).forEach(key => { if (href.includes(key)) { lazyTrigger(functions[key]) } }) })();