make DLF download button work on share.deutschlandradio.de

This commit is contained in:
tastytea 2022-07-17 12:33:09 +02:00
parent edd90c4c9c
commit ab22e1043b
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 20 additions and 4 deletions

View File

@ -2,9 +2,9 @@
// @name DLF download button
// @description Adds a download button for each audio file on DLF sites.
// @description:de Fügt einen download-button für jede audio-datei auf DLF-seiten hinzu.
// @version 2021.06.19.1
// @version 2022.07.17.1
// @author tastytea
// @copyright 2019, 2021, tastytea (https://tastytea.de/)
// @copyright 2019, 2021, 2022, tastytea (https://tastytea.de/)
// @license GPL-3.0-only
// @namespace tastytea.de
// @homepageURL https://schlomp.space/tastytea/userscripts
@ -18,7 +18,7 @@
// @inject-into content
// ==/UserScript==
function main()
function dlf_us_main()
{
// deutschlandradio.de, deutschlandfunkkultur.de
let root = document.getElementsByClassName("player-embed")[0];
@ -36,6 +36,14 @@ function main()
return;
}
// share.deutschlandradio.de
root = document.getElementsByClassName("b-btn-player")[1];
if (root !== undefined)
{
add_button(root.getAttribute("data-audioreference"));
return;
}
console.warn("Could not find player / download-button element.");
}
@ -83,7 +91,15 @@ function add_button(url)
return;
}
// share.deutschlandradio.de
root = document.getElementsByClassName("b-audio-player-wrapper")[0];
if (root !== undefined)
{
root.parentElement.insertBefore(button, root);
return;
}
console.warn("Could not find root element.");
}
main();
dlf_us_main();