Greasy Fork镜像 还支持 简体中文。

URL Redirect Redirecter

Redirect the Redirected Url

目前為 2023-09-03 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name URL Redirect Redirecter
  3. // @namespace FaustVXUrlRedirect
  4. // @version 0.4.1
  5. // @description Redirect the Redirected Url
  6. // @author FaustVX
  7. // @match http*://www.curseforge.com/*
  8. // @match http*://legacy.curseforge.com/*
  9. // @match http*://*.youtube.com/*
  10. // @match http*://twitter.com/*
  11. // @match http*://github.com/*
  12. // @grant none
  13. // @supportURL https://gist.github.com/FaustVX/0deb00258929a517a6e2796f9020e17c#comments
  14. // @contributionURL https://www.paypal.com/donate/?cmd=_donations&business=jodu035@gmail.com&item_name=TamperMonkey+Url+Redirect
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. function run() {
  19. 'use strict';
  20.  
  21. const urlSplit = window.location.href.split('/');
  22. const domainName = urlSplit[2].split('.');
  23.  
  24. function changeHref(query) {
  25. return function (a) {
  26. const urlParams = new URLSearchParams(a.search);
  27. const url = urlParams.get(query);
  28. a.href = decodeURIComponent(url);
  29. }
  30. }
  31.  
  32. function changeTag(node, tag) {
  33. const clone = createElement(tag)
  34. for (const attr of node.attributes) {
  35. clone.setAttributeNS(null, attr.name, attr.value)
  36. }
  37. while (node.firstChild) {
  38. clone.appendChild(node.firstChild)
  39. }
  40. node.replaceWith(clone)
  41. return clone
  42. }
  43.  
  44. function createElement(tag) {
  45. return document.createElementNS(tag === 'svg' ? 'http://www.w3.org/2000/svg' : 'http://www.w3.org/1999/xhtml', tag)
  46. }
  47.  
  48. function execute(i, url, selectorAll, foreach) {
  49. if (domainName[i] === url) {
  50. document.querySelectorAll(selectorAll).forEach(foreach);
  51. return true;
  52. }
  53. return false;
  54. }
  55.  
  56. execute(1, "curseforge", 'a[href*="/linkout"]', changeHref("remoteUrl"))
  57. || execute(1, "youtube", 'a[href*="/redirect"]', changeHref("q"))
  58. || execute(0, "github", '.Box-sc-g0xbh4-0.iiAnVG span[data-testid="compare-text"]:not(:has(a))', function(s) {
  59. const href = "compare/" + s.lastChild.textContent;
  60. const a = createElement('a');
  61. a.href = href;
  62. a.innerHTML = s.lastChild.textContent;
  63. s.lastChild.replaceWith(a)
  64. })
  65. || execute(0, "twitter", 'a[href*="t.co/"]', function(a) {
  66. if (a.innerHTML.startsWith('<span')) {
  67. a.href = a.innerHTML = a.innerText.replace(/…$/, '');
  68. }
  69. })
  70. };
  71.  
  72. function runWhenReady(callback) {
  73. const tryNow = function() {
  74. try {
  75. callback();
  76. } catch { }
  77. setTimeout(tryNow, 250);
  78. };
  79. tryNow();
  80. }
  81.  
  82. runWhenReady(run);

QingJ © 2025

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