2019-10-25 18:44:39 +02:00
|
|
|
/* Please respect alphabetical order when adding a site in any list */
|
|
|
|
|
2017-07-08 14:16:27 -07:00
|
|
|
'use strict';
|
2020-05-01 12:57:33 +02:00
|
|
|
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
2017-07-08 14:16:27 -07:00
|
|
|
|
2019-12-30 21:09:44 +01:00
|
|
|
// Cookies from this list are blocked by default (obsolete)
|
2020-02-25 22:35:21 +01:00
|
|
|
// defaultSites are loaded from sites.js at installation extension
|
|
|
|
// var defaultSites = {};
|
2017-07-08 14:16:27 -07:00
|
|
|
|
2018-01-30 21:26:21 -08:00
|
|
|
const restrictions = {
|
2019-12-16 20:14:16 +01:00
|
|
|
'barrons.com': /.+barrons\.com\/articles\/.+/,
|
2020-05-02 11:09:51 +02:00
|
|
|
'economist.com': /.+economist\.com\/.+\/\d{1,4}\/\d{1,2}\/\d{2}\/.+/,
|
2020-04-03 13:58:45 +02:00
|
|
|
'elcomercio.pe': /.+\/elcomercio.pe\/.+((\w)+(\-)+){3,}.+/,
|
|
|
|
'gestion.pe': /.+\/gestion.pe\/.+((\w)+(\-)+){3,}.+/,
|
2020-04-26 09:24:42 +02:00
|
|
|
'quora.com': /^((?!quora\.com\/search\?q=).)*$/
|
2017-07-08 14:16:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't remove cookies before page load
|
2020-02-25 22:35:21 +01:00
|
|
|
// allow_cookies are completed with domains in sites.js (default allow/remove_cookies)
|
2019-12-20 14:41:41 +01:00
|
|
|
var allow_cookies = [
|
2020-01-26 20:34:19 +01:00
|
|
|
'adelaidenow.com.au',
|
2020-03-04 18:48:08 +01:00
|
|
|
'aftonbladet.se',
|
2020-01-28 18:38:12 +01:00
|
|
|
'bostonglobe.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'cairnspost.com.au',
|
2020-02-16 16:32:20 +01:00
|
|
|
'clarin.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'couriermail.com.au',
|
|
|
|
'dailytelegraph.com.au',
|
2020-03-19 20:05:19 +01:00
|
|
|
'demorgen.be',
|
2020-01-25 18:55:30 +01:00
|
|
|
'dn.se',
|
2020-02-12 18:45:26 +01:00
|
|
|
'dvhn.nl',
|
2020-02-09 15:48:21 +01:00
|
|
|
'elmercurio.com',
|
2020-04-11 20:09:31 +02:00
|
|
|
'eurekareport.com.au',
|
2020-04-25 17:16:06 +02:00
|
|
|
'faz.net',
|
2020-01-21 19:46:27 +01:00
|
|
|
'folha.uol.com.br',
|
2020-04-03 13:58:45 +02:00
|
|
|
'gestion.pe',
|
2020-01-26 20:34:19 +01:00
|
|
|
'goldcoastbulletin.com.au',
|
2020-01-05 12:19:53 +01:00
|
|
|
'haaretz.co.il',
|
|
|
|
'haaretz.com',
|
2020-01-11 13:59:27 +01:00
|
|
|
'handelsblatt.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'heraldsun.com.au',
|
2020-02-25 23:18:39 +01:00
|
|
|
'humo.be',
|
2020-04-11 20:09:31 +02:00
|
|
|
'intelligentinvestor.com.au',
|
2020-01-19 14:01:23 +01:00
|
|
|
'kleinezeitung.at',
|
2020-02-12 18:45:26 +01:00
|
|
|
'lc.nl',
|
2020-01-25 14:52:33 +01:00
|
|
|
'lrb.co.uk',
|
2020-01-05 12:19:53 +01:00
|
|
|
'mexiconewsdaily.com',
|
2020-04-28 09:46:11 +02:00
|
|
|
'miamiherald.com',
|
2020-01-31 15:16:02 +01:00
|
|
|
'modernhealthcare.com',
|
2020-01-31 14:58:53 +01:00
|
|
|
'nationalreview.com',
|
2020-03-23 17:50:50 +01:00
|
|
|
'newrepublic.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'ntnews.com.au',
|
2019-10-20 17:18:58 +02:00
|
|
|
'nytimes.com',
|
|
|
|
'parool.nl',
|
2020-01-05 12:19:53 +01:00
|
|
|
'quora.com',
|
2020-01-02 09:10:30 +01:00
|
|
|
'scribd.com',
|
2020-02-26 23:11:34 +01:00
|
|
|
'seekingalpha.com',
|
2020-04-13 08:56:45 +02:00
|
|
|
'switzersuperreport.com.au',
|
2020-01-02 09:10:30 +01:00
|
|
|
'techinasia.com',
|
2020-01-05 12:19:53 +01:00
|
|
|
'telegraph.co.uk',
|
2019-10-20 17:18:58 +02:00
|
|
|
'the-american-interest.com',
|
2020-03-10 19:32:16 +01:00
|
|
|
'theathletic.co.uk',
|
2020-01-05 11:18:33 +01:00
|
|
|
'theathletic.com',
|
2019-04-28 17:20:17 -07:00
|
|
|
'theaustralian.com.au',
|
2020-01-05 12:19:53 +01:00
|
|
|
'themarker.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'themercury.com.au',
|
2020-01-05 12:19:53 +01:00
|
|
|
'thetimes.co.uk',
|
2020-01-26 20:34:19 +01:00
|
|
|
'townsvillebulletin.com.au',
|
2019-10-20 17:18:58 +02:00
|
|
|
'trouw.nl',
|
|
|
|
'volkskrant.nl',
|
2020-01-26 20:34:19 +01:00
|
|
|
'weeklytimesnow.com.au',
|
2020-01-31 14:15:09 +01:00
|
|
|
'worldpoliticsreview.com',
|
2017-07-08 14:16:27 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
// Removes cookies after page load
|
2020-02-25 22:35:21 +01:00
|
|
|
// remove_cookies are completed with domains of sites.js (default allow/remove_cookies)
|
2019-12-20 14:41:41 +01:00
|
|
|
var remove_cookies = [
|
2017-07-08 14:16:27 -07:00
|
|
|
]
|
|
|
|
|
2019-10-25 14:34:58 +02:00
|
|
|
// select specific cookie(s) to hold from remove_cookies domains
|
|
|
|
const remove_cookies_select_hold = {
|
2020-03-22 13:21:33 +01:00
|
|
|
'barrons.com': ['wsjregion'],
|
2020-01-13 21:32:24 +01:00
|
|
|
'newstatesman.com': ['STYXKEY_nsversion'],
|
|
|
|
'qz.com': ['gdpr'],
|
2020-03-19 19:18:40 +01:00
|
|
|
'washingtonpost.com': ['wp_gdpr'],
|
|
|
|
'wsj.com': ['wsjregion']
|
2019-10-25 14:34:58 +02:00
|
|
|
}
|
|
|
|
|
2020-04-13 19:09:49 +02:00
|
|
|
// list of regional ad.nl sites
|
|
|
|
const ad_region_domains = ['bd.nl', 'ed.nl', 'tubantia.nl', 'bndestem.nl', 'pzc.nl', 'destentor.nl', 'gelderlander.nl'];
|
|
|
|
|
2019-10-25 14:34:58 +02:00
|
|
|
// select only specific cookie(s) to drop from remove_cookies domains
|
2020-04-13 19:09:49 +02:00
|
|
|
var remove_cookies_select_drop = {
|
2019-11-17 20:09:03 +01:00
|
|
|
'ad.nl': ['temptationTrackingId'],
|
2019-12-20 18:20:09 +01:00
|
|
|
'caixinglobal.com': ['CAIXINGLB_LOGIN_UUID'],
|
2019-12-30 14:11:13 +01:00
|
|
|
'dn.se': ['randomSplusId'],
|
2020-04-03 20:56:50 +02:00
|
|
|
'fd.nl': ['socialread'],
|
2020-01-02 21:55:15 +01:00
|
|
|
'nrc.nl': ['counter'],
|
|
|
|
'theatlantic.com': ['articleViews']
|
2019-10-25 14:34:58 +02:00
|
|
|
}
|
2020-04-13 19:09:49 +02:00
|
|
|
for (var domainIndex in ad_region_domains) {
|
|
|
|
let domain = ad_region_domains[domainIndex];
|
|
|
|
remove_cookies_select_drop[domain] = ['temptationTrackingId'];
|
|
|
|
}
|
2019-10-25 14:34:58 +02:00
|
|
|
|
2019-05-12 14:00:27 -07:00
|
|
|
// Override User-Agent with Googlebot
|
2020-02-27 22:51:31 +01:00
|
|
|
const use_google_bot_default = [
|
2020-01-26 20:34:19 +01:00
|
|
|
'adelaidenow.com.au',
|
2020-03-04 18:48:08 +01:00
|
|
|
'aftonbladet.se',
|
2019-05-25 14:18:22 -07:00
|
|
|
'barrons.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'cairnspost.com.au',
|
|
|
|
'couriermail.com.au',
|
|
|
|
'dailytelegraph.com.au',
|
2020-01-25 18:55:30 +01:00
|
|
|
'dn.se',
|
2020-04-11 20:09:31 +02:00
|
|
|
'eurekareport.com.au',
|
2020-03-13 12:00:30 +01:00
|
|
|
'ft.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'goldcoastbulletin.com.au',
|
2019-11-25 18:31:39 +01:00
|
|
|
'haaretz.co.il',
|
2020-01-05 12:19:53 +01:00
|
|
|
'haaretz.com',
|
2020-01-11 13:59:27 +01:00
|
|
|
'handelsblatt.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'heraldsun.com.au',
|
2020-04-11 20:09:31 +02:00
|
|
|
'intelligentinvestor.com.au',
|
2019-09-22 16:54:54 -07:00
|
|
|
'mexiconewsdaily.com',
|
2020-04-28 09:46:11 +02:00
|
|
|
'miamiherald.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'ntnews.com.au',
|
2019-10-29 14:25:54 +01:00
|
|
|
'quora.com',
|
2020-02-26 23:11:34 +01:00
|
|
|
'seekingalpha.com',
|
2020-04-13 08:56:45 +02:00
|
|
|
'switzersuperreport.com.au',
|
2019-10-22 13:53:43 +02:00
|
|
|
'telegraph.co.uk',
|
2020-03-10 19:32:16 +01:00
|
|
|
'theathletic.co.uk',
|
2020-01-05 12:19:53 +01:00
|
|
|
'theathletic.com',
|
2019-10-22 13:53:43 +02:00
|
|
|
'theaustralian.com.au',
|
2019-11-25 18:31:39 +01:00
|
|
|
'themarker.com',
|
2020-01-26 20:34:19 +01:00
|
|
|
'themercury.com.au',
|
2019-09-22 17:03:15 -07:00
|
|
|
'thetimes.co.uk',
|
2020-01-26 20:34:19 +01:00
|
|
|
'townsvillebulletin.com.au',
|
|
|
|
'weeklytimesnow.com.au',
|
2020-01-31 14:15:09 +01:00
|
|
|
'worldpoliticsreview.com',
|
2019-10-22 13:53:43 +02:00
|
|
|
'wsj.com',
|
2020-02-27 22:51:31 +01:00
|
|
|
];
|
|
|
|
var use_google_bot_custom = [];
|
|
|
|
var use_google_bot = use_google_bot_default.concat(use_google_bot_custom);
|
2019-05-12 14:00:27 -07:00
|
|
|
|
2020-01-19 10:09:14 +01:00
|
|
|
// block paywall-scripts individually
|
2019-11-19 00:02:46 +01:00
|
|
|
var blockedRegexes = {
|
2020-01-22 19:04:30 +01:00
|
|
|
'adweek.com': /.+\.lightboxcdn\.com\/.+/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'afr.com': /afr\.com\/assets\/vendorsReactRedux_client.+\.js/,
|
2020-02-14 13:05:18 +01:00
|
|
|
'americanbanker.com': /.+\.tinypass\.com\/.+/,
|
2020-02-22 13:20:19 +01:00
|
|
|
'bloomberg.com': /.+\.tinypass\.com\/.+/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'bostonglobe.com': /meter\.bostonglobe\.com\/js\/.+/,
|
2019-11-19 14:25:29 +01:00
|
|
|
'businessinsider.com': /(.+\.tinypass\.com\/.+|cdn\.onesignal\.com\/sdks\/.+\.js)/,
|
2020-05-01 12:57:33 +02:00
|
|
|
'challenges.fr': /(.+\.challenges\.fr\/js\/|.+\.poool\.fr\/.+)/,
|
2020-01-25 18:40:52 +01:00
|
|
|
'chicagobusiness.com': /.+\.tinypass\.com\/.+/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'chicagotribune.com': /.+:\/\/.+\.tribdss\.com\//,
|
2020-03-17 12:13:40 +01:00
|
|
|
'corriere.it': /(\.rcsobjects\.it\/rcs_cpmt\/|\.rcsobjects\.it\/rcs_tracking-service\/|\.corriereobjects\.it\/.+\/js\/_paywall\.sjs|\.corriereobjects\.it\/.*\/js\/tracking\/|\.userzoom\.com\/files\/js\/|\.lp4\.io\/app\/)/,
|
2020-01-19 10:09:14 +01:00
|
|
|
'digiday.com': /.+\.tinypass\.com\/.+/,
|
2020-05-02 11:09:51 +02:00
|
|
|
'economist.com': /(.+\.tinypass\.com\/.+|economist\.com\/engassets\/_next\/static\/chunks\/framework.+\.js)/,
|
2020-04-25 20:39:36 +02:00
|
|
|
'elcomercio.pe': /elcomercio\.pe\/pf\/dist\/template\/elcomercio-noticia.+\.js/,
|
2020-02-09 15:48:21 +01:00
|
|
|
'elmercurio.com': /merreader\.emol\.cl\/assets\/js\/vendor\/modal\.js/,
|
2020-02-12 18:45:26 +01:00
|
|
|
'elpais.com': /.+\.epimg\.net\/js\/.+\/noticia\.min\.js/,
|
2020-01-19 10:09:14 +01:00
|
|
|
'exame.abril.com.br': /.+\.tinypass\.com\/.+/,
|
2020-01-21 19:46:27 +01:00
|
|
|
'folha.uol.com.br': /.+\.folha\.uol\.com\.br\/paywall\/js\/.+\/publicidade\.ads\.js/,
|
2020-01-19 10:09:14 +01:00
|
|
|
'globo.com': /.+\.tinypass\.com\/.+/,
|
2019-12-08 19:24:00 +01:00
|
|
|
'foreignpolicy.com': /.+\.tinypass\.com\/.+/,
|
2020-01-17 16:24:27 +01:00
|
|
|
'fortune.com': /.+\.tinypass\.com\/.+/,
|
2020-04-25 20:39:36 +02:00
|
|
|
'gestion.pe': /gestion\.pe\/pf\/dist\/template\/gestion-noticia.+\.js/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'haaretz.co.il': /haaretz\.co\.il\/htz\/js\/inter\.js/,
|
|
|
|
'haaretz.com': /haaretz\.com\/hdc\/web\/js\/minified\/header-scripts-int.js.+/,
|
2020-04-23 21:44:27 +02:00
|
|
|
'ilmessaggero.it': /(utils\.cedsdigital\.it\/js\/PaywallMeter\.js|static\.viralize\.tv\/viralize_player)/,
|
2019-12-12 22:06:58 +01:00
|
|
|
'inquirer.com': /.+\.tinypass\.com\/.+/,
|
2020-03-21 14:33:05 +00:00
|
|
|
'ladepeche.fr': /.+\.poool\.fr\/.+/,
|
2020-03-22 13:21:33 +01:00
|
|
|
'lastampa.it': /.+\.repstatic\.it\/minify\/sites\/lastampa\/.+\/config\.cache\.php\?name=social_js/,
|
2020-01-20 20:49:11 +01:00
|
|
|
'lejdd.fr': /.+\.swisspay\.ch\/.+/,
|
2020-01-04 13:32:59 +01:00
|
|
|
'leparisien.fr': /.+\.tinypass\.com\/.+/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'lesechos.fr': /.+\.tinypass\.com\/.+/,
|
2020-03-28 18:49:43 +01:00
|
|
|
'livemint.com': /(.+\.livemint\.com\/js\/localWorker\.js|analytics\.htmedia\.in\/analytics-js\/.+\.js)/,
|
2020-03-25 07:47:35 +00:00
|
|
|
'lopinion.fr': /.+\.poool\.fr\/.+/,
|
2020-03-25 19:27:07 +01:00
|
|
|
'lrb.co.uk': /.+\.tinypass\.com\/.+/,
|
2020-01-31 15:16:02 +01:00
|
|
|
'modernhealthcare.com': /.+\.tinypass\.com\/.+/,
|
2020-01-31 14:58:53 +01:00
|
|
|
'nationalreview.com': /.+\.blueconic\.net\/.+/,
|
2020-01-07 22:04:49 +01:00
|
|
|
'newcastleherald.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/,
|
2020-03-23 17:50:50 +01:00
|
|
|
'newrepublic.com': /.+\.onecount\.net\/js\/.+/,
|
2020-03-25 19:27:07 +01:00
|
|
|
'nytimes.com': /(.+meter-svc\.nytimes\.com\/meter\.js.+|.+mwcm\.nyt\.com\/.+\.js)/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'nzherald.co.nz': /nzherald\.co\.nz\/.+\/headjs\/.+\.js/,
|
2020-03-02 14:53:37 +01:00
|
|
|
'portnews.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/,
|
2020-02-01 21:20:41 +01:00
|
|
|
'repubblica.it': /scripts\.repubblica\.it\/pw\/pw\.js.+/,
|
2020-03-31 17:06:16 +00:00
|
|
|
'science-et-vie.com': /.+\.qiota\.com\/.+/,
|
2020-05-02 09:02:47 +02:00
|
|
|
'sciencesetavenir.fr': /.+\.poool\.fr\/.+/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'sloanreview.mit.edu': /.+\.tinypass\.com\/.+/,
|
|
|
|
'spectator.co.uk': /.+\.tinypass\.com\/.+/,
|
2020-02-02 18:12:27 +01:00
|
|
|
'spectator.com.au': /.+\.tinypass\.com\/.+/,
|
2020-02-14 13:05:18 +01:00
|
|
|
'telegraph.co.uk': /.+\.tinypass\.com\/.+/,
|
2020-02-03 17:45:57 +01:00
|
|
|
'theadvocate.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/,
|
|
|
|
'thecourier.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/,
|
2020-01-30 17:55:30 +01:00
|
|
|
'thedailybeast.com': /.+\.tinypass\.com\/.+/,
|
2020-01-15 18:24:30 +01:00
|
|
|
'theglobeandmail.com': /theglobeandmail\.com\/pb\/resources\/scripts\/build\/chunk-bootstraps\/.+\.js/,
|
2020-02-20 21:10:38 +01:00
|
|
|
'thenation.com': /.+\.tinypass\.com\/.+/,
|
2020-01-19 10:09:14 +01:00
|
|
|
'valeursactuelles.com': /.+\.poool\.fr\/.+/
|
2020-01-03 12:50:00 +01:00
|
|
|
};
|
2020-05-01 12:57:33 +02:00
|
|
|
// browser-specific block
|
|
|
|
if (ext_api === chrome) {
|
|
|
|
blockedRegexes['challenges.fr'] = /.+\.poool\.fr\/.+/;
|
|
|
|
}
|
2017-07-08 14:16:27 -07:00
|
|
|
|
2019-04-28 17:20:17 -07:00
|
|
|
const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
|
|
|
const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)"
|
|
|
|
|
2017-07-08 14:16:27 -07:00
|
|
|
var enabledSites = [];
|
|
|
|
|
2020-01-19 10:09:14 +01:00
|
|
|
function setDefaultOptions() {
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.storage.sync.set({
|
2020-01-19 10:09:14 +01:00
|
|
|
sites: defaultSites
|
|
|
|
}, function() {
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.runtime.openOptionsPage();
|
2020-01-19 10:09:14 +01:00
|
|
|
});
|
|
|
|
}
|
2020-02-25 23:18:39 +01:00
|
|
|
|
2020-01-15 18:24:30 +01:00
|
|
|
// Get the enabled sites (from local storage) & add to allow/remove_cookies (if not already in one of these arrays)
|
2020-02-27 22:51:31 +01:00
|
|
|
// Add googlebot- and block_javascript-settings for custom sites
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.storage.sync.get({
|
2020-02-27 22:51:31 +01:00
|
|
|
sites: {},
|
|
|
|
sites_custom: {}
|
|
|
|
}, function (items) {
|
|
|
|
var sites = items.sites;
|
|
|
|
var sites_custom = items.sites_custom;
|
2019-12-20 14:41:41 +01:00
|
|
|
|
2020-02-27 22:51:31 +01:00
|
|
|
// custom googlebot
|
|
|
|
use_google_bot_custom = Object.keys(sites_custom).filter(function (key) {
|
|
|
|
return sites_custom[key]['googlebot'] > 0;
|
|
|
|
}).map(function (key) {
|
2020-03-09 21:09:42 +01:00
|
|
|
return sites_custom[key]['domain'].toLowerCase();
|
2020-02-27 22:51:31 +01:00
|
|
|
});
|
|
|
|
use_google_bot = use_google_bot_default.slice();
|
|
|
|
|
|
|
|
// custom block javascript (only (sub)domain)
|
|
|
|
block_js_custom = Object.keys(sites_custom).filter(function (key) {
|
|
|
|
return sites_custom[key]['block_javascript'] > 0;
|
|
|
|
}).map(function (key) {
|
2020-03-09 21:09:42 +01:00
|
|
|
return sites_custom[key]['domain'].toLowerCase();
|
2020-02-27 22:51:31 +01:00
|
|
|
});
|
|
|
|
block_js = block_js_default.slice();
|
|
|
|
|
2020-02-29 20:02:02 +01:00
|
|
|
enabledSites = Object.keys(sites).filter(function (key) {
|
|
|
|
return (sites[key] !== '' && sites[key] !== '###');
|
|
|
|
}).map(function (key) {
|
2020-03-09 21:09:42 +01:00
|
|
|
return sites[key].toLowerCase();
|
2020-02-27 22:51:31 +01:00
|
|
|
});
|
2020-04-13 19:09:49 +02:00
|
|
|
if (enabledSites.includes('ad.nl')) {
|
|
|
|
enabledSites = enabledSites.concat(ad_region_domains);
|
|
|
|
}
|
2020-02-29 20:02:02 +01:00
|
|
|
|
2020-02-27 22:51:31 +01:00
|
|
|
for (var domainIndex in enabledSites) {
|
|
|
|
var domainVar = enabledSites[domainIndex];
|
|
|
|
if (!allow_cookies.includes(domainVar) && !remove_cookies.includes(domainVar)) {
|
|
|
|
allow_cookies.push(domainVar);
|
|
|
|
remove_cookies.push(domainVar);
|
|
|
|
}
|
|
|
|
if (use_google_bot_custom.includes(domainVar)) {
|
|
|
|
use_google_bot.push(domainVar);
|
|
|
|
}
|
|
|
|
if (block_js_custom.includes(domainVar)) {
|
|
|
|
block_js.push("*://*." + domainVar + "/*"); // subdomains of site
|
|
|
|
block_js.push("*://" + domainVar + "/*"); // site without www.-prefix
|
|
|
|
}
|
|
|
|
}
|
2020-03-28 14:56:46 +01:00
|
|
|
disableJavascriptOnListedSites();
|
2020-02-27 22:51:31 +01:00
|
|
|
});
|
2020-03-25 19:27:07 +01:00
|
|
|
|
2017-07-08 14:16:27 -07:00
|
|
|
// Listen for changes to options
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
2020-02-27 22:51:31 +01:00
|
|
|
for (var key in changes) {
|
|
|
|
var storageChange = changes[key];
|
|
|
|
if (key === 'sites') {
|
|
|
|
var sites = storageChange.newValue;
|
2020-02-29 20:02:02 +01:00
|
|
|
enabledSites = Object.keys(sites).filter(function (key) {
|
|
|
|
return (sites[key] !== '' && sites[key] !== '###');
|
|
|
|
}).map(function (key) {
|
2020-02-27 22:51:31 +01:00
|
|
|
return sites[key];
|
|
|
|
});
|
2020-04-13 19:09:49 +02:00
|
|
|
if (enabledSites.includes('ad.nl')) {
|
|
|
|
enabledSites = enabledSites.concat(ad_region_domains);
|
|
|
|
}
|
2020-03-28 15:19:06 +01:00
|
|
|
// reset disableJavascriptOnListedSites eventListener
|
2020-03-28 14:56:46 +01:00
|
|
|
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
|
|
|
|
ext_api.webRequest.handlerBehaviorChanged();
|
2020-02-27 22:51:31 +01:00
|
|
|
}
|
|
|
|
if (key === 'sites_custom') {
|
|
|
|
var sites_custom = storageChange.newValue;
|
|
|
|
use_google_bot_custom = Object.keys(sites_custom).filter(function (key) {
|
|
|
|
return sites_custom[key]['googlebot'] > 0;
|
|
|
|
}).map(function (key) {
|
2020-03-09 21:09:42 +01:00
|
|
|
return sites_custom[key]['domain'].toLowerCase();
|
2020-02-27 22:51:31 +01:00
|
|
|
});
|
|
|
|
use_google_bot = use_google_bot_default.slice();
|
|
|
|
for (var domainIndex in use_google_bot_custom) {
|
|
|
|
var domainVar = use_google_bot_custom[domainIndex];
|
2020-02-29 20:02:02 +01:00
|
|
|
if (domainVar && !use_google_bot.includes(domainVar)) {
|
2020-02-27 22:51:31 +01:00
|
|
|
use_google_bot.push(domainVar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
block_js_custom = Object.keys(sites_custom).filter(function (key) {
|
|
|
|
return sites_custom[key]['block_javascript'] > 0;
|
|
|
|
}).map(function (key) {
|
2020-03-09 21:09:42 +01:00
|
|
|
return sites_custom[key]['domain'].toLowerCase();
|
2020-02-27 22:51:31 +01:00
|
|
|
});
|
|
|
|
block_js = block_js_default.slice();
|
|
|
|
for (var domainIndex in block_js_custom) {
|
|
|
|
var domainVar = block_js_custom[domainIndex];
|
2020-02-29 20:02:02 +01:00
|
|
|
if (domainVar && !block_js.includes(domainVar)) {
|
2020-02-27 22:51:31 +01:00
|
|
|
block_js.push("*://*." + domainVar + "/*"); // subdomains of site
|
|
|
|
block_js.push("*://" + domainVar + "/*"); // site without www.-prefix
|
|
|
|
}
|
|
|
|
}
|
2020-03-28 15:19:06 +01:00
|
|
|
// reset disableJavascriptOnListedSites eventListener
|
2020-03-28 14:56:46 +01:00
|
|
|
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
|
|
|
|
ext_api.webRequest.handlerBehaviorChanged();
|
2020-02-27 22:51:31 +01:00
|
|
|
}
|
2017-07-08 14:16:27 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Set and show default options on install
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.runtime.onInstalled.addListener(function (details) {
|
2017-07-08 14:16:27 -07:00
|
|
|
if (details.reason == "install") {
|
2020-02-25 22:35:21 +01:00
|
|
|
setDefaultOptions();
|
2017-07-08 14:16:27 -07:00
|
|
|
} else if (details.reason == "update") {
|
|
|
|
// User updated extension
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-03 18:12:59 +01:00
|
|
|
// repubblica.it bypass
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.webRequest.onBeforeRequest.addListener(function (details) {
|
2020-03-03 18:12:59 +01:00
|
|
|
if (!isSiteEnabled(details)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var updatedUrl = details.url.replace('/pwa/', '/ws/detail/');
|
|
|
|
return { redirectUrl: updatedUrl };
|
|
|
|
},
|
|
|
|
{urls:["*://*.repubblica.it/pwa/*"], types:["main_frame"]},
|
|
|
|
["blocking"]
|
|
|
|
);
|
|
|
|
|
2020-04-25 17:16:06 +02:00
|
|
|
const faz_uaMobile = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36";
|
|
|
|
ext_api.webRequest.onBeforeSendHeaders.addListener(
|
|
|
|
function (details) {
|
|
|
|
let headers = details.requestHeaders;
|
|
|
|
headers.forEach(function (header, i) {
|
|
|
|
if (header.name.toLowerCase() == 'user-agent')
|
|
|
|
header.value = faz_uaMobile;
|
|
|
|
});
|
|
|
|
if (!details.originUrl && details.type == "xmlhttprequest" ||
|
|
|
|
details.initiator == "https://www.faz.net" && details.type == "xmlhttprequest")
|
|
|
|
return { requestHeaders: headers };
|
|
|
|
}, {
|
|
|
|
urls: ["*://m.faz.net/*"]
|
|
|
|
},
|
|
|
|
["blocking", "requestHeaders"]);
|
|
|
|
|
2020-02-27 22:51:31 +01:00
|
|
|
var block_js_default = ["*://*.tinypass.com/*", "*://*.poool.fr/*", "*://*.piano.io/*", "*://*.outbrain.com/*"];
|
|
|
|
var block_js_custom = [];
|
|
|
|
var block_js = block_js_default.concat(block_js_custom);
|
2020-03-28 14:56:46 +01:00
|
|
|
|
2020-01-01 14:56:47 +01:00
|
|
|
// Disable javascript for these sites/general paywall-scripts
|
2020-03-28 14:56:46 +01:00
|
|
|
function disableJavascriptOnListedSites() {
|
|
|
|
ext_api.webRequest.onBeforeRequest.addListener(function (details) {
|
|
|
|
if (!isSiteEnabled(details)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
cancel: true
|
|
|
|
};
|
|
|
|
}, {
|
|
|
|
urls: block_js,
|
|
|
|
types: ["script"]
|
|
|
|
},
|
|
|
|
["blocking"]);
|
|
|
|
}
|
2019-04-28 17:20:17 -07:00
|
|
|
|
2020-03-25 19:27:07 +01:00
|
|
|
var extraInfoSpec = ['blocking', 'requestHeaders'];
|
|
|
|
if (ext_api.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty('EXTRA_HEADERS'))
|
|
|
|
extraInfoSpec.push('extraHeaders');
|
|
|
|
|
|
|
|
ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
2019-11-19 00:02:46 +01:00
|
|
|
var requestHeaders = details.requestHeaders;
|
|
|
|
|
|
|
|
var header_referer = '';
|
2019-11-21 21:17:32 -08:00
|
|
|
for (var n in requestHeaders) {
|
|
|
|
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
2019-11-19 00:02:46 +01:00
|
|
|
header_referer = requestHeaders[n].value;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 11:30:05 +01:00
|
|
|
|
2019-12-02 14:35:33 +01:00
|
|
|
// remove cookies for sites medium platform (mainfest.json needs in permissions: <all_urls>)
|
2020-05-01 12:57:33 +02:00
|
|
|
if (isSiteEnabled({url: 'https://medium.com'}) && matchUrlDomain('cdn-client.medium.com', details.url) && !matchUrlDomain('medium.com', header_referer)) {
|
|
|
|
ext_api.cookies.getAll({domain: urlHost(header_referer)}, function(cookies) {
|
|
|
|
for (var i=0; i<cookies.length; i++) {
|
|
|
|
ext_api.cookies.remove({url: (cookies[i].secure ? "https://" : "http://") + cookies[i].domain + cookies[i].path, name: cookies[i].name});
|
|
|
|
}
|
|
|
|
});
|
2019-11-30 13:31:52 +01:00
|
|
|
}
|
2020-01-09 11:30:05 +01:00
|
|
|
|
2019-11-19 00:02:46 +01:00
|
|
|
// check for blocked regular expression: domain enabled, match regex, block on an internal or external regex
|
2020-05-01 12:57:33 +02:00
|
|
|
var blockedDomains = Object.keys(blockedRegexes);
|
2020-05-02 11:09:51 +02:00
|
|
|
var domain = (matchUrlDomain(blockedDomains, details.url) || matchUrlDomain(blockedDomains, header_referer));
|
|
|
|
if (domain && details.url.match(blockedRegexes[domain]) && (isSiteEnabled({url: details.url}) || isSiteEnabled({url: header_referer}))) {
|
2020-05-01 12:57:33 +02:00
|
|
|
// allow BG paywall-script to set cookies in homepage/sections (else no article-text)
|
|
|
|
if (domain == 'bostonglobe.com' &&
|
|
|
|
(header_referer === 'https://www.bostonglobe.com/' || header_referer.includes('/?p1=BGHeader_') || header_referer.includes('/?p1=BGMenu_'))) {
|
|
|
|
ext_api.webRequest.handlerBehaviorChanged();
|
|
|
|
} else if (domain == 'theglobeandmail.com' && !(header_referer.includes('/article-'))) {
|
|
|
|
ext_api.webRequest.handlerBehaviorChanged();
|
|
|
|
}
|
|
|
|
return { cancel: true };
|
2017-07-08 14:16:27 -07:00
|
|
|
}
|
|
|
|
|
2019-11-19 00:02:46 +01:00
|
|
|
if (!isSiteEnabled(details)) {
|
|
|
|
return;
|
2018-12-04 22:39:37 -08:00
|
|
|
}
|
|
|
|
|
2017-07-08 14:16:27 -07:00
|
|
|
var tabId = details.tabId;
|
|
|
|
|
2019-04-28 17:20:17 -07:00
|
|
|
var useUserAgentMobile = false;
|
2017-07-08 14:16:27 -07:00
|
|
|
var setReferer = false;
|
|
|
|
|
|
|
|
// if referer exists, set it to google
|
2019-04-28 17:20:17 -07:00
|
|
|
requestHeaders = requestHeaders.map(function (requestHeader) {
|
2017-07-08 14:16:27 -07:00
|
|
|
if (requestHeader.name === 'Referer') {
|
2020-05-01 12:57:33 +02:00
|
|
|
if (details.url.includes("cooking.nytimes.com/api/v1/users/bootstrap")) {
|
2020-01-29 18:09:53 +01:00
|
|
|
// this fixes images not being loaded on cooking.nytimes.com main page
|
|
|
|
// referrer has to be *nytimes.com otherwise returns 403
|
|
|
|
requestHeader.value = 'https://cooking.nytimes.com';
|
2020-05-01 12:57:33 +02:00
|
|
|
} else if (matchUrlDomain(['clarin.com', 'kleinezeitung.at', 'fd.nl'], details.url)) {
|
2019-04-28 17:20:17 -07:00
|
|
|
requestHeader.value = 'https://www.facebook.com/';
|
|
|
|
} else {
|
|
|
|
requestHeader.value = 'https://www.google.com/';
|
|
|
|
}
|
|
|
|
setReferer = true;
|
|
|
|
}
|
|
|
|
if (requestHeader.name === 'User-Agent') {
|
|
|
|
useUserAgentMobile = requestHeader.value.toLowerCase().includes("mobile");
|
|
|
|
}
|
2017-07-08 14:16:27 -07:00
|
|
|
|
2019-04-28 17:20:17 -07:00
|
|
|
return requestHeader;
|
|
|
|
});
|
2017-07-08 14:16:27 -07:00
|
|
|
|
|
|
|
// otherwise add it
|
|
|
|
if (!setReferer) {
|
2020-05-01 12:57:33 +02:00
|
|
|
if (matchUrlDomain(['clarin.com', 'kleinezeitung.at', 'fd.nl'], details.url)) {
|
2017-07-08 14:16:27 -07:00
|
|
|
requestHeaders.push({
|
|
|
|
name: 'Referer',
|
|
|
|
value: 'https://www.facebook.com/'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
requestHeaders.push({
|
|
|
|
name: 'Referer',
|
|
|
|
value: 'https://www.google.com/'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-12 14:00:27 -07:00
|
|
|
// override User-Agent to use Googlebot
|
2020-05-01 12:57:33 +02:00
|
|
|
if (matchUrlDomain(use_google_bot, details.url)) {
|
2019-04-28 17:20:17 -07:00
|
|
|
requestHeaders.push({
|
|
|
|
"name": "User-Agent",
|
|
|
|
"value": useUserAgentMobile ? userAgentMobile : userAgentDesktop
|
|
|
|
})
|
2019-05-12 14:00:27 -07:00
|
|
|
requestHeaders.push({
|
|
|
|
"name": "X-Forwarded-For",
|
|
|
|
"value": "66.249.66.1"
|
|
|
|
})
|
2019-04-28 17:20:17 -07:00
|
|
|
}
|
|
|
|
|
2017-07-08 14:16:27 -07:00
|
|
|
// remove cookies before page load
|
2020-05-01 12:57:33 +02:00
|
|
|
if (!matchUrlDomain(allow_cookies, details.url)) {
|
|
|
|
requestHeaders = requestHeaders.map(function(requestHeader) {
|
|
|
|
if (requestHeader.name === 'Cookie') {
|
|
|
|
requestHeader.value = '';
|
2017-07-08 14:16:27 -07:00
|
|
|
}
|
2020-05-01 12:57:33 +02:00
|
|
|
return requestHeader;
|
|
|
|
});
|
|
|
|
}
|
2017-07-08 14:16:27 -07:00
|
|
|
|
|
|
|
if (tabId !== -1) {
|
|
|
|
// run contentScript inside tab
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.tabs.executeScript(tabId, {
|
2017-07-08 14:16:27 -07:00
|
|
|
file: 'contentScript.js',
|
|
|
|
runAt: 'document_start'
|
|
|
|
}, function(res) {
|
2020-03-25 19:27:07 +01:00
|
|
|
if (ext_api.runtime.lastError || res[0]) {
|
2017-07-08 14:16:27 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return { requestHeaders: requestHeaders };
|
|
|
|
}, {
|
|
|
|
urls: ['<all_urls>']
|
2020-03-25 19:27:07 +01:00
|
|
|
}, extraInfoSpec);
|
|
|
|
// extraInfoSpec is ['blocking', 'requestHeaders'] + possible 'extraHeaders'
|
2017-07-08 14:16:27 -07:00
|
|
|
|
2020-05-01 12:57:33 +02:00
|
|
|
ext_api.tabs.onUpdated.addListener(function (tabId, info, tab) { updateBadge(tab); });
|
|
|
|
ext_api.tabs.onActivated.addListener(function (activeInfo) { ext_api.tabs.get(activeInfo.tabId, updateBadge); });
|
|
|
|
|
|
|
|
let cachedBadgeText = '';
|
|
|
|
function updateBadge (activeTab) {
|
|
|
|
if (!activeTab) { return; }
|
|
|
|
const badgeText = getTextB(activeTab.url);
|
|
|
|
if (cachedBadgeText === badgeText) { return; }
|
|
|
|
cachedBadgeText = badgeText;
|
|
|
|
ext_api.browserAction.setBadgeBackgroundColor({color: 'red'});
|
|
|
|
ext_api.browserAction.setBadgeText({text: badgeText});
|
2020-03-03 22:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTextB(currentUrl) {
|
2020-04-13 19:09:49 +02:00
|
|
|
return currentUrl && isSiteEnabled({url: currentUrl}) ? 'ON' : '';
|
2020-03-03 22:34:25 +01:00
|
|
|
}
|
|
|
|
|
2017-07-08 14:16:27 -07:00
|
|
|
// remove cookies after page load
|
2020-03-25 19:27:07 +01:00
|
|
|
ext_api.webRequest.onCompleted.addListener(function (details) {
|
2020-05-01 12:57:33 +02:00
|
|
|
var domainVar = matchUrlDomain(remove_cookies, details.url);
|
|
|
|
if (!domainVar || !enabledSites.includes(domainVar))
|
|
|
|
return;
|
|
|
|
ext_api.cookies.getAll({
|
|
|
|
domain: domainVar
|
|
|
|
}, function (cookies) {
|
|
|
|
for (var i = 0; i < cookies.length; i++) {
|
|
|
|
var cookie_domain = cookies[i].domain;
|
|
|
|
var rc_domain = cookie_domain.replace(/^(\.?www\.|\.)/, '');
|
|
|
|
// hold specific cookie(s) from remove_cookies domains
|
|
|
|
if ((rc_domain in remove_cookies_select_hold) && remove_cookies_select_hold[rc_domain].includes(cookies[i].name)) {
|
|
|
|
continue; // don't remove specific cookie
|
2020-03-25 19:27:07 +01:00
|
|
|
}
|
2020-05-01 12:57:33 +02:00
|
|
|
// drop only specific cookie(s) from remove_cookies domains
|
|
|
|
if ((rc_domain in remove_cookies_select_drop) && !(remove_cookies_select_drop[rc_domain].includes(cookies[i].name))) {
|
|
|
|
continue; // only remove specific cookie
|
|
|
|
}
|
|
|
|
ext_api.cookies.remove({
|
|
|
|
url: (cookies[i].secure ? "https://" : "http://") + cookies[i].domain + cookies[i].path,
|
|
|
|
name: cookies[i].name
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-07-08 14:16:27 -07:00
|
|
|
}, {
|
2020-03-25 19:27:07 +01:00
|
|
|
urls: ["<all_urls>"]
|
2017-07-08 14:16:27 -07:00
|
|
|
});
|
|
|
|
|
2019-02-06 23:17:42 -08:00
|
|
|
function isSiteEnabled(details) {
|
2020-05-01 12:57:33 +02:00
|
|
|
var enabledSite = matchUrlDomain(enabledSites, details.url);
|
2019-02-06 23:17:42 -08:00
|
|
|
if (enabledSite in restrictions) {
|
2020-05-01 12:57:33 +02:00
|
|
|
return restrictions[enabledSite].test(details.url);
|
2019-02-06 23:17:42 -08:00
|
|
|
}
|
2020-05-01 12:57:33 +02:00
|
|
|
return !!enabledSite;
|
|
|
|
}
|
|
|
|
|
|
|
|
function matchDomain(domains, hostname) {
|
|
|
|
var matched_domain = false;
|
|
|
|
if (!hostname)
|
|
|
|
hostname = window.location.hostname;
|
|
|
|
if (typeof domains === 'string')
|
|
|
|
domains = [domains];
|
|
|
|
domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain));
|
|
|
|
return matched_domain;
|
|
|
|
}
|
|
|
|
|
|
|
|
function urlHost(url) {
|
|
|
|
if (url.startsWith('http')) {
|
|
|
|
try {
|
|
|
|
return new URL(url).hostname;
|
|
|
|
} catch (e) {
|
|
|
|
console.log(`url not valid: ${url} error: ${e}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
function matchUrlDomain(domains, url) {
|
|
|
|
return matchDomain(domains, urlHost(url));
|
2019-02-06 23:17:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getParameterByName(name, url) {
|
|
|
|
if (!url) url = window.location.href;
|
|
|
|
name = name.replace(/[\[\]]/g, '\\$&');
|
|
|
|
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
|
|
|
|
results = regex.exec(url);
|
|
|
|
if (!results) return null;
|
|
|
|
if (!results[2]) return '';
|
|
|
|
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
2019-02-07 19:23:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function stripQueryStringAndHashFromPath(url) {
|
|
|
|
return url.split("?")[0].split("#")[0];
|
2020-01-11 21:01:03 +01:00
|
|
|
}
|