Open the F**king URL Right Now

自动跳转某些网站不希望用户直达的外链

目前为 2020-10-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Open the F**king URL Right Now
  3. // @description 自动跳转某些网站不希望用户直达的外链
  4. // @author OldPanda
  5. // @match http://t.cn/*
  6. // @match https://www.jianshu.com/go-wild?*
  7. // @match https://link.zhihu.com/?target=*
  8. // @match https://www.douban.com/link2/?url=*
  9. // @match https://link.ld246.com/forward?goto=*
  10. // @match https://mp.weixin.qq.com/*
  11. // @version 0.4.0
  12. // @run-at document-idle
  13. // @namespace https://old-panda.com/
  14. // @require https://code.jquery.com/jquery-3.5.1.min.js
  15. // @license GPL License
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. /**
  22. * Make urls clickable again on Weixin Media Platform.
  23. */
  24. function enableURLs() {
  25. let content = $("#js_content").text();
  26. let urls = content.matchAll(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g);
  27. let replaced = new Set();
  28. for (let value of urls) {
  29. let url = $.trim(value[0]);
  30. if (!url || replaced.has(url) || url.includes("localhost") || url.includes("127.0.0.1")) {
  31. continue;
  32. }
  33. $("#js_content").html((_, html) => {
  34. return html.replace(url, `<a target="_blank" rel="noopener noreferrer" href="${url}">${url}</a>`);
  35. });
  36. replaced.add(url);
  37. }
  38. }
  39.  
  40. $(document).ready(function () {
  41. if (window.location.href.includes("http://t.cn/")) {
  42. if ($(".wrap .desc").first().text() === "如需浏览,请长按网址复制后使用浏览器访问") {
  43. window.location.replace($(".wrap .link").first().text());
  44. }
  45. } else if (window.location.href.includes("https://www.jianshu.com/go-wild?")) {
  46. let fakeUrl = new URL(window.location.href);
  47. let trueUrl = fakeUrl.searchParams.get("url");
  48. window.location.replace(trueUrl);
  49. } else if (window.location.href.includes("https://link.zhihu.com/?target=")) {
  50. window.location.replace($(".content .link").first().text());
  51. } else if (window.location.href.includes("https://www.douban.com/link2/?url=")) {
  52. let fakeUrl = new URL(window.location.href);
  53. let trueUrl = fakeUrl.searchParams.get("url");
  54. window.location.replace(trueUrl);
  55. } else if (window.location.href.includes("https://link.ld246.com/forward?goto=")) {
  56. let fakeUrl = new URL(window.location.href);
  57. let trueUrl = fakeUrl.searchParams.get("goto");
  58. window.location.replace(trueUrl);
  59. } else if (window.location.href.includes("https://mp.weixin.qq.com/")) {
  60. enableURLs();
  61. }
  62. });
  63. })();

QingJ © 2025

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