CurseForge Downloader

Download files from curseforge directly instead of launching Twitch.

当前为 2019-06-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CurseForge Downloader
  3. // @namespace https://www.yesterday17.cn/
  4. // @version 1.0.0
  5. // @description Download files from curseforge directly instead of launching Twitch.
  6. // @author Yesterday17
  7. // @include *://www.curseforge.com/*
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. "use strict";
  12. (function() {
  13. const elements = document.querySelectorAll(
  14. '.icon.icon-margin use[*|href="/Content/2-0-7117-35996/Skins/CurseForge/images/twitch/Logo/Glitch.svg#Logo/Glitch"]'
  15. );
  16. Array.from(elements)
  17. .map(item => {
  18. let button = item;
  19. while (item.nodeName !== "A") {
  20. item = item.parentElement;
  21. }
  22. return item;
  23. })
  24. .forEach((download, index) => {
  25. // change link
  26. let link = download.getAttribute("href").replace(/\?client=y/g, "");
  27. if (/(?:\/[^\/])*?\/download\/\d+/.test(link)) {
  28. link += "/file";
  29. }
  30. download.setAttribute("href", link);
  31.  
  32. // change icon
  33. elements[index].parentElement.setAttribute("viewBox", "0 0 20 20");
  34. elements[index].setAttribute(
  35. "xlink:href",
  36. "/Content/2-0-7117-35996/Skins/CurseForge/images/twitch/Action/Download.svg#Action/Download"
  37. );
  38. });
  39. })();