Fix-update Medium/Towards Data Science (multimedia)

This commit is contained in:
magnolia1234 2021-06-09 21:32:35 +02:00
parent 59e68c973c
commit 73bcd7ccd2
4 changed files with 20 additions and 37 deletions

View file

@ -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
});
}
});
}

View file

@ -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

View file

@ -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

View file

@ -524,5 +524,5 @@
"*://*.wallkit.net/*",
"*://*.wsj.net/*"
],
"version": "2.2.4.1"
"version": "2.2.4.2"
}