mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 06:17:46 +01:00
Fix trimmed referer (restrictions)
This commit is contained in:
parent
5da2219e84
commit
e432983269
3 changed files with 28 additions and 25 deletions
|
@ -12,31 +12,29 @@ var currentTabUrl = '';
|
||||||
var csDone = false;
|
var csDone = false;
|
||||||
var optin_setcookie = false;
|
var optin_setcookie = false;
|
||||||
var optin_update = true;
|
var optin_update = true;
|
||||||
|
var blocked_referer = false;
|
||||||
|
|
||||||
// defaultSites are loaded from sites.js at installation extension
|
// defaultSites are loaded from sites.js at installation extension
|
||||||
|
|
||||||
const restrictions = {
|
var restrictions = {
|
||||||
'adweek.com': /^((?!\.adweek\.com\/(.+\/)?(amp|agencyspy|tvnewser|tvspy)\/).)*$/,
|
'adweek.com': /^((?!\.adweek\.com\/(.+\/)?(amp|agencyspy|tvnewser|tvspy)\/).)*$/,
|
||||||
'barrons.com': /.+\.barrons\.com\/(amp\/)?article(s)?\/.+/,
|
|
||||||
'bloomberg.com': /^((?!\.bloomberg\.com\/news\/terminal\/).)*$/,
|
'bloomberg.com': /^((?!\.bloomberg\.com\/news\/terminal\/).)*$/,
|
||||||
'economictimes.com': /.+\.economictimes\.com\/($|(__assets|prime)(\/.+)?|.+\.cms)/,
|
'economictimes.com': /\.economictimes\.com($|\/($|(__assets|prime)(\/.+)?|.+\.cms))/,
|
||||||
'elespanol.com': /^((?!\/cronicaglobal\.elespanol\.com\/).)*$/,
|
'elespanol.com': /^((?!\/cronicaglobal\.elespanol\.com\/).)*$/,
|
||||||
'elpais.com': /(\/elpais\.com\/$|(static|imagenes(\.\w+)?)\.elpais\.com|\/(.+\.)?elpais\.com\/.+\.html)/,
|
'elpais.com': /(\/elpais\.com\/$|(static|imagenes(\.\w+)?)\.elpais\.com|\/(.+\.)?elpais\.com\/.+\.html)/,
|
||||||
'faz.net': /^((?!\/.+\.faz\.net\/aktuell\/(\?switchfaznet)?$).)*$/,
|
'faz.net': /^((?!\.faz\.net\/aktuell\/(\?switchfaznet)?$).)*$/,
|
||||||
'foreignaffairs.com': /.+\.foreignaffairs\.com\/(articles|fa-caching|interviews|reviews|sites)\/.+/,
|
'foreignaffairs.com': /\.foreignaffairs\.com\/((articles|fa-caching|interviews|reviews|sites)\/)/,
|
||||||
'ft.com': /.+\.ft\.com\/content\//,
|
|
||||||
'lastampa.it': /^((?!\/video\.lastampa\.it\/).)*$/,
|
'lastampa.it': /^((?!\/video\.lastampa\.it\/).)*$/,
|
||||||
'medianama.com': /\.medianama\.com\/((\d){4}\/(\d){2}|wp-content)\//,
|
'medianama.com': /\.medianama\.com\/((\d){4}\/(\d){2}|wp-content)\//,
|
||||||
'science.org': /^((?!\.science\.org\/doi\/).)*$/,
|
'science.org': /^((?!\.science\.org\/doi\/).)*$/,
|
||||||
'timesofindia.com': /.+\.timesofindia\.com\/($|toi-plus(\/.+)?|.+\.cms)/,
|
'timesofindia.com': /\.timesofindia\.com($|\/($|toi-plus(\/.+)?|.+\.cms))/,
|
||||||
'nknews.org': /^((?!nknews\.org\/pro\/).)*$/,
|
'nknews.org': /^((?!nknews\.org\/pro\/).)*$/,
|
||||||
'quora.com': /^((?!quora\.com\/search\?q=).)*$/,
|
'quora.com': /^((?!quora\.com\/search\?q=).)*$/,
|
||||||
'repubblica.it': /^((?!\/video\.repubblica\.it\/).)*$/,
|
'repubblica.it': /^((?!\/video\.repubblica\.it\/).)*$/,
|
||||||
'seekingalpha.com': /.+\/seekingalpha\.com\/($|(amp\/)?(article|news)\/|samw\/)/,
|
'seekingalpha.com': /\/seekingalpha\.com($|\/($|(amp\/)?(article|news)\/|samw\/))/,
|
||||||
'statista.com': /^((?!\.statista\.com\/(outlook|study)\/).)*$/,
|
'statista.com': /^((?!\.statista\.com\/(outlook|study)\/).)*$/,
|
||||||
'techinasia.com': /\.techinasia\.com\/.+/,
|
'techinasia.com': /\.techinasia\.com\/.+/,
|
||||||
'theglobeandmail.com': /\.theglobeandmail\.com\/.+\//,
|
'timeshighereducation.com': /\.timeshighereducation\.com\/((features|news|people)\/|.+((\w)+(\-)+){3,}.+|sites\/default\/files\/)/
|
||||||
'timeshighereducation.com': /.+\.timeshighereducation\.com\/((features|news|people)\/|.+((\w)+(\-)+){3,}.+|sites\/default\/files\/)/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let domain of au_news_corp_domains)
|
for (let domain of au_news_corp_domains)
|
||||||
|
@ -673,19 +671,24 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
||||||
var requestHeaders = details.requestHeaders;
|
var requestHeaders = details.requestHeaders;
|
||||||
|
|
||||||
var header_referer = '';
|
var header_referer = '';
|
||||||
for (let n in requestHeaders) {
|
if (details.originUrl)
|
||||||
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
header_referer = details.originUrl;
|
||||||
header_referer = requestHeaders[n].value;
|
else {
|
||||||
continue;
|
for (let n in requestHeaders) {
|
||||||
|
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
||||||
|
header_referer = requestHeaders[n].value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var blocked_referer_domains = ['foreignaffairs.com', 'timeshighereducation.com'];
|
||||||
|
if (!header_referer && details.initiator) {
|
||||||
|
header_referer = details.initiator;
|
||||||
|
if (!blocked_referer && matchUrlDomain(blocked_referer_domains, details.url) && ['script', 'xmlhttprequest'].includes(details.type)) {
|
||||||
|
for (let domain of blocked_referer_domains)
|
||||||
|
restrictions[domain] = new RegExp('((\\/|\\.)' + domain.replace(/\./g, '\\.') + '($|\\/$)|' + restrictions[domain].toString().replace(/(^\/|\/$)/g, '') + ')');
|
||||||
|
blocked_referer = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// fix blocked referer
|
|
||||||
if (!header_referer) {
|
|
||||||
if (typeof browser !== 'object')
|
|
||||||
header_referer = details.initiator ? details.initiator : '';
|
|
||||||
else
|
|
||||||
header_referer = details.originUrl ? details.originUrl : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove cookies for sites medium platform (custom domains)
|
// remove cookies for sites medium platform (custom domains)
|
||||||
|
@ -1339,7 +1342,7 @@ function isSiteEnabled(details) {
|
||||||
return !!enabledSite;
|
return !!enabledSite;
|
||||||
}
|
}
|
||||||
|
|
||||||
function matchDomain(domains, hostname = window.location.hostname) {
|
function matchDomain(domains, hostname = '') {
|
||||||
var matched_domain = false;
|
var matched_domain = false;
|
||||||
if (typeof domains === 'string')
|
if (typeof domains === 'string')
|
||||||
domains = [domains];
|
domains = [domains];
|
||||||
|
@ -1363,7 +1366,6 @@ function matchUrlDomain(domains, url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParameterByName(name, url) {
|
function getParameterByName(name, url) {
|
||||||
if (!url) url = window.location.href;
|
|
||||||
name = name.replace(/[\[\]]/g, '\\$&');
|
name = name.replace(/[\[\]]/g, '\\$&');
|
||||||
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
|
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
|
||||||
results = regex.exec(url);
|
results = regex.exec(url);
|
||||||
|
|
|
@ -3,6 +3,7 @@ Changelog Bypass Paywalls Clean - Firefox
|
||||||
|
|
||||||
Post-release
|
Post-release
|
||||||
Fix Handelsblatt (no amp)
|
Fix Handelsblatt (no amp)
|
||||||
|
Fix trimmed referer (restrictions)
|
||||||
|
|
||||||
* v2.5.0.0 (2022-01-02)
|
* v2.5.0.0 (2022-01-02)
|
||||||
Add Capital Gazette (local USA)
|
Add Capital Gazette (local USA)
|
||||||
|
|
|
@ -605,5 +605,5 @@
|
||||||
"*://*.wsj.net/*",
|
"*://*.wsj.net/*",
|
||||||
"*://*.zephr.com/*"
|
"*://*.zephr.com/*"
|
||||||
],
|
],
|
||||||
"version": "2.5.0.1"
|
"version": "2.5.0.2"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue