// ==UserScript== // @name 取消跳转拦截 // @namespace https://bbs.tampermonkey.net.cn/ // @version 2.6 // @description 取消跳转拦截 // @author 冰冻大西瓜 // @match https://link.juejin.cn/?target=* // @match https://c.pc.qq.com/* // @match https://link.zhihu.com/?target=* // @match https://link.csdn.net/?target=* // @match https://weixin110.qq.com/cgi-bin/mmspamsupport-bin/newredirectconfirmcgi?click=* // @license // ==/UserScript== // 跳转实现 /** * @description: 实现网页自动跳转 * @param {string} url:访问网页的域名 */ const jumpUrl = url => { const regular = domain[url] || null // 判断是否为正则表达式 if (regular instanceof RegExp) { const result = urlInfo.href.match(regular) if (result) window.location.href = decodeURIComponent(result[1]) } else if (regular.constructor === Object) { // 处理腾讯拦截,有多种拦截URL,做单独处理 if (urlInfo.href.includes('pfurl')) { const result = urlInfo.href.match(regular.pfurl) if (result) window.location.href = decodeURIComponent(result[1]) } else if (urlInfo.href.includes('sublevel')) { const result = urlInfo.href.match(regular.sublevel) if (result) window.location.href = decodeURIComponent(result[1]) } } else { window.location.href = new Function('return ' + domain[url])() } } // 配置项 const domain = { 'c.pc.qq.com': { pfurl: /pfurl=(.*)&pfuin/, sublevel: /&url=(.*)&sublevel/ }, 'link.zhihu.com': /target=(.*)/, 'link.juejin.cn': /target=(.*)/, 'link.csdn.net': /target=(.*)/, 'weixin110.qq.com': "document.querySelector('.ui-ellpisis-content p').innerText", } // 程序入口 const urlInfo = window.location jumpUrl(urlInfo.hostname)