// ==UserScript== // @name 知乎、CSDN链接直接跳转 // @namespace https://greasyfork.org/ // @version 0.3 // @description 去除知乎、CSDN链接跳转提示,点击链接直接跳转网页 // @author Derek // @match https://*.zhihu.com/* // @match https://*.csdn.net/* // @grant none // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js // @license MIT // @downloadURL none // ==/UserScript== function getRealHref(href) { try { if (href.startsWith(`https://link.zhihu.com/?target=`)) { //仅针对link.zhihu.com做跳转,其他不变 let href_real = href.split(`?target=`)[1]; return decodeURIComponent(href_real); } else { return href; } } catch (e) { return href; } } (function () { window.topen = window.open; window.open = (a, b) => { if (a.startsWith("https://link.csdn.net?target=")) { a = a.replace(/https\:\/\/link\.csdn\.net\?target\=/g, ''); window.topen(decodeURIComponent(a), b); } else { window.topen(a, b); } } setInterval(() => { //对新出现的内容,每秒刷新一次a标签的链接 let a = $(`a`); for (let i = 0; i < a.length; i++) { let cur_a = a.eq(i); let cur_href = cur_a.attr(`href`); if (cur_href) { cur_a.attr(`href`, getRealHref(cur_href)); } } }, 1000); })();