ard_download_button: Run forever.

This commit is contained in:
tastytea 2019-06-22 05:15:58 +02:00
parent 4f23f2514e
commit d4bdea2f3b
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 4 additions and 10 deletions

View File

@ -2,7 +2,7 @@
// @name ARD download button // @name ARD download button
// @description Adds a download-button for every video on ardmediathek.de. // @description Adds a download-button for every video on ardmediathek.de.
// @description:de Fügt einen download-button für jedes video auf ardmediathek.de hinzu. // @description:de Fügt einen download-button für jedes video auf ardmediathek.de hinzu.
// @version 2019.06.22.9 // @version 2019.06.22.10
// @author tastytea // @author tastytea
// @copyright 2019, tastytea (https://tastytea.de/) // @copyright 2019, tastytea (https://tastytea.de/)
// @license GPL-3.0-only // @license GPL-3.0-only
@ -16,19 +16,13 @@
// @inject-into content // @inject-into content
// ==/UserScript== // ==/UserScript==
let interval;
let counter = 0;
function main() function main()
{ {
// Stop if button is already there or after 10 tries. // Stop if button is already there.
if (document.getElementById("tastytea_downloadbutton") !== null if (document.getElementById("tastytea_downloadbutton") !== null)
|| counter >= 10)
{ {
clearInterval(interval);
return; return;
} }
++counter;
const url = get_url(); const url = get_url();
if (url === null) if (url === null)
@ -82,4 +76,4 @@ function add_button(url)
root.appendChild(div); root.appendChild(div);
} }
interval = setInterval(main, 2000); setInterval(main, 2000); // The script is not restarted when clicking on a link.