Redirect Old Links

No more "Module Disabled"!

  1. // ==UserScript==
  2. // @name Redirect Old Links
  3. // @version 0.3
  4. // @description No more "Module Disabled"!
  5. // @author comp500
  6. // @namespace https://infra.link/
  7. // @match https://minecraft.curseforge.com/mc-mods/*
  8. // @homepageURL https://github.com/comp500/Curseforge-Userscripts/
  9. // @supportURL https://github.com/comp500/Curseforge-Userscripts/issues/
  10. // @source https://github.com/comp500/Curseforge-Userscripts/
  11. // @run-at document-end
  12. // @grant GM_xmlhttpRequest
  13. // @connect addons-ecs.forgesvc.net
  14. // ==/UserScript==
  15.  
  16. (async function() {
  17. 'use strict';
  18.  
  19. let greaseMonkeyXHR = details => {
  20. details.method = details.method ? details.method : "GET";
  21. details.anonymous = true;
  22. details.responseType = details.responseType ? details.responseType : "arraybuffer";
  23. return new Promise((resolve, reject) => {
  24. details.onload = resolve;
  25. details.onerror = reject;
  26. GM_xmlhttpRequest(details);
  27. });
  28. };
  29.  
  30. // Match project IDs
  31. let matches = location.href.match(/https:\/\/minecraft.curseforge.com\/mc-mods\/(\d+)/);
  32. if (matches != null && matches[1] != null) {
  33. location.href = "https://www.curseforge.com/projects/" + matches[1];
  34. } else {
  35. // Match slug IDs
  36. matches = location.href.match(/https:\/\/minecraft.curseforge.com\/mc-mods\/([a-z][\da-z\-_]{1,127})\/?$/);
  37. if (matches != null && matches[1] != null) {
  38. location.href = "https://www.curseforge.com/minecraft/mc-mods/" + matches[1];
  39. }
  40. }
  41. })();