取消跳转拦截

取消网站跳转拦截

目前为 2023-09-22 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 取消跳转拦截
  3. // @namespace https://bbs.tampermonkey.net.cn/
  4. // @version 2.7.2
  5. // @description 取消网站跳转拦截
  6. // @author 冰冻大西瓜
  7. // @license GPLv3
  8. // @match https://link.juejin.cn/?target=*
  9. // @match https://c.pc.qq.com/*
  10. // @match http(s?)://link.zhihu.com/?target=*
  11. // @match https://link.csdn.net/?target=*
  12. // @match https://weixin110.qq.com/cgi-bin/mmspamsupport-bin/newredirectconfirmcgi?click=*
  13. // @note 更新微信110拦截
  14. // ==/UserScript==
  15.  
  16. // 跳转实现
  17. /**
  18. * @description 实现网页自动跳转
  19. * @param {string} regular 处理规则
  20. * @return {string} window.location.href:跳转后的URL
  21. */
  22. const jumpUrl = regular => {
  23. if (!regular) return
  24. // 判断是否为正则表达式
  25. if (regular instanceof RegExp) {
  26. const result = urlInfo.href.match(regular)
  27. if (result) window.location.href = decodeURIComponent(result[1])
  28. } else if (regular.constructor === Object) {
  29. // 处理腾讯拦截,有多种拦截URL,做单独处理
  30. if (urlInfo.href.includes('pfurl')) {
  31. const result = urlInfo.href.match(regular.pfurl)
  32. console.log('pfurl: ', result)
  33. if (result) window.location.href = decodeURIComponent(result[1])
  34. } else if (urlInfo.href.includes('ios.html')) {
  35. const result = urlInfo.href.match(regular.sublevel)
  36. console.log('ios.html: ', result)
  37. if (result) window.location.href = decodeURIComponent(result[1])
  38. }
  39. } else {
  40. const url = document.querySelector(regular).textContent
  41. if (url) {
  42. window.location.href = url
  43. } else {
  44. console.log('网址被强力屏蔽,无法解析')
  45. }
  46. }
  47. }
  48.  
  49. // 配置项
  50. const domain = {
  51. 'c.pc.qq.com': { pfurl: /pfurl=(.*)&pfuin/, sublevel: /&url=(.*)&sublevel/ },
  52. 'link.zhihu.com': /target=(.*)/,
  53. 'link.juejin.cn': /target=(.*)/,
  54. 'link.csdn.net': /target=(.*)/,
  55. 'weixin110.qq.com': '.ui-ellpisis-content p',
  56. }
  57.  
  58. // 程序入口
  59. const urlInfo = window.location
  60. const regular = domain[urlInfo.hostname] || null
  61. jumpUrl(regular)

QingJ © 2025

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