2019-07-04 15:20:54 +02:00
|
|
|
// ==UserScript==
|
|
|
|
// @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.
|
2022-07-17 12:33:09 +02:00
|
|
|
// @version 2022.07.17.1
|
2019-07-04 15:20:54 +02:00
|
|
|
// @author tastytea
|
2022-07-17 12:33:09 +02:00
|
|
|
// @copyright 2019, 2021, 2022, tastytea (https://tastytea.de/)
|
2019-07-04 15:20:54 +02:00
|
|
|
// @license GPL-3.0-only
|
|
|
|
// @namespace tastytea.de
|
|
|
|
// @homepageURL https://schlomp.space/tastytea/userscripts
|
|
|
|
// @supportURL https://schlomp.space/tastytea/userscripts/issues
|
|
|
|
// @downloadURL https://schlomp.space/tastytea/userscripts/raw/branch/main/audio/dlf_download_button.user.js
|
|
|
|
// @grant none
|
|
|
|
// @match https://*.deutschlandradio.de/*
|
|
|
|
// @match https://*.deutschlandfunkkultur.de/*
|
|
|
|
// @match https://*.deutschlandfunknova.de/*
|
|
|
|
// @run-at document-end
|
|
|
|
// @inject-into content
|
|
|
|
// ==/UserScript==
|
|
|
|
|
2022-07-17 12:33:09 +02:00
|
|
|
function dlf_us_main()
|
2019-07-04 15:20:54 +02:00
|
|
|
{
|
|
|
|
// deutschlandradio.de, deutschlandfunkkultur.de
|
|
|
|
let root = document.getElementsByClassName("player-embed")[0];
|
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
add_button(root.getAttribute("data-audio-src"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// deutschlandfunknova.de
|
|
|
|
root = document.getElementsByClassName("button--play")[0];
|
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
add_button(root.getAttribute("data-mp3"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-17 12:33:09 +02:00
|
|
|
// share.deutschlandradio.de
|
|
|
|
root = document.getElementsByClassName("b-btn-player")[1];
|
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
add_button(root.getAttribute("data-audioreference"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-04 15:20:54 +02:00
|
|
|
console.warn("Could not find player / download-button element.");
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_button(url)
|
|
|
|
{
|
|
|
|
const button = document.createElement("a");
|
|
|
|
button.setAttribute("id", "tastytea_downloadbutton");
|
|
|
|
button.setAttribute("href", url);
|
|
|
|
button.appendChild(document.createTextNode("Download"));
|
|
|
|
|
|
|
|
// Change appearance based on site.
|
2019-07-11 18:15:07 +02:00
|
|
|
if (window.location.href.search("deutschlandradio.de") > 0)
|
2019-07-04 15:20:54 +02:00
|
|
|
{
|
|
|
|
button.style.fontSize = "150%";
|
|
|
|
button.style.fontWeight = "bold";
|
|
|
|
button.style.color = "black";
|
|
|
|
}
|
2019-07-11 18:15:07 +02:00
|
|
|
else if (window.location.href.search("deutschlandfunkkultur.de") > 0)
|
2019-07-04 15:20:54 +02:00
|
|
|
{
|
2021-06-19 17:36:35 +02:00
|
|
|
button.style.fontWeight = "bold";
|
2019-07-04 15:20:54 +02:00
|
|
|
}
|
|
|
|
button.style.textDecoration = "underline";
|
|
|
|
|
|
|
|
// deutschlandradio.de
|
|
|
|
let root = document.getElementsByClassName("div-top-sub-container")[0];
|
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
root.appendChild(button);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// deutschlandfunkkultur.de
|
|
|
|
root = document.getElementsByClassName("drk-articleplay")[0];
|
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
root.parentElement.insertBefore(button, root);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// deutschlandfunknova.de
|
2021-04-29 13:51:46 +02:00
|
|
|
root = document.getElementsByClassName("podcast--buttons")[0];
|
2019-07-04 15:20:54 +02:00
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
root.parentElement.insertBefore(button, root);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-17 12:33:09 +02:00
|
|
|
// share.deutschlandradio.de
|
|
|
|
root = document.getElementsByClassName("b-audio-player-wrapper")[0];
|
|
|
|
if (root !== undefined)
|
|
|
|
{
|
|
|
|
root.parentElement.insertBefore(button, root);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-04 15:20:54 +02:00
|
|
|
console.warn("Could not find root element.");
|
|
|
|
}
|
|
|
|
|
2022-07-17 12:33:09 +02:00
|
|
|
dlf_us_main();
|