From 4344263be627f3beffaa78788c8e6e5f3ddca850 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 14 May 2020 20:58:55 +0200 Subject: [PATCH] Fix-update WSJ (timing issues) Single refresh when paywall. --- background.js | 3 --- contentScript.js | 12 ++++++++++++ lp/manifest.json | 9 ++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/background.js b/background.js index 69c6395..b5b4169 100644 --- a/background.js +++ b/background.js @@ -496,12 +496,9 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { ext_api.tabs.onUpdated.addListener(function (tabId, info, tab) { updateBadge(tab); }); ext_api.tabs.onActivated.addListener(function (activeInfo) { ext_api.tabs.get(activeInfo.tabId, updateBadge); }); -let cachedBadgeText = ''; function updateBadge (activeTab) { if (!activeTab) { return; } const badgeText = getTextB(activeTab.url); - if (cachedBadgeText === badgeText) { return; } - cachedBadgeText = badgeText; ext_api.browserAction.setBadgeBackgroundColor({color: 'red'}); ext_api.browserAction.setBadgeText({text: badgeText}); } diff --git a/contentScript.js b/contentScript.js index 6669981..72c41c5 100644 --- a/contentScript.js +++ b/contentScript.js @@ -120,6 +120,17 @@ else if (matchDomain("wsj.com")) { if (close_button) close_button.click(); } + document.addEventListener('DOMContentLoaded', () => { + let wsj_login = document.querySelector('.wsj-snippet-login'); + if (wsj_login && !window.location.hash) { + let url = window.location.href; + if (url.includes('?')) { + window.location.href = url.replace('?', '#refreshed?'); + } else { + window.location.href = url + '#refreshed'; + } + } + }); } else if (matchDomain("sloanreview.mit.edu")) { @@ -562,6 +573,7 @@ else if (matchDomain('faz.net')) { str = str.replace(/([a-z\"\“])(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n"); // exceptions: names with alternating lower/uppercase (no general fix) str = str.replace(/Glaxo\n\nSmith\n\nKline/g, "GlaxoSmithKline"); + str = str.replace(/Eu\n\nGH/g, "EuGH"); str = str.replace(/If\n\nSG/g, "IfSG"); str = str.replace(/La\n\nPierre/g, "LaPierre"); return str; diff --git a/lp/manifest.json b/lp/manifest.json index 2a62e5a..9a3791c 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -237,17 +237,20 @@ "*://*.cedsdigital.it/*", "*://*.corriereobjects.it/*", "*://*.epimg.net/*", + "*://*.htmedia.in/*", "*://*.lightboxcdn.com/*", - "*://merreader.emol.cl/*", "*://*.lp4.io/*", + "*://*.nyt.com/*", + "*://*.onecount.net/*", + "*://*.onesignal.com/*", + "*://*.qiota.com/*", "*://*.rcsobjects.it/*", "*://*.repstatic.it/*", "*://*.swisspay.ch/*", - "*://*.htmedia.in/*", - "*://*.qiota.com/*", "*://*.tribdss.com/*", "*://*.userzoom.com/*", "*://*.viralize.tv/*", + "*://merreader.emol.cl/*", "*://*.bndestem.nl/*", "*://*.bd.nl/*", "*://*.ed.nl/*",