删除链接重定向

点击页面左下角蓝色按钮删除超链接中的第三方跳转,目前支持的网站有知乎、简书、掘金等等网站。如果发现没有删除第三方跳转,或者新的超链接是新生成的,多次点击该按钮即可。作者:浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)

目前為 2019-10-13 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 删除链接重定向
  3. // @namespace https://github.com/kingphoenix2000/tampermonkey_scripts
  4. // @supportURL https://github.com/kingphoenix2000/tampermonkey_scripts
  5. // @version 0.1.0
  6. // @author 浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)
  7. // @description 点击页面左下角蓝色按钮删除超链接中的第三方跳转,目前支持的网站有知乎、简书、掘金等等网站。如果发现没有删除第三方跳转,或者新的超链接是新生成的,多次点击该按钮即可。作者:浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)
  8. // @homepage https://blog.csdn.net/kingwolf_javascript/
  9. // @include *://*.zhihu.com/*
  10. // @include *://*.jianshu.com/*
  11. // @include *://juejin.im/*
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17.  
  18. let removeURLList = [
  19. "https://link.zhihu.com/?target=",
  20. "http://link.zhihu.com/?target=",
  21. "https://link.jianshu.com/?t=",
  22. "https://link.juejin.im/?target="
  23. ];
  24.  
  25. let len = removeURLList.length;
  26. let div = document.createElement("div");
  27. div.id = "removeLinksRedirection";
  28. div.innerText = "删除链接重定向";
  29. div.style.cssText = "width: 150px;font-size:15px;padding: 7px;bottom: 35px;left: 35px;z-index: 1000;background-color: #0077e6;position: fixed;border-radius: 25px;text-align: center;cursor: pointer;color: #fff;";
  30. div.onclick = function (e) {
  31. let links = document.links;
  32. links = Array.from(links);
  33. links.forEach(function (a) {
  34. let href = a.href;
  35. for (let i = 0; i < len; i++) {
  36. let url = removeURLList[i];
  37. href = href.replace(url, '');
  38. }
  39. if (href.startsWith("http")) {
  40. href = decodeURIComponent(href);
  41. a.href = href;
  42. }
  43. else {
  44. console.log("错误的网址: ", a.href);
  45. }
  46. });
  47. this.innerText = "操作成功!";
  48. setTimeout(function () { document.getElementById("removeLinksRedirection").innerText = "删除链接重定向"; }, 3000);
  49. }
  50.  
  51. document.body.appendChild(div);
  52.  
  53. })();