diff --git a/background.js b/background.js index aa5a5a6..e2c8e10 100644 --- a/background.js +++ b/background.js @@ -630,7 +630,6 @@ ext_api.storage.local.get({ } } disableJavascriptOnListedSites(); - disableJavascriptInlineOnMediumSites(); }); // Listen for changes to options @@ -939,28 +938,6 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) { }, ['blocking', 'responseHeaders']); -// medium sites: block inline script -var medium_block_js_inline = ["*://*.medium.com/*", "*://*.towardsdatascience.com/*"]; -function disableJavascriptInlineOnMediumSites() { - ext_api.webRequest.onHeadersReceived.addListener(function (details) { - if (!isSiteEnabled(details) || !details.url.split('?')[0].match(/((\w)+(\-)+){3,}/)) { - return; - } - var headers = details.responseHeaders; - headers.push({ - 'name': 'Content-Security-Policy', - 'value': "script-src *;" - }); - return { - responseHeaders: headers - }; - }, { - 'types': ['main_frame', 'sub_frame'], - 'urls': medium_block_js_inline - }, - ['blocking', 'responseHeaders']); -} - var block_js_default = ["*://cdn.tinypass.com/*", "*://*.piano.io/*", "*://*.poool.fr/*", "*://cdn.ampproject.org/v*/amp-access-*.js", "*://*.blueconic.net/*", "*://*.cxense.com/*", "*://*.evolok.net/*", "*://js.matheranalytics.com/*", "*://*.newsmemory.com/*", "*://*.onecount.net/*", "*://js.pelcro.com/*", "*://*.qiota.com/*", "*://*.tribdss.com/*"]; var block_js_custom = []; var block_js_custom_ext = []; @@ -1510,6 +1487,9 @@ ext_api.runtime.onMessage.addListener(function (message, sender) { } }); } + if (message.request === 'refreshCurrentTab') { + refreshCurrentTab(); + } if (message.scheme && (![chrome_scheme, 'undefined'].includes(message.scheme) || focus_changed)) { let icon_path = {path: {'128': 'bypass.png'}}; if (message.scheme === 'dark') @@ -1622,3 +1602,17 @@ function randomIP() { rndmIP.push(randomInt(254) + 1); return rndmIP.join('.'); } + +// Refresh the current tab +function refreshCurrentTab() { + ext_api.tabs.query({ + active: true, + currentWindow: true + }, function (tabs) { + if (tabs && tabs[0] && tabs[0].url.startsWith('http')) { + ext_api.tabs.update(tabs[0].id, { + url: tabs[0].url + }); + } + }); +} diff --git a/changelog.txt b/changelog.txt index 19f4b7f..fac3cb7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release Fix-update Atlantico.fr +Fix-update Medium/Towards Data Science (multimedia) * v2.2.4.0 (2021-06-06) Add group Crain's Business diff --git a/contentScript.js b/contentScript.js index 04e9f74..4e0e3c8 100644 --- a/contentScript.js +++ b/contentScript.js @@ -69,24 +69,12 @@ if (matchDomain(['medium.com', 'towardsdatascience.com']) || document.querySelec let paywall = document.querySelector('div#paywall-background-color'); removeDOMElement(paywall); if (paywall) - window.location.reload(true); + ext_api.runtime.sendMessage({request: 'refreshCurrentTab'}); window.setTimeout(function () { let meter = document.querySelector('[id*="highlight-meter-"]'); if (meter) meter.hidden = true; }, 500); // Delay (in milliseconds) - let hidden_images = document.querySelectorAll('img:not([src])'); - let parser = new DOMParser(); - for (let hidden_image of hidden_images) { - let noscript = hidden_image.parentElement.parentElement.querySelector('noscript'); - if (noscript && noscript.innerHTML) { - let html = parser.parseFromString(noscript.innerHTML, 'text/html'); - if (html.querySelector('img')) { - hidden_image.parentNode.replaceChild(html.querySelector('img'), hidden_image); - removeDOMElement(noscript); - } - } - } } else if (window.location.hostname.match(/\.(com|net)\.au$/)) {//australia diff --git a/manifest.json b/manifest.json index 1a48b4c..6eeaafa 100644 --- a/manifest.json +++ b/manifest.json @@ -524,5 +524,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.2.4.1" + "version": "2.2.4.2" } \ No newline at end of file