Added dlf_download_button.
This commit is contained in:
parent
ecbf662cd3
commit
ad015f936a
|
@ -0,0 +1,89 @@
|
|||
// ==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.
|
||||
// @version 2019.07.04.1
|
||||
// @author tastytea
|
||||
// @copyright 2019, tastytea (https://tastytea.de/)
|
||||
// @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==
|
||||
|
||||
function main()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
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.
|
||||
if (window.location.href.search("deutschlandradio.de"))
|
||||
{
|
||||
button.style.fontSize = "150%";
|
||||
button.style.fontWeight = "bold";
|
||||
button.style.color = "black";
|
||||
}
|
||||
else if (window.location.href.search("deutschlandfunkkultur.de"))
|
||||
{
|
||||
button.setAttribute("class", "drk-articleplay");
|
||||
}
|
||||
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
|
||||
root = document.getElementsByClassName("meta__share")[0];
|
||||
if (root !== undefined)
|
||||
{
|
||||
root.parentElement.insertBefore(button, root);
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn("Could not find root element.");
|
||||
}
|
||||
|
||||
main();
|
Loading…
Reference in New Issue