// ==UserScript== // @name 外链自动跳转 // @namespace http://tampermonkey.net/ // @version 0.1.1 // @description 自动跳转链接,自动完成CSDN、掘金、简书、知乎、贴吧等网站的跳转询问界面的跳转 // @author myaijarvis // @icon https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web//static/favicons/apple-touch-icon.png // @match *://link.csdn.net/* // @match *://link.juejin.cn/* // @match *://link.zhihu.com/* // @match *://www.jianshu.com/go-wild* // @match *://jump.bdimg.com/safecheck/index?url=* // @match *://gitee.com/link* // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js // @run-at document-end // @grant none // @downloadURL none // ==/UserScript== const url = document.URL; (function () { "use strict"; /* 原理:获取外链的链接地址,然后直接跳转,而不是点击按钮触发网站跳转(其他脚本常见做法) 代码比较少,新手可以学习一下 */ // Your code here... //console.log(url); //debugger; let target_url = ""; if (url.match(/jump.bdimg.com/)) { // 贴吧 url路径上的跳转地址加密了,只能寻找其他方法 target_url = $("div.warning_info.fl > a:nth-child(2)").attr("href"); //debugger; } else if (url.match(/jianshu.com\/go-wild/)) { target_url = url.split("url=")[1]; } else { // 适用于目标路径在url上做参数的 比如https://link.csdn.net/?target=https%3A%2F%2Ftieba.baidu.com%2Fp%2F3303958322 //debugger; target_url = url.split("target=")[1]; } target_url = decodeURIComponent(target_url); // 编码 console.log(target_url); // 0.5秒后跳转 setTimeout(() => { window.location.href = target_url; }, 500); })(); /* 参考:https://blog.csdn.net/qq_44879358/article/details/120558187 */