mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 07:27:48 +01:00
Fix-update Medium/Towards Data Science
This commit is contained in:
parent
f6a76ba979
commit
c12c7073a1
4 changed files with 48 additions and 14 deletions
|
@ -621,6 +621,7 @@ ext_api.storage.local.get({
|
|||
}
|
||||
}
|
||||
disableJavascriptOnListedSites();
|
||||
disableJavascriptInlineOnMediumSites();
|
||||
});
|
||||
|
||||
// Listen for changes to options
|
||||
|
@ -755,7 +756,7 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
ext_api.tabs.update(tabs[0].id, {
|
||||
url: tabs[0].url
|
||||
});
|
||||
|
@ -910,7 +911,7 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) {
|
|||
['blocking', 'responseHeaders']);
|
||||
|
||||
// block inline script
|
||||
var block_js_inline = ["*://elviajero.elpais.com/*", "*://retina.elpais.com/*", "*://verne.elpais.com/*", "*://*.medianama.com/*"]
|
||||
var block_js_inline = ["*://elviajero.elpais.com/*", "*://retina.elpais.com/*", "*://verne.elpais.com/*", "*://*.medianama.com/*"];
|
||||
ext_api.webRequest.onHeadersReceived.addListener(function (details) {
|
||||
if (!isSiteEnabled(details)) {
|
||||
return;
|
||||
|
@ -929,6 +930,28 @@ 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 = [];
|
||||
|
@ -1055,7 +1078,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
ext_api.tabs.executeScript({
|
||||
file: 'options/toggleIcon.js',
|
||||
runAt: 'document_start'
|
||||
|
@ -1216,7 +1239,7 @@ if (matchUrlDomain(change_headers, details.url) && (['main_frame', 'sub_frame',
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
if (isSiteEnabled({url: tabs[0].url})) {
|
||||
ext_api.tabs.executeScript({
|
||||
file: 'contentScript.js',
|
||||
|
@ -1308,7 +1331,7 @@ function site_switch() {
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
let currentUrl = tabs[0].url;
|
||||
let isDefaultSite = matchUrlDomain(defaultSites_grouped_domains, currentUrl);
|
||||
if (!isDefaultSite) {
|
||||
|
@ -1354,7 +1377,7 @@ function remove_cookies_fn(domainVar, exclusions = false) {
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
let tabId = tabs[0].id;
|
||||
let storeId = '0';
|
||||
for (let store of cookieStores) {
|
||||
|
@ -1414,7 +1437,7 @@ function clear_cookies() {
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
ext_api.tabs.executeScript({
|
||||
file: 'options/clearCookies.js',
|
||||
runAt: 'document_start'
|
||||
|
@ -1457,7 +1480,7 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
|
|||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
if (tabs && tabs[0] && tabs[0].url.startsWith('http')) {
|
||||
let currentUrl = tabs[0].url;
|
||||
let domain;
|
||||
let isExcludedSite = matchUrlDomain(excludedSites, currentUrl);
|
||||
|
|
|
@ -4,6 +4,7 @@ Changelog Bypass Paywalls Clean - Firefox
|
|||
Post-release
|
||||
Add MediaNama (India)
|
||||
Remove Mitteldeutsche Zeitung (obsolete)
|
||||
Fix-update Medium/Towards Data Science
|
||||
Fix-update National Geographic USA
|
||||
Fix-update Prensa Iberica
|
||||
Fix-update Saechsische Zeitung (amp)
|
||||
|
|
|
@ -74,6 +74,18 @@ if (matchDomain(['medium.com', 'towardsdatascience.com']) || document.querySelec
|
|||
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$/) || matchDomain(['afr.com'])) {//australia
|
||||
|
@ -2028,13 +2040,11 @@ else if (matchDomain('newyorker.com')) {
|
|||
for (let asset_invisible of invisible_assets)
|
||||
asset_invisible.classList.remove('responsive-asset--invisible');
|
||||
let overlays = document.querySelectorAll('.aspect-ratio--overlay-container, .asset-embed__asset-container');
|
||||
let noscript,
|
||||
html;
|
||||
let parser = new DOMParser();
|
||||
for (let overlay of overlays) {
|
||||
noscript = overlay.querySelector('noscript');
|
||||
if (noscript) {
|
||||
html = parser.parseFromString(noscript.innerHTML, 'text/html');
|
||||
let noscript = overlay.querySelector('noscript');
|
||||
if (noscript && noscript.innerHTML) {
|
||||
let html = parser.parseFromString(noscript.innerHTML, 'text/html');
|
||||
overlay.appendChild(html.querySelector('img'));
|
||||
removeDOMElement(noscript);
|
||||
}
|
||||
|
|
|
@ -517,5 +517,5 @@
|
|||
"*://*.wallkit.net/*",
|
||||
"*://*.wsj.net/*"
|
||||
],
|
||||
"version": "2.2.1.8"
|
||||
"version": "2.2.1.9"
|
||||
}
|
Loading…
Reference in a new issue