Fix-update Medium/Towards Data Science (multimedia)

master
magnolia1234 2021-06-09 21:32:19 +02:00
parent 1e65f489e6
commit fa3eb8e6f1
5 changed files with 21 additions and 38 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 - Chrome
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

@ -30,5 +30,5 @@
"webRequestBlocking",
"<all_urls>"
],
"version": "2.2.4.1"
"version": "2.2.4.2"
}

View File

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