-
-
Save ErkHal/f15af2b62732bb7ac13c3add78a1375d to your computer and use it in GitHub Desktop.
// ==UserScript== | |
// @name Thingiverse speed downloader | |
// @namespace http://tampermonkey.net/ | |
// @version 0.4 | |
// @description Just straight up download the .zip and not having to wait for 5 secs or be stopped by anti-adblock. Thanks to Deses, scoutman57, kohrar and quantumfrost for updates ! | |
// @author ErkHal | |
// @include https://www.thingiverse.com/thing:* | |
// @exclude https://www.thingiverse.com/thing:*/edit* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant none | |
// ==/UserScript== | |
// UPDATE THESE SELECTORS IF THIS SCRIPT DOESN'T WORK ANYMORE | |
const BUTTON_SELECTOR = '#react-app > div > div > div.Layout__content--H4y81.ThingPage__thingPage--j9upp > div.ThingPage__thingPageContentWrapper--qHQro > div.ThingPage__thingPageContent--gMLfM > div.Card__card--k0alX.flex.flex--column.flex-gap--md > div.DetailPageTitle__thingTitle--WCfWi > button.um-button.um-button--primary.um-button--icon-right.um-button--rounded.Button__button--vu8l5.Button__large--r5Q9z'; | |
const MODAL_SELECTOR = 'body > div.ReactModalPortal > div > div'; | |
const MODAL_BG_SELECTOR = 'body > div.ReactModalPortal > div'; | |
// EDIT THESE TO STYLE THE DOWNLOAD BUTTON | |
const DOWNLOAD_BUTTON_TEXT = 'DOWNLOAD FILES'; | |
const DOWNLOAD_BUTTON_STYLES = `-webkit-box-direction: normal; | |
-webkit-box-align: center; | |
-webkit-box-pack: center; | |
-webkit-font-smoothing: antialiased; | |
align-items: center; | |
appearance: none; | |
border: 2px solid transparent; | |
display: inline-flex; | |
font: inherit; | |
justify-content: center; | |
margin: 0; | |
outline: 2px solid transparent; | |
text-decoration: none; | |
user-select: none; | |
white-space: nowrap; | |
background-color: #196ef0; | |
color: #fff; | |
flex-shrink: 0; | |
outline-offset: -2px; | |
transition: background-color .15s ease-in-out,color .15s ease-in-out,outline-color .15s ease-in-out,border-color .15s ease-in-out; | |
cursor: pointer; | |
border-radius: 36px; | |
min-height: 48px; | |
min-width: 48px; | |
padding: 10px 22px; | |
font-weight: bold` | |
//Wait for elements to appear on page | |
waitForKeyElements(BUTTON_SELECTOR, noBullshit); | |
function noBullshit() { | |
'use strict'; | |
const downloadElement = document.querySelector(BUTTON_SELECTOR); | |
const downloadElementText = downloadElement.querySelector('span'); | |
const newBtnText = document.createTextNode('GET IT'); | |
downloadElementText.textContent = 'GET IT'; | |
var URL = window.location.href; | |
//Checking if we're on the Details tab or somewhere else | |
if(URL.split("/").length - 1 > 3) { | |
URL = URL.substring(0, URL.lastIndexOf("/")); | |
} | |
const downloadZip = () => { | |
window.location.href = URL + '/zip' | |
} | |
// Create new download button | |
const newDownloadBtn = document.createElement('button'); | |
newDownloadBtn.addEventListener("click", downloadZip); | |
newDownloadBtn.style = DOWNLOAD_BUTTON_STYLES; | |
newDownloadBtn.textContent = DOWNLOAD_BUTTON_TEXT; | |
// Replace the original button | |
downloadElement.replaceWith(newDownloadBtn); | |
}; |
@Deses that solution appears to work. Do you want recognition on the description of this script ? I will push the fixed version soon :)
Nice! I see you've given it the extra time I didn't have and resolved the problem for all the cases. Excellent work!
About the recognition, sure, why not. :)
Thank you!
This is coming in very handy now that thingiverse seems to have taken additional steps against adblockers and firefox's enhanced tracking protection feature.
@sreinwald Glad to help !
Very minor, but you can remove duplicate code
//Checking if we're on the Details tab or somewhere else
if(URL.split("/").length - 1 > 3) {
URL = URL.substring(0, URL.lastIndexOf("/"));
downloadElement.href = URL + '/zip'
} else {
downloadElement.href = URL + '/zip'
}
to
//Checking if we're on the Details tab or somewhere else
if(URL.split("/").length - 1 > 3) {
URL = URL.substring(0, URL.lastIndexOf("/"));
}
downloadElement.href = URL + '/zip'
they changed the layout slightly so the old code does not work..
// ==UserScript==
// @name Thingiverse speed downloader
// @namespace http://tampermonkey.net/
// @Version 0.2
// @description Just straight up download the .zip and not having to wait for 5 secs or be stopped by anti-adblock. Thanks to Deses for reporting a bug in the script and suggesting fixes !
// @author ErkHal
// @match https://www.thingiverse.com/thing:*
// @exclude https://www.thingiverse.com/thing:*/edit*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// ==/UserScript==
waitForKeyElements ("div.SidebarMenu__sideMenuTop--3xCYh > button", noBullshit);
function noBullshit() {
'use strict';
const downloadElement = document.querySelector('div.SidebarMenu__sideMenuTop--3xCYh > button');
var URL = window.location.href;
//Checking if we're on the Details tab or somewhere else
if(URL.split("/").length - 1 > 3) {
URL = URL.substring(0, URL.lastIndexOf("/"));
}
downloadElement.onclick=function() {
window.location.href = URL + '/zip'
};
downloadElement.innerHTML = '<div class="button button-primary">DOWNLOAD ZIP</div>'
};
@scoutman57 Thanks for the fix; it works for me.
Here's the updated script formatted properly for any one else needing it. I included @idle-user's change too.
// ==UserScript==
// @name Thingiverse speed downloader
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Just straight up download the .zip and not having to wait for 5 secs or be stopped by anti-adblock. Thanks to Deses for reporting a bug in the script and suggesting fixes !
// @author ErkHal
// @include https://www.thingiverse.com/thing:*
// @exclude https://www.thingiverse.com/thing:*/edit*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// ==/UserScript==
waitForKeyElements ("div.SidebarMenu__sideMenuTop--3xCYh > button", noBullshit);
function noBullshit() {
'use strict';
const downloadElement = document.querySelector('div.SidebarMenu__sideMenuTop--3xCYh > button');
var URL = window.location.href;
//Checking if we're on the Details tab or somewhere else
if(URL.split("/").length - 1 > 3) {
URL = URL.substring(0, URL.lastIndexOf("/"));
}
downloadElement.onclick=function() {
window.location.href = URL + '/zip'
};
downloadElement.innerHTML = '<div class="button button-primary">DOWNLOAD</div>'
};
Thanks @scoutman57 and @kohrar, I've updated the gist with your inputs and mentioned you guys in the description :)
They've changed the div name again, here's the new code that works:
// ==UserScript==
// @name Thingiverse speed downloader
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Just straight up download the .zip and not having to wait for 5 secs or be stopped by anti-adblock. Thanks to Deses, scoutman57 and kohrar for updates !
// @author ErkHal
// @include https://www.thingiverse.com/thing:*
// @exclude https://www.thingiverse.com/thing:*/edit*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// ==/UserScript==
waitForKeyElements ("div.SidebarMenu__sideMenuTop--vJNxy > button", noBullshit);
function noBullshit() {
'use strict';
const downloadElement = document.querySelector('div.SidebarMenu__sideMenuTop--vJNxy > button');
var URL = window.location.href;
//Checking if we're on the Details tab or somewhere else
if(URL.split("/").length - 1 > 3) {
URL = URL.substring(0, URL.lastIndexOf("/"));
}
downloadElement.onclick=function() {
window.location.href = URL + '/zip'
};
downloadElement.innerHTML = '<div class="button button-primary">DOWNLOAD</div>'
};
@quantumfrost updated, thx ! <3
UPDATE 18.10.2023: Simplified the code: now the button is just replaced with a new one with completely different event listener, since the the updated pages now still displayed the modal and also triggered the download. Now the modal as well as the download countdown etc. is completely ignored !
Also added the selectors and the styling to the top of the userscript, so these are easier to update once Thingiverse changes these again. You can also now customize the text to your liking if you want !
If you are in
/files
,/comments
,/makes
and so on and you click the DOWNLOAD button, it results in a 404 error because it appends /zip to the url and/files/zip
doesn't exist.What the script should do is check if you are not in the details page and remove the last part of the url and then append /zip.
That would work for all pages except the Details page.