From 54ab9e31b9d7ff7d2892910a8034329243cd8b52 Mon Sep 17 00:00:00 2001 From: Rushil Srivastava Date: Fri, 8 Feb 2019 19:52:50 -0800 Subject: [PATCH] full updates for 0.19.2 --- README.md | 4 +--- manifest.json | 5 ++--- src/js/background.js | 2 +- src/js/ft.js | 15 --------------- src/js/wsj.js | 41 +++++++++++++---------------------------- 5 files changed, 17 insertions(+), 50 deletions(-) delete mode 100644 src/js/ft.js diff --git a/README.md b/README.md index 839f155..9216596 100755 --- a/README.md +++ b/README.md @@ -21,10 +21,8 @@ I made this because as a student, it isn't practical for me to pay each company 5. Enjoy! 6. The extension should automagically update, but you can also manually update by clicking the `Update` button on the Extensions page `chrome://extensions`. -### Broken integrations -* [Wall Street Journal](https://www.wsj.com/) - ### Supported Tested Websites: +* [Wall Street Journal](https://www.wsj.com/) * [New York Times](https://www.nytimes.com/) * [Cooking New York Times](https://cooking.nytimes.com/) * [Financial Times](https://www.ft.com/) diff --git a/manifest.json b/manifest.json index 3509fb3..b85d02f 100755 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "News Paywall Blocker by OpenNews", - "version": "0.19.1", + "version": "0.19.2", "manifest_version": 2, "description": "Experience a brand new FREE browsing experience bypassing pesky cookie Paywalls!", "author": "Rushil Srivastava", @@ -29,7 +29,6 @@ { "matches": ["https://www.ft.com/*"], "css": ["src/css/ft.css"], - "js": ["src/js/arrive.min.js", "src/js/ft.js"], "run_at": "document_start" }, { @@ -39,7 +38,7 @@ }, { "matches": ["https://www.wsj.com/*"], - "js": ["src/js/arrive.min.js", "src/js/wsj.js"], + "js": ["src/js/wsj.js"], "run_at": "document_start" } ], diff --git a/src/js/background.js b/src/js/background.js index 8772d02..f4a1dfd 100755 --- a/src/js/background.js +++ b/src/js/background.js @@ -152,7 +152,7 @@ var cookieBasedURLs = Object.values(sites) }) .map(site => site.url); -// add firefox and edge support with the global `browser` object +// add firefox and edge support with the global `browser` object #5 browser = typeof browser !== "undefined" ? browser : chrome; // script blocking diff --git a/src/js/ft.js b/src/js/ft.js deleted file mode 100644 index f779b6b..0000000 --- a/src/js/ft.js +++ /dev/null @@ -1,15 +0,0 @@ -document.arrive("body > script", function() { - let script = this.innerHTML; - if (script.includes("window.FT.flags")) { - console.log("Disabling Paywall on FT.com"); - var flags = script.substring(script.lastIndexOf("window.FT.flags = ") + 18, script.lastIndexOf("window.FT.nUiConfig = ")); - flags = flags.replace(/ /g, '').replace(/;/g, '') - flags = JSON.parse(flags); - flags["disablePaywall"] = true; - flags["ads"] = false; - flags["adTargetingUserApi"] = false; - flags = "window.FT.flags = " + JSON.stringify(flags) + ";"; - script = script.substring(0, script.lastIndexOf("window.FT.flags = ")) + flags + script.substring(script.lastIndexOf("window.FT.nUiConfig = ")) - this.innerHTML = script; - } -}); \ No newline at end of file diff --git a/src/js/wsj.js b/src/js/wsj.js index d1f665c..990a5a7 100644 --- a/src/js/wsj.js +++ b/src/js/wsj.js @@ -1,28 +1,13 @@ -console.log("Disabling Paywall on WSJ.com"); -// edit meta data -document.arrive('meta[name="cx_shield"]', function() { - this.setAttribute("content", "{\"campaign\":2000,\"placement\":\"cx-articlecover\", \"tag\":\"default\", \"type\":\"free\"}"); -}); -// make free article in first meta JSON -document.arrive('script[type="application/ld+json"]', function() { - let data = JSON.parse(this.innerHTML); - data["isAccessibleForFree"] = "true"; - data["hasPart"]["isAccessibleForFree"] = "true"; - this.innerHTML = JSON.stringify(data); -}); -// make free article in second meta JSON -document.arrive('#article_body > script[type="text/javascript"]', function() { - let script = this.innerHTML; - if (script.includes("var utag_data =")) { - console.log("found") - let data = JSON.parse(script.replace("var utag_data =", '').replace(/ /g, '').replace(/;/g, '')) - data["page_access"] = "free"; - data["cx_shield"] = { - "campaign": 2000, - "placement": "cx-articlecover", - "tag": "default", - "type": "free" - }; - this.innerHTML = "var utag_data = " + JSON.stringify(data) + ";"; - } -}); \ No newline at end of file +var url = window.location.href; +var redirect = true; + +if (url.indexOf('?mod=rsswn') != -1) + redirect = false; +else if (url.indexOf('&mod=rsswn') != -1) + redirect = false; + +// redirect +if (redirect) { + console.log("Disabling Paywall on " + window.location.pathname); + window.location = '//' + location.host + location.pathname + '?mod=rsswn'; +}