From 78a4f281024b9341a6a02634a87e583ddbf30bcf Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 3 Mar 2020 18:15:21 +0100 Subject: [PATCH] Fix Repubblica.it Fix for timing-issue with redirect of weblinks on homepage. --- background.js | 12 ++++++++++++ contentScript.js | 16 ++++++++-------- popup.html | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/background.js b/background.js index 0cc3399..fd20176 100644 --- a/background.js +++ b/background.js @@ -281,6 +281,18 @@ browser.runtime.onInstalled.addListener(function (details) { } }); +// repubblica.it bypass +browser.webRequest.onBeforeRequest.addListener(function (details) { + if (!isSiteEnabled(details)) { + return; + } + var updatedUrl = details.url.replace('/pwa/', '/ws/detail/'); + return { redirectUrl: updatedUrl }; +}, +{urls:["*://*.repubblica.it/pwa/*"], types:["main_frame"]}, +["blocking"] +); + var block_js_default = ["*://*.tinypass.com/*", "*://*.poool.fr/*", "*://*.piano.io/*", "*://*.outbrain.com/*"]; var block_js_custom = []; var block_js = block_js_default.concat(block_js_custom); diff --git a/contentScript.js b/contentScript.js index c29adb8..21a9b4f 100644 --- a/contentScript.js +++ b/contentScript.js @@ -8,18 +8,18 @@ if (!localstorage_hold){ } // Content workarounds/domain -if (location.hostname.endsWith('rep.repubblica.it')) { - if (location.href.includes('/pwa/')) { - location.href = location.href.replace('/pwa/', '/ws/detail/'); - } - if (location.href.includes('/ws/detail/')) { +if (window.location.hostname.endsWith('rep.repubblica.it')) { + setTimeout(function () { + if (window.location.href.includes('/pwa/')) { + window.location.href = window.location.href.replace('/pwa/', '/ws/detail/'); + } + }, 500); // Delay (in milliseconds) + if (window.location.href.includes('/ws/detail/')) { const paywall = document.querySelector('.paywall[subscriptions-section="content"]'); if (paywall) { paywall.removeAttribute('subscriptions-section'); const preview = document.querySelector('div[subscriptions-section="content-not-granted"]'); - if (preview) { - preview.remove(); - } + removeDOMElement(preview); } } } diff --git a/popup.html b/popup.html index fc428fd..ff2bfd9 100644 --- a/popup.html +++ b/popup.html @@ -4,8 +4,8 @@ -
Bypass Paywalls Clean -
Options | Custom | GitHub |
+
Bypass Paywalls Clean +
Options | GitHub |
\ No newline at end of file