From d54f7aa6d12eda35bd3a3315c433ce97652ed5e1 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 22 Sep 2020 21:06:28 +0200 Subject: [PATCH] Fix-update National Review (amp for plus) Plus minor update opt-in UI --- background.js | 2 +- contentScript.js | 15 +++++++++++++++ lp/manifest.json | 2 +- manifest.json | 2 +- optin/opt-in.html | 2 +- optin/opt-in.js | 23 ++++++++++------------- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/background.js b/background.js index 4890ef3..f61b214 100644 --- a/background.js +++ b/background.js @@ -197,7 +197,7 @@ var blockedRegexes = { 'mercuriovalpo.cl': /(.+\.mercuriovalpo\.cl\/impresa\/wp-content\/themes\/papel-digital-2019-desktop\/assets\/(vendor|\d)\.js|pram\.pasedigital\.cl\/API\/User\/Status\?)/, 'modernhealthcare.com': /.+\.tinypass\.com\/.+/, 'nationalgeographic.com': /.+\.blueconic\.net\/.+/, -'nationalreview.com': /.+\.blueconic\.net\/.+/, +'nationalreview.com': /(.+\.blueconic\.net\/.+|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/, 'newrepublic.com': /.+\.onecount\.net\/js\/.+/, 'newsweek.com': /.+\.googletagmanager\.com\/gtm\.js/, 'newyorker.com': /.+\.newyorker\.com\/verso\/static\/presenter-articles.+\.js/, diff --git a/contentScript.js b/contentScript.js index 490fea8..59de822 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1087,6 +1087,21 @@ else if (domain = matchDomain("businesstimes.com.sg")) { cx_custom.setAttribute('style', 'display:none'); } +else if (matchDomain("nationalreview.com")) { + document.addEventListener('DOMContentLoaded', () => { + let url = window.location.href; + let article_truncated = document.querySelector('div#article-content-truncate-wrap'); + window.setTimeout(function () { + if (article_truncated && !url.includes('/amp/')) { + if (url.includes('?')) + window.location.href = url.replace('?', 'amp/?') + else + window.location.href = url + 'amp'; + } + }, 500); // Delay (in milliseconds) + }); +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { diff --git a/lp/manifest.json b/lp/manifest.json index 83fb5bf..03e5ff6 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -309,5 +309,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.7.0" + "version": "1.8.7.1" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 4acd1e7..1faeccf 100644 --- a/manifest.json +++ b/manifest.json @@ -40,5 +40,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.7.0" + "version": "1.8.7.1" } \ No newline at end of file diff --git a/optin/opt-in.html b/optin/opt-in.html index 3aee92d..4035217 100644 --- a/optin/opt-in.html +++ b/optin/opt-in.html @@ -16,7 +16,7 @@ Boston Globe
Irish Independent
The Belfast Telegraph

-

+

SetCookie opt-in enabled:

diff --git a/optin/opt-in.js b/optin/opt-in.js index 428c21c..b131547 100644 --- a/optin/opt-in.js +++ b/optin/opt-in.js @@ -2,10 +2,9 @@ var ext_api = chrome || browser; window.addEventListener("load", function () { + var opt_in_enabled = document.getElementById('opt-in-enabled'); ext_api.storage.sync.get("optIn", function (result) { - var opt_in_enabled = document.getElementById('opt-in-enabled'); - opt_in_enabled.appendChild(document.createTextNode('SetCookie opt-in enabled: ' + (result.optIn ? 'YES' : 'NO'))); - //console.log("Setting up UI. result.optIn:" + result.optIn); + opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO'; }); document.getElementById("button-enable").addEventListener( @@ -15,7 +14,10 @@ window.addEventListener("load", function () { "optIn": true, "optInShown": true }); - window.close(); + opt_in_enabled.innerText = 'YES'; + setTimeout(function () { + window.close(); + }, 800); }); document.getElementById("button-cancel").addEventListener( @@ -25,14 +27,9 @@ window.addEventListener("load", function () { "optIn": false, "optInShown": true }); - window.close(); + opt_in_enabled.innerText = 'NO'; + setTimeout(function () { + window.close(); + }, 800); }); -/** - // set up the appearance of the popup depending on the outcome of the opt-in - ext_api.storage.sync.get("optInShown", function (result) { - console.log("Setting up UI. result.optInShown:" + result.optInShown); - document.getElementById("opt-in-prompt").hidden = result.optInShown; - document.getElementById("after-opt-in").hidden = !result.optInShown; - }); -**/ }); \ No newline at end of file