aboutsummaryrefslogtreecommitdiffstats
path: root/npr-text-mode-redirect.user.js
diff options
context:
space:
mode:
Diffstat (limited to 'npr-text-mode-redirect.user.js')
-rw-r--r--npr-text-mode-redirect.user.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/npr-text-mode-redirect.user.js b/npr-text-mode-redirect.user.js
new file mode 100644
index 0000000..026f8c4
--- /dev/null
+++ b/npr-text-mode-redirect.user.js
@@ -0,0 +1,19 @@
+// ==UserScript==
+// @name NPR Text Mode Redirect
+// @description Redirect to the site's text mode
+// @namespace com.teddywing
+// @match https://choice.npr.org/*
+// ==/UserScript==
+
+
+var location = document.location;
+
+// Get the article ID from the URL.
+// Example:
+// https://choice.npr.org/index.html?origin=https://www.npr.org/2018/07/20/630792401/sleep-scientist-warns-against-walking-through-life-in-an-underslept-state
+// The article ID is `630792401`
+var params = new URLSearchParams(location.search.substring(1));
+var redirect_url = params.get('origin');
+var article_id = redirect_url.split('/')[6];
+
+location.assign('https://text.npr.org/s.php?sId=' + article_id);