forked from tastytea/userscripts
Added NPR text only.
This commit is contained in:
parent
ea0ac347f0
commit
cf030b1593
|
@ -0,0 +1,51 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name NPR text only
|
||||||
|
// @description Redirects to the privacy respecting, text-only version of articles on npr.org and limits the text-width to 80 characters.
|
||||||
|
// @description:de Leitet auf die datenschutzfreundliche, nur-text version von artikeln auf npr.org weiter und beschränkt die text-breite auf 80 zeichen.
|
||||||
|
// @version 2019.07.06.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/news/npr_text_only.user.js
|
||||||
|
// @grant GM_addStyle
|
||||||
|
// @match https://*.npr.org/*
|
||||||
|
// @run-at document-start
|
||||||
|
// @inject-into content
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
function main()
|
||||||
|
{
|
||||||
|
if (window.location.href.startsWith("https://text.npr.org"))
|
||||||
|
{
|
||||||
|
add_css();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
redirect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect()
|
||||||
|
{
|
||||||
|
const re = new RegExp('npr\.org/[0-9]{4}/[0-9]{2}/[0-9]{2}/([0-9]+)/');
|
||||||
|
const result = re.exec(window.location.href);
|
||||||
|
|
||||||
|
if (result !== null && result.length > 1)
|
||||||
|
{
|
||||||
|
window.location.assign("https://text.npr.org/s.php?sId=" + result[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.error("Could not find sId.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_css()
|
||||||
|
{
|
||||||
|
GM_addStyle("p { max-width: 80ch; }"); // jshint ignore:line
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
|
@ -2,7 +2,7 @@
|
||||||
// @name ARD download button
|
// @name ARD download button
|
||||||
// @description Adds a download-button for every video on ardmediathek.de.
|
// @description Adds a download-button for every video on ardmediathek.de.
|
||||||
// @description:de Fügt einen download-button für jedes video auf ardmediathek.de hinzu.
|
// @description:de Fügt einen download-button für jedes video auf ardmediathek.de hinzu.
|
||||||
// @version 2019.06.22.11
|
// @version 2019.06.22.12
|
||||||
// @author tastytea
|
// @author tastytea
|
||||||
// @copyright 2019, tastytea (https://tastytea.de/)
|
// @copyright 2019, tastytea (https://tastytea.de/)
|
||||||
// @license GPL-3.0-only
|
// @license GPL-3.0-only
|
||||||
|
@ -36,10 +36,10 @@ function main()
|
||||||
|
|
||||||
function get_url() // Extract URL from HTML.
|
function get_url() // Extract URL from HTML.
|
||||||
{
|
{
|
||||||
const html = document.getElementsByTagName('html')[0].innerHTML;
|
const html = document.documentElement.innerHTML;
|
||||||
const re_mp4 = new RegExp('"(https:)?(//[^",]+\.mp4)"', 'g');
|
const re_mp4 = new RegExp('"(https:)?(//[^",]+\.mp4)"', 'g');
|
||||||
|
|
||||||
let result = [...html.matchAll(re_mp4)];
|
const result = [...html.matchAll(re_mp4)];
|
||||||
if (result !== null)
|
if (result !== null)
|
||||||
{ // Return the last match.
|
{ // Return the last match.
|
||||||
return "https:" + result[result.length - 1][2];
|
return "https:" + result[result.length - 1][2];
|
||||||
|
|
Loading…
Reference in New Issue