LUModder

New Curseforge get modpack download links

Jun 26th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Curse-No-Twitch-Launcher
  3. // @namespace
  4. // @match https://www.curseforge.com/minecraft/*
  5. // @grant none
  6. // ==/UserScript==
  7. // script source: https://old.reddit.com/r/feedthebeast/comments/c5t2xv/curseforge_has_changed/es44856/
  8.  
  9. // lazy but idc rn
  10. var btnInner = `<span class="button__text"><svg class="icon icon-margin" viewBox="0 0 20 20" width="18" height="18"><use xlink:href="/Content/2-0-7116-38081/Skins/CurseForge/images/twitch/Action/Download.svg#Action/Download"></use></svg> Download</span>`;
  11.  
  12. var anchors = document.querySelectorAll('a.button');
  13.  
  14. for(var i=0; i < anchors.length; i++){
  15.     var btn = anchors[i]
  16.     var link = btn.href;
  17.     if (link.includes("?client=y")) {
  18.         if (btn.parentNode.parentNode.children.length > 1) { //cleanup mod buttons
  19.             btn.parentNode.parentNode.removeChild(btn.parentNode);
  20.         }else{ //otherwise assume modpack and just restyle the button
  21.             btn.href = link.replace(/\?client=y/, "?client=n");
  22.             btn.className = "button button--hollow";
  23.             btn.innerHTML = btnInner;
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment