知乎、简书、CSDN、掘金链接直接跳转

去除知乎、简书、CSDN、掘金链接跳转提示,点击链接直接跳转网页

目前为 2024-03-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 知乎、简书、CSDN、掘金链接直接跳转
  3. // @namespace https://gf.qytechs.cn/
  4. // @version 0.7
  5. // @description 去除知乎、简书、CSDN、掘金链接跳转提示,点击链接直接跳转网页
  6. // @author Derek
  7. // @match https://*.zhihu.com/*
  8. // @match https://*.csdn.net/*
  9. // @match https://*.jianshu.com/*
  10. // @match https://*.juejin.cn/*
  11. // @match https://*.51cto.com/*
  12. // @grant none
  13. // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. function getRealHref(href) {
  18. try {
  19. if (href.startsWith(`https://link.zhihu.com/?target=`)) {
  20. let href_real = href.split(`?target=`)[1];
  21. return decodeURIComponent(href_real);
  22. } else if (href.startsWith(`https://link.jianshu.com?t=`)) {
  23. let href_real = href.split(`?t=`)[1];
  24. return decodeURIComponent(href_real);
  25. } else if (href.startsWith(`https://links.jianshu.com/go?to=`)) {
  26. let href_real = href.split(`go?to=`)[1];
  27. return decodeURIComponent(href_real);
  28. } else if (href.startsWith(`https://link.juejin.cn?target=`)) {
  29. let href_real = href.split(`?target=`)[1];
  30. return decodeURIComponent(href_real);
  31. } else {
  32. return href;
  33. }
  34. } catch (e) {
  35. return href;
  36. }
  37. }
  38.  
  39. (function () {
  40. window.topen = window.open;
  41. window.open = (a, b) => {
  42. if (a.startsWith("https://link.csdn.net?target=")) {
  43. a = a.replace(/https\:\/\/link\.csdn\.net\?target\=/g, '');
  44. window.topen(decodeURIComponent(a), b);
  45. } else if (a.startsWith("https://blog.51cto.com/transfer?")) {
  46. a = a.replace(/https\:\/\/blog\.51cto\.com\/transfer\?/g, '');
  47. window.topen(decodeURIComponent(a), b);
  48. } else {
  49. window.topen(a, b);
  50. }
  51. }
  52. setInterval(() => {
  53. //对新出现的内容,每 1.5s 刷新一次a标签的链接
  54. let a = $(`a`);
  55. for (let i = 0; i < a.length; i++) {
  56. let cur_a = a.eq(i);
  57. let cur_href = cur_a.attr(`href`);
  58. if (cur_href) {
  59. cur_a.attr(`href`, getRealHref(cur_href));
  60. }
  61. }
  62. }, 1500);
  63. })();

QingJ © 2025

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