Added ndr.de HD button.

This commit is contained in:
tastytea 2019-06-14 00:04:49 +02:00
parent 0456ef4246
commit 131609bfe4
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,57 @@
// ==UserScript==
// @name ndr.de HD button
// @description Adds a download-button for the HD-version of the video.
// @description:de Fügt einen download-button für die HD-version des videos hinzu.
// @version 2019.06.14.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/video/ndr_hd_button.user.js
// @grant none
// @match https://*.ndr.de/*
// @run-at document-end
// @inject-into content
// ==/UserScript==
function get_video_url()
{
const element = document.querySelector('[itemprop=contentUrl]');
return element.getAttribute("content").replace("hq.mp4", "hd.mp4");
}
function add_button(parent, url)
{
const button = document.createElement("a");
button.setAttribute("class", "button download");
button.setAttribute("href", url);
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);
button.appendChild(document.createTextNode("Download HD"));
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();