This is the code I used in greasmonkey to download the zip file from the location specified by url in the @include statement.
// ==UserScript== // @name zipexport // @namespace refresh page // @include https://control.com/export.php // @version 1 // @grant none // ==/UserScript== var timerVar= setInterval(function() {DoMeEverySecond (); }, 60000); function DoMeEverySecond () { setInterval('window.location.reload()',10000); $(document).ready(function() { setTimeout(function(){ document.getElementsByClassName("btn btn-lg btn-primary")[0].click(); }, 1000);}); }
To understand, please go through this.
// @include https://control.com/export.php
Use the link to the source page here
setInterval(function() {DoMeEverySecond (); }, 60000);
Helps you call the DoMeEverySecond () function; after 60,000 ms (60 s = 1 min)
setInterval('window.location.reload()',10000);
Used to reload the page every 10 seconds. It is used by me only to ensure that the web page is updated to the last state (I had a download file that was updated every hour). You can avoid it if you do not need it.
$(document).ready(function()
function () is only called after a full reload of the web page, if we use this statement.
document.getElementsByClassName("btn btn-lg btn-primary")[0].click();
getElementsByClassName / getElementsById etc. can be used here, based on what can point to the file you want to download (use the check item by right-clicking on the source page to find out if any of the / id class can point to your zip file)
[0] can help you if you have several variables to call in the same class.
click()
clicks on the specified element (this should help to download the file)