Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Xaero's Mods Auto Download Latest Fabric
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description When minecraft opens the Chocolate MC mod update page, this will automatically download the latest fabric version for that mod.
- // @author XenoTheStrange
- // @match https://chocolateminecraft.com/*.php
- // @exclude https://chocolateminecraft.com/index.php
- // @match https://chocolateminecraft.com/update.php?mod_id=*
- // @icon https://www.google.com/s2/favicons?domain=chocolateminecraft.com
- // @grant none
- // ==/UserScript==
- //HELLO THERE.
- //On a page like this one: https://chocolateminecraft.com/betterpvp2.php
- //This script will skip to the download page and immediately download the latest file for the version selected below
- //for forge, change "fabric" in "var version" below to "forge"
- (function() {
- 'use strict';
- //change this to forge to get forge instead
- var version = "fabric"
- //if this appears to be a mod page, skip forward.
- if (document.location.href.indexOf("https://chocolateminecraft.com/update.php?mod_id=") !== -1){
- document.location = document.getElementsByClassName("big_link")[0]?.parentElement.href
- }
- //if the page contains download buttons, go to those pages
- if (document.getElementsByClassName("DownloadButton").length !== 0){
- document.location = document.getElementsByClassName("DownloadButton")[0]?.href
- }
- if (document.getElementsByClassName("DownloadFullButton").length !== 0){
- document.location = document.getElementsByClassName("DownloadFullButton")[0]?.href
- }
- //if the page contains a table that looks like a version table for downloads, do this
- if (document.getElementsByTagName("tbody")[0]?.children[1]?.children[0]?.innerText == "Version"){
- var tbKids = document.getElementsByTagName("tbody")[0].children;
- for (var i=2;i<8;i++){
- //if entry contains fabric, it is the newest version, open a window containing the jar url instead of the bitly url.
- if (tbKids[i].children[2].innerText.toLowerCase().indexOf(version) !== -1){
- let linkElement = tbKids[i].children[3].children[0]
- if (linkElement.href.split("url=").length !== 0){
- linkElement.href = linkElement.href.split("url=")[1]
- }
- linkElement.click()
- break;
- }
- }
- }
- // Your code here...
- })()
Add Comment
Please, Sign In to add comment