XenoTheStrange

Skip Extra Pages When Updating Chocolate Minecraft Mods

Aug 30th, 2021 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Xaero's Mods Auto Download Latest Fabric
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  When minecraft opens the Chocolate MC mod update page, this will automatically download the latest fabric version for that mod.
  6. // @author       XenoTheStrange
  7. // @match        https://chocolateminecraft.com/*.php
  8. // @exclude      https://chocolateminecraft.com/index.php
  9. // @match        https://chocolateminecraft.com/update.php?mod_id=*
  10. // @icon         https://www.google.com/s2/favicons?domain=chocolateminecraft.com
  11. // @grant        none
  12. // ==/UserScript==
  13.  
  14. //HELLO THERE.
  15. //On a page like this one: https://chocolateminecraft.com/betterpvp2.php
  16. //This script will skip to the download page and immediately download the latest file for the version selected below
  17. //for forge, change "fabric" in "var version" below to "forge"
  18.  
  19. (function() {
  20.     'use strict';
  21.     //change this to forge to get forge instead
  22.     var version = "fabric"
  23.    
  24.     //if this appears to be a mod page, skip forward.
  25.     if (document.location.href.indexOf("https://chocolateminecraft.com/update.php?mod_id=") !== -1){
  26.         document.location = document.getElementsByClassName("big_link")[0]?.parentElement.href
  27.     }
  28.     //if the page contains download buttons, go to those pages
  29.     if (document.getElementsByClassName("DownloadButton").length !== 0){
  30.             document.location = document.getElementsByClassName("DownloadButton")[0]?.href
  31.         }
  32.     if (document.getElementsByClassName("DownloadFullButton").length !== 0){
  33.         document.location = document.getElementsByClassName("DownloadFullButton")[0]?.href
  34.     }
  35.     //if the page contains a table that looks like a version table for downloads, do this
  36.     if (document.getElementsByTagName("tbody")[0]?.children[1]?.children[0]?.innerText == "Version"){
  37.         var tbKids = document.getElementsByTagName("tbody")[0].children;
  38.         for (var i=2;i<8;i++){
  39.             //if entry contains fabric, it is the newest version, open a window containing the jar url instead of the bitly url.
  40.             if (tbKids[i].children[2].innerText.toLowerCase().indexOf(version) !== -1){
  41.                 let linkElement = tbKids[i].children[3].children[0]
  42.                 if (linkElement.href.split("url=").length !== 0){
  43.                     linkElement.href = linkElement.href.split("url=")[1]
  44.                 }
  45.                 linkElement.click()
  46.                 break;
  47.                 }
  48.             }
  49.         }
  50.     // Your code here...
  51. })()
Add Comment
Please, Sign In to add comment