Wanta

移除跳转外链提示

安裝腳本?
作者推薦腳本

您可能也會喜歡 去你妈的秒懂

安裝腳本
  1. // ==UserScript==
  2. // @name Wanta
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6.1
  5. // @description 移除跳转外链提示
  6. // @author PRO
  7. // @match *://www.jianshu.com/p/*
  8. // @match *://juejin.cn/post/*
  9. // @match *://gitee.com/*
  10. // @match *://zhuanlan.zhihu.com/*
  11. // @match *://*.feishu.cn/*
  12. // @match *://leetcode.cn/problems/*
  13. // @match *://weibo.com/*
  14. // @match *://www.mcmod.cn/*
  15. // @match *://play.mcmod.cn/*
  16. // @match *://www.mcbbs.net/*
  17. // @match *://www.minecraftforum.net/*
  18. // @match *://www.curseforge.com/minecraft/mc-mods/*
  19. // @match *://h5.qzone.qq.com/*
  20. // @icon https://gf.qytechs.cn/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBMWhLQVE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--2831c7f8ea43fc8b8e3eed3818b98e88bb689285/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202022-07-16%20105357.png?locale=zh-CN
  21. // @grant none
  22. // @license gpl-3.0
  23. // ==/UserScript==
  24.  
  25. (function () {
  26. 'use strict';
  27. const error = (...args) => console.error(`[Wanta ERROR]`, ...args);
  28. const debug = (...args) => console.log(`[Wanta DEBUG]`, ...args);
  29. // domain: [link_prefix query_parameter main_article_path decode_func]
  30. // query_parameter = '': Get the last part of url
  31. function same(orig) {
  32. return orig;
  33. }
  34. function b64Decode(orig) {
  35. return decodeURIComponent(atob(orig));
  36. }
  37. function mcmod(orig) {
  38. let parts = orig.split("@");
  39. return parts.map(b64Decode).join("?");
  40. }
  41.  
  42. const fuck = {
  43. 'www.jianshu.com': ['https://links.jianshu.com/go', 'to', 'article', decodeURIComponent],
  44. 'juejin.cn': ['https://link.juejin.cn', 'target', '#juejin > div.view-container > main > div > div.main-area.article-area > article', decodeURIComponent],
  45. 'gitee.com': ['https://gitee.com/link', 'target', '.markdown-body', decodeURIComponent],
  46. 'zhuanlan.zhihu.com': ['https://link.zhihu.com/', 'target', 'div.Post-RichTextContainer', decodeURIComponent],
  47. '.*\.feishu\.cn': ['https://security.feishu.cn/link/safety', 'target', 'div#mainBox', decodeURIComponent],
  48. 'leetcode.cn': ['https://leetcode.cn/link/', 'target', '#__next', same],
  49. 'weibo.com': ['https://weibo.cn/sinaurl?', 'u', '#app div[class^=Main_full]', decodeURIComponent],
  50. 'www.mcmod.cn': ['https://link.mcmod.cn/target/', '', 'body > div.col-lg-12.common-frame > div > div.col-lg-12.center > div.col-lg-12.right', mcmod],
  51. 'play.mcmod.cn': ['https://link.mcmod.cn/target/', '', 'body > div.col-lg-12.common-frame > div > div.col-lg-12.center', mcmod],
  52. 'www.mcbbs.net': ['https://www.mcbbs.net/plugin.php?id=link_redirect', 'target', 'div#ct', decodeURIComponent],
  53. 'www.minecraftforum.net': ['https://www.minecraftforum.net/linkout', 'remoteUrl', '.listing-container', decodeURIComponent],
  54. 'www.curseforge.com': ['https://www.curseforge.com/linkout', 'remoteUrl', '.project-page', decodeURIComponent],
  55. 'h5.qzone.qq.com': ['https://www.urlshare.cn/umirror_url_check', 'url', '#page-detail > .feed-list > .feed.dataItem', decodeURIComponent],
  56. };
  57. let domain = window.location.hostname;
  58. if (!(domain in fuck)) {
  59. for (let d in fuck) {
  60. if (domain.match(d)) {
  61. domain = d;
  62. break;
  63. }
  64. }
  65. }
  66. const prefix = fuck[domain][0];
  67. const queryName = fuck[domain][1];
  68. const mainPath = fuck[domain][2];
  69. const decodeFunc = fuck[domain][3];
  70. const attrFlag = "wanta-purified";
  71. const maxDepth = 5;
  72. function purify(link) {
  73. let new_href;
  74. if (queryName.length == 0) {
  75. let l = link.href.split('/');
  76. new_href = l[l.length - 1];
  77. } else {
  78. const params = new URL(link.href).searchParams;
  79. new_href = params.get(queryName);
  80. }
  81. try {
  82. new_href = decodeFunc(new_href);
  83. } catch (error) {
  84. error(`Failed to purify link "${link.href}".`)
  85. return false;
  86. }
  87. if (new_href) {
  88. debug(`${link.href} -> ${new_href}`);
  89. link.href = new_href;
  90. return true;
  91. } else {
  92. error(`Failed to purify link "${link.href}".`)
  93. return false;
  94. }
  95. }
  96. function handler(e) {
  97. let ele = e.target;
  98. for (let depth = 0; depth < maxDepth; depth++) {
  99. if (ele.hasAttribute(attrFlag)) {
  100. break;
  101. }
  102. if (ele.tagName == 'A') {
  103. debug(`Intercepted link: ${ele.href}`);
  104. if (!ele.href.startsWith(prefix) || purify(ele)) { // Note: If not starts with prefix, `purify` won't be called
  105. e.preventDefault();
  106. e.stopImmediatePropagation();
  107. ele.setAttribute(attrFlag, "success");
  108. ele.dispatchEvent(new MouseEvent(e.type, e));
  109. break;
  110. } else {
  111. ele.setAttribute(attrFlag, "failed");
  112. error(`Failed to purify link: ${ele.href}`);
  113. }
  114. }
  115. ele = ele.parentElement;
  116. }
  117. }
  118. const main_article = document.querySelector(mainPath);
  119. if (main_article) {
  120. main_article.addEventListener('mousedown', handler, true);
  121. main_article.addEventListener('click', handler, true);
  122. } else {
  123. error("Failed to find main article.");
  124. }
  125. })();

QingJ © 2025

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