2019-06-14 00:04:49 +02:00
|
|
|
// ==UserScript==
|
2019-06-17 12:56:51 +02:00
|
|
|
// @name NDR download button
|
|
|
|
// @description Adds a download-button for every video and audio on ndr.de.
|
|
|
|
// @description:de Fügt einen download-button für jedes videos und audio auf ndr.de hinzu.
|
2019-06-17 13:47:21 +02:00
|
|
|
// @version 2019.06.17.3
|
2019-06-14 00:04:49 +02:00
|
|
|
// @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
|
2019-06-17 12:56:51 +02:00
|
|
|
// @downloadURL https://schlomp.space/tastytea/userscripts/raw/branch/main/video/ndr_download_button.user.js
|
2019-06-14 00:04:49 +02:00
|
|
|
// @grant none
|
|
|
|
// @match https://*.ndr.de/*
|
|
|
|
// @run-at document-end
|
|
|
|
// @inject-into content
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
function get_video_url()
|
|
|
|
{
|
|
|
|
const element = document.querySelector('[itemprop=contentUrl]');
|
2019-06-17 12:56:51 +02:00
|
|
|
let url = element.getAttribute("content");
|
2019-06-17 13:05:50 +02:00
|
|
|
if (url.search("/TV-") > -1) // Upgrade Videos to HD.
|
2019-06-17 12:56:51 +02:00
|
|
|
{
|
|
|
|
url = url.replace("hq.mp4", "hd.mp4");
|
|
|
|
}
|
2019-06-17 13:05:50 +02:00
|
|
|
else if (url.search("/AU-") > -1) // The advertised MP4 file does not exist.
|
|
|
|
{
|
|
|
|
url = url.replace("hq.mp4", "mp3");
|
|
|
|
}
|
2019-06-17 12:56:51 +02:00
|
|
|
|
|
|
|
return url;
|
2019-06-14 00:04:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function add_button(parent, url)
|
|
|
|
{
|
2019-06-17 12:56:51 +02:00
|
|
|
let buttontext = "Download";
|
|
|
|
if (url.search("hd.mp4") > -1)
|
|
|
|
{
|
|
|
|
buttontext += " HD";
|
|
|
|
}
|
2019-06-17 13:47:21 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// If there is already an equivalent download-button, do nothing.
|
|
|
|
if (document.getElementsByClassName("button download").length > 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-06-17 12:56:51 +02:00
|
|
|
|
2019-06-14 00:04:49 +02:00
|
|
|
const button = document.createElement("a");
|
|
|
|
button.setAttribute("class", "button download");
|
|
|
|
button.setAttribute("href", url);
|
2019-06-14 00:26:38 +02:00
|
|
|
// Needed for shine effect
|
|
|
|
button.setAttribute("style", "position: relative;");
|
2019-06-14 00:04:49 +02:00
|
|
|
|
|
|
|
const spanshine = document.createElement("span");
|
|
|
|
spanshine.setAttribute("class", "buttonshine");
|
|
|
|
button.appendChild(spanshine);
|
|
|
|
|
|
|
|
const spandl = document.createElement("span");
|
|
|
|
spandl.setAttribute("class", "icon icon_download");
|
|
|
|
button.appendChild(spandl);
|
|
|
|
|
2019-06-17 12:56:51 +02:00
|
|
|
button.appendChild(document.createTextNode(buttontext));
|
2019-06-14 00:04:49 +02:00
|
|
|
|
|
|
|
parent.appendChild(button);
|
|
|
|
}
|
|
|
|
|
|
|
|
function main()
|
|
|
|
{
|
|
|
|
const functions = document.getElementsByClassName("functions");
|
|
|
|
if (functions.length > 0)
|
|
|
|
{
|
|
|
|
const url = get_video_url();
|
|
|
|
if (url !== "")
|
|
|
|
{
|
|
|
|
add_button(functions[0], url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|