2020-01-15 17:58:10 +00:00
|
|
|
/* Please respect alphabetical order when adding a site in any list */
|
|
|
|
|
2017-07-08 17:40:29 +00:00
|
|
|
'use strict';
|
2020-05-01 10:58:36 +00:00
|
|
|
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2020-01-14 19:02:04 +00:00
|
|
|
// Cookies from this list are blocked by default (obsolete)
|
2020-02-25 21:47:05 +00:00
|
|
|
// defaultSites are loaded from sites.js at installation extension
|
|
|
|
// var defaultSites = {};
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2018-01-31 05:08:11 +00:00
|
|
|
const restrictions = {
|
2020-06-15 20:21:42 +00:00
|
|
|
'barrons.com': /.+barrons\.com\/(amp\/)?article(s)?\/.+/,
|
2020-09-24 18:50:29 +00:00
|
|
|
'bloombergquint.com': /^((?!\.bloombergquint\.com\/bq-blue-exclusive\/).)*$/,
|
2020-04-03 12:07:30 +00:00
|
|
|
'elcomercio.pe': /.+\/elcomercio.pe\/.+((\w)+(\-)+){3,}.+/,
|
|
|
|
'gestion.pe': /.+\/gestion.pe\/.+((\w)+(\-)+){3,}.+/,
|
2020-09-12 13:40:50 +00:00
|
|
|
'nknews.org': /^((?!\.nknews\.org\/pro\/).)*$/,
|
2020-05-27 15:11:31 +00:00
|
|
|
'quora.com': /^((?!quora\.com\/search\?q=).)*$/,
|
2020-08-20 17:01:12 +00:00
|
|
|
'seekingalpha.com': /.+seekingalpha\.com\/article\/.+/,
|
|
|
|
'wsj.com': /^((?!\/cn\.wsj\.com\/).)*$/
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't remove cookies before page load
|
2020-02-25 21:47:05 +00:00
|
|
|
// allow_cookies are completed with domains in sites.js (default allow/remove_cookies)
|
2020-01-28 22:06:25 +00:00
|
|
|
var allow_cookies = [
|
2020-06-27 12:22:39 +00:00
|
|
|
'abc.es',
|
2020-03-04 17:55:47 +00:00
|
|
|
'aftonbladet.se',
|
2020-07-05 11:11:58 +00:00
|
|
|
'belfasttelegraph.co.uk',
|
2020-01-28 22:06:25 +00:00
|
|
|
'bostonglobe.com',
|
2020-07-04 11:33:25 +00:00
|
|
|
'business-standard.com',
|
2020-02-16 15:35:17 +00:00
|
|
|
'clarin.com',
|
2020-08-28 16:05:57 +00:00
|
|
|
'chronicle.com',
|
2020-03-19 19:12:04 +00:00
|
|
|
'demorgen.be',
|
2020-08-26 15:29:51 +00:00
|
|
|
'df.cl',
|
2020-01-28 22:06:25 +00:00
|
|
|
'dn.se',
|
2020-02-12 17:55:28 +00:00
|
|
|
'dvhn.nl',
|
2020-09-16 06:28:15 +00:00
|
|
|
'editorialedomani.it',
|
2020-02-09 14:51:34 +00:00
|
|
|
'elmercurio.com',
|
2020-10-04 12:58:08 +00:00
|
|
|
'elpais.com',
|
2020-08-26 15:18:51 +00:00
|
|
|
'mercuriovalpo.cl',
|
2020-04-11 18:11:34 +00:00
|
|
|
'eurekareport.com.au',
|
2020-04-25 15:18:12 +00:00
|
|
|
'faz.net',
|
2020-01-28 22:06:25 +00:00
|
|
|
'folha.uol.com.br',
|
2020-06-18 18:55:18 +00:00
|
|
|
'ftm.nl',
|
2020-04-03 12:07:30 +00:00
|
|
|
'gestion.pe',
|
2020-01-05 15:19:01 +00:00
|
|
|
'haaretz.co.il',
|
|
|
|
'haaretz.com',
|
2020-01-11 13:05:12 +00:00
|
|
|
'handelsblatt.com',
|
2020-02-25 22:33:18 +00:00
|
|
|
'humo.be',
|
2020-06-27 11:49:37 +00:00
|
|
|
'ilfattoquotidiano.it',
|
2020-06-08 14:44:46 +00:00
|
|
|
'independent.ie',
|
2020-04-11 18:11:34 +00:00
|
|
|
'intelligentinvestor.com.au',
|
2020-06-26 17:56:58 +00:00
|
|
|
'knack.be',
|
2020-02-12 17:55:28 +00:00
|
|
|
'lc.nl',
|
2020-09-14 19:29:13 +00:00
|
|
|
'lesechos.fr',
|
2020-07-16 14:20:06 +00:00
|
|
|
'lesoir.be',
|
2020-08-21 07:41:41 +00:00
|
|
|
'limesonline.com',
|
2020-01-25 13:56:18 +00:00
|
|
|
'lrb.co.uk',
|
2020-01-28 22:06:25 +00:00
|
|
|
'mexiconewsdaily.com',
|
2020-01-31 14:19:17 +00:00
|
|
|
'modernhealthcare.com',
|
2020-06-17 14:45:16 +00:00
|
|
|
'nationalgeographic.com',
|
2020-01-31 14:01:53 +00:00
|
|
|
'nationalreview.com',
|
2020-03-23 16:59:16 +00:00
|
|
|
'newrepublic.com',
|
2020-09-12 13:40:50 +00:00
|
|
|
'nknews.org',
|
2020-08-02 10:35:09 +00:00
|
|
|
'noordhollandsdagblad.nl',
|
2020-10-04 06:46:46 +00:00
|
|
|
'nrz.de',
|
2019-10-23 11:06:43 +00:00
|
|
|
'nytimes.com',
|
2020-07-08 15:58:08 +00:00
|
|
|
'nzz.ch',
|
2019-10-14 12:52:27 +00:00
|
|
|
'parool.nl',
|
2020-01-05 15:19:01 +00:00
|
|
|
'quora.com',
|
2020-10-02 16:41:44 +00:00
|
|
|
'repubblica.it',
|
2020-09-26 19:20:24 +00:00
|
|
|
'rollingstone.com',
|
2020-01-05 16:41:06 +00:00
|
|
|
'scribd.com',
|
2020-02-26 22:16:03 +00:00
|
|
|
'seekingalpha.com',
|
2020-06-26 16:54:43 +00:00
|
|
|
'slader.com',
|
2020-09-14 19:50:13 +00:00
|
|
|
'startribune.com',
|
2020-09-26 15:27:41 +00:00
|
|
|
'stocknews.com',
|
2020-01-14 19:02:04 +00:00
|
|
|
'techinasia.com',
|
2020-01-28 22:06:25 +00:00
|
|
|
'the-american-interest.com',
|
2020-07-09 18:53:36 +00:00
|
|
|
'thehindu.com',
|
2020-01-05 15:19:01 +00:00
|
|
|
'themarker.com',
|
2020-09-25 12:59:06 +00:00
|
|
|
'timeshighereducation.com',
|
2019-10-14 12:52:27 +00:00
|
|
|
'trouw.nl',
|
2020-09-19 16:10:54 +00:00
|
|
|
'variety.com',
|
2019-10-23 11:06:43 +00:00
|
|
|
'volkskrant.nl',
|
2020-08-22 18:25:53 +00:00
|
|
|
'washingtonpost.com',
|
2020-09-28 18:43:29 +00:00
|
|
|
'waz.de',
|
2020-01-31 13:17:59 +00:00
|
|
|
'worldpoliticsreview.com',
|
2020-10-04 06:46:46 +00:00
|
|
|
'wp.de',
|
|
|
|
'wr.de',
|
2020-09-24 18:50:29 +00:00
|
|
|
'zeit.de',
|
2017-07-08 17:40:29 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
// Removes cookies after page load
|
2020-02-25 21:47:05 +00:00
|
|
|
// remove_cookies are completed with domains of sites.js (default allow/remove_cookies)
|
2020-01-14 19:02:04 +00:00
|
|
|
var remove_cookies = [
|
2017-07-08 17:40:29 +00:00
|
|
|
]
|
|
|
|
|
2019-10-25 13:00:08 +00:00
|
|
|
// select specific cookie(s) to hold from remove_cookies domains
|
|
|
|
const remove_cookies_select_hold = {
|
2020-03-22 12:22:30 +00:00
|
|
|
'barrons.com': ['wsjregion'],
|
2020-01-13 21:23:03 +00:00
|
|
|
'newstatesman.com': ['STYXKEY_nsversion'],
|
|
|
|
'qz.com': ['gdpr'],
|
2020-03-20 10:21:55 +00:00
|
|
|
'wsj.com': ['wsjregion']
|
2019-10-25 13:00:08 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 17:11:29 +00: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 13:00:08 +00:00
|
|
|
// select only specific cookie(s) to drop from remove_cookies domains
|
2020-04-13 17:11:29 +00:00
|
|
|
var remove_cookies_select_drop = {
|
2019-11-17 19:26:29 +00:00
|
|
|
'ad.nl': ['temptationTrackingId'],
|
2019-12-20 18:13:21 +00:00
|
|
|
'caixinglobal.com': ['CAIXINGLB_LOGIN_UUID'],
|
2020-01-28 22:06:25 +00:00
|
|
|
'dn.se': ['randomSplusId'],
|
2020-04-03 19:03:27 +00:00
|
|
|
'fd.nl': ['socialread'],
|
2020-01-28 22:06:25 +00:00
|
|
|
'nrc.nl': ['counter'],
|
|
|
|
'theatlantic.com': ['articleViews']
|
2019-10-25 13:00:08 +00:00
|
|
|
}
|
2020-04-13 17:11:29 +00:00
|
|
|
for (var domainIndex in ad_region_domains) {
|
|
|
|
let domain = ad_region_domains[domainIndex];
|
|
|
|
remove_cookies_select_drop[domain] = ['temptationTrackingId'];
|
|
|
|
}
|
2019-10-25 13:00:08 +00:00
|
|
|
|
2019-05-12 20:44:03 +00:00
|
|
|
// Override User-Agent with Googlebot
|
2020-07-06 17:30:48 +00:00
|
|
|
var use_google_bot_default = [
|
2020-06-27 12:22:39 +00:00
|
|
|
'abc.es',
|
2020-03-04 17:55:47 +00:00
|
|
|
'aftonbladet.se',
|
2019-10-22 12:37:02 +00:00
|
|
|
'barrons.com',
|
2020-08-26 15:29:51 +00:00
|
|
|
'df.cl',
|
2020-01-28 22:06:25 +00:00
|
|
|
'dn.se',
|
2020-09-16 06:28:15 +00:00
|
|
|
'editorialedomani.it',
|
2020-04-11 18:11:34 +00:00
|
|
|
'eurekareport.com.au',
|
2020-03-13 11:07:54 +00:00
|
|
|
'ft.com',
|
2020-01-05 12:02:44 +00:00
|
|
|
'haaretz.co.il',
|
|
|
|
'haaretz.com',
|
2020-01-11 13:05:12 +00:00
|
|
|
'handelsblatt.com',
|
2020-04-11 18:11:34 +00:00
|
|
|
'intelligentinvestor.com.au',
|
2020-07-16 14:20:06 +00:00
|
|
|
'lesoir.be',
|
2020-01-28 22:06:25 +00:00
|
|
|
'mexiconewsdaily.com',
|
2020-04-28 07:46:27 +00:00
|
|
|
'miamiherald.com',
|
2020-07-08 15:58:08 +00:00
|
|
|
'nzz.ch',
|
2019-10-29 18:27:54 +00:00
|
|
|
'quora.com',
|
2020-06-14 16:37:06 +00:00
|
|
|
'republic.ru',
|
2020-02-26 22:16:03 +00:00
|
|
|
'seekingalpha.com',
|
2020-01-05 12:02:44 +00:00
|
|
|
'themarker.com',
|
2019-05-12 20:44:03 +00:00
|
|
|
'thetimes.co.uk',
|
2020-08-22 18:25:53 +00:00
|
|
|
'washingtonpost.com',
|
2020-01-31 13:17:59 +00:00
|
|
|
'worldpoliticsreview.com',
|
2020-09-24 18:50:29 +00:00
|
|
|
'zeit.de',
|
2020-02-28 15:23:17 +00:00
|
|
|
];
|
|
|
|
var use_google_bot_custom = [];
|
|
|
|
var use_google_bot = use_google_bot_default.concat(use_google_bot_custom);
|
2020-03-10 18:12:25 +00:00
|
|
|
|
2020-01-28 22:06:25 +00:00
|
|
|
// block paywall-scripts individually
|
|
|
|
var blockedRegexes = {
|
|
|
|
'adweek.com': /.+\.lightboxcdn\.com\/.+/,
|
2020-01-15 17:58:10 +00:00
|
|
|
'afr.com': /afr\.com\/assets\/vendorsReactRedux_client.+\.js/,
|
2020-02-14 12:08:15 +00:00
|
|
|
'americanbanker.com': /.+\.tinypass\.com\/.+/,
|
2020-06-15 20:21:42 +00:00
|
|
|
'barrons.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/,
|
2020-07-05 11:11:58 +00:00
|
|
|
'belfasttelegraph.co.uk': /cdn\.flip-pay\.com\/clients\/inm\/flip-pay\.js/,
|
2020-09-08 14:38:18 +00:00
|
|
|
'bizjournals.com': /(assets\.bizjournals\.com\/static\/js\/app\/cxense\.js|cdn\.cxense\.com)/,
|
2020-02-22 12:21:18 +00:00
|
|
|
'bloomberg.com': /.+\.tinypass\.com\/.+/,
|
2020-01-15 17:58:10 +00:00
|
|
|
'bostonglobe.com': /meter\.bostonglobe\.com\/js\/.+/,
|
2020-09-11 16:07:02 +00:00
|
|
|
'brisbanetimes.com.au': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/,
|
2020-07-16 14:20:06 +00:00
|
|
|
'businessinsider.com': /.+\.tinypass\.com\/.+/,
|
2020-05-02 19:55:47 +00:00
|
|
|
'challenges.fr': /.+\.poool\.fr\/.+/,
|
2020-07-25 07:06:49 +00:00
|
|
|
'charliehebdo.fr': /.+\.poool\.fr\/.+/,
|
2020-01-28 22:06:25 +00:00
|
|
|
'chicagobusiness.com': /.+\.tinypass\.com\/.+/,
|
2020-07-15 16:53:16 +00:00
|
|
|
'chicagotribune.com': /.+:\/\/.+\.tribdss\.com\/.+/,
|
2020-08-28 16:05:57 +00:00
|
|
|
'chronicle.com': /(.+\.blueconic\.net\/.+|assets\.login\.chronicle\.com\/common\/che-auth0-user\.js)/,
|
2020-07-15 16:53:16 +00:00
|
|
|
'clarin.com': /js\.matheranalytics\.com\/.+/,
|
2020-07-16 14:20:06 +00:00
|
|
|
'corriere.it': /(\.rcsobjects\.it\/(rcs_cpmt|rcs_tracking-service)\/|\.corriereobjects\.it\/.+\/js\/(_paywall\.sjs|tracking\/)|\.userzoom\.com\/files\/js\/|\.lp4\.io\/app\/)/,
|
2020-01-28 22:06:25 +00:00
|
|
|
'digiday.com': /.+\.tinypass\.com\/.+/,
|
2020-08-22 17:38:39 +00:00
|
|
|
'economist.com': /.+\.tinypass\.com\/.+/,
|
2020-10-02 14:38:16 +00:00
|
|
|
'editorialedomani.it': /(.+\.editorialedomani\.it\/pelcro\.js|js\.pelcro\.com\/.+)/,
|
2020-06-18 05:59:22 +00:00
|
|
|
'estadao.com.br': /acesso\.estadao\.com\.br\/paywall\/.+\/pw\.js/,
|
2020-06-17 14:29:36 +00:00
|
|
|
'dvhn.nl': /.+\.evolok\.net\/.+\/authorize\/.+/,
|
2020-04-25 18:41:55 +00:00
|
|
|
'elcomercio.pe': /elcomercio\.pe\/pf\/dist\/template\/elcomercio-noticia.+\.js/,
|
2020-07-29 14:51:35 +00:00
|
|
|
'elmercurio.com': /(elmercurio\.com\/.+\/js\/modal\.js|merreader\.emol\.cl\/assets\/js\/(vendor\/modal|merPramV\d)\.js|staticmer(\d)?\.emol\.cl\/js\/.+\/(modal|PramModal\.min)\.js)/,
|
2020-05-25 19:01:41 +00:00
|
|
|
'elmundo.es': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/,
|
2020-01-28 22:06:25 +00:00
|
|
|
'elpais.com': /.+\.epimg\.net\/js\/.+\/noticia\.min\.js/,
|
|
|
|
'exame.abril.com.br': /.+\.tinypass\.com\/.+/,
|
|
|
|
'folha.uol.com.br': /.+\.folha\.uol\.com\.br\/paywall\/js\/.+\/publicidade\.ads\.js/,
|
|
|
|
'globo.com': /.+\.tinypass\.com\/.+/,
|
2019-12-08 18:34:26 +00:00
|
|
|
'foreignpolicy.com': /.+\.tinypass\.com\/.+/,
|
2020-01-28 22:06:25 +00:00
|
|
|
'fortune.com': /.+\.tinypass\.com\/.+/,
|
2020-06-18 18:55:18 +00:00
|
|
|
'ftm.nl': /.+\.ftm\.nl\/js\/routing\?/,
|
2020-09-05 14:59:14 +00:00
|
|
|
'fresnobee.com': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/,
|
2020-04-25 18:41:55 +00:00
|
|
|
'gestion.pe': /gestion\.pe\/pf\/dist\/template\/gestion-noticia.+\.js/,
|
2020-05-15 14:05:03 +00:00
|
|
|
'globes.co.il': /.+\.tinypass\.com\/.+/,
|
2020-01-15 17:58:10 +00:00
|
|
|
'haaretz.co.il': /haaretz\.co\.il\/htz\/js\/inter\.js/,
|
2020-01-28 22:06:25 +00:00
|
|
|
'haaretz.com': /haaretz\.com\/hdc\/web\/js\/minified\/header-scripts-int.js.+/,
|
2020-06-06 14:46:56 +00:00
|
|
|
'historyextra.com': /.+\.evolok\.net\/.+\/authorize\/.+/,
|
2020-04-23 19:45:47 +00:00
|
|
|
'ilmessaggero.it': /(utils\.cedsdigital\.it\/js\/PaywallMeter\.js|static\.viralize\.tv\/viralize_player)/,
|
2020-06-08 14:44:46 +00:00
|
|
|
'independent.ie': /cdn\.flip-pay\.com\/clients\/inm\/flip-pay\.js/,
|
2019-12-13 13:14:55 +00:00
|
|
|
'inquirer.com': /.+\.tinypass\.com\/.+/,
|
2020-07-18 06:42:02 +00:00
|
|
|
'irishtimes.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/,
|
2020-06-26 17:56:58 +00:00
|
|
|
'knack.be': /.+\.knack\.be\/js\/responsive\/rmgModal\.js/,
|
2020-03-21 14:48:04 +00:00
|
|
|
'ladepeche.fr': /.+\.poool\.fr\/.+/,
|
2020-07-25 07:42:31 +00:00
|
|
|
'lasegunda.com': /segreader\.emol\.cl\/assets\/js\/(vendor\/modal\.js|merPramV\d\.js)/,
|
2020-01-28 22:06:25 +00:00
|
|
|
'lastampa.it': /.+\.repstatic\.it\/minify\/sites\/lastampa\/.+\/config\.cache\.php\?name=social_js/,
|
2020-06-17 14:29:36 +00:00
|
|
|
'lc.nl': /.+\.evolok\.net\/.+\/authorize\/.+/,
|
2020-05-20 15:02:34 +00:00
|
|
|
'lejdd.fr': /.+\.poool\.fr\/.+/,
|
2020-01-07 21:26:47 +00:00
|
|
|
'leparisien.fr': /.+\.tinypass\.com\/.+/,
|
2020-01-08 22:21:21 +00:00
|
|
|
'lesechos.fr': /.+\.tinypass\.com\/.+/,
|
2020-08-21 07:41:41 +00:00
|
|
|
'limesonline.com': /scripts\.repubblica\.it\/pw\/pw\.js.+/,
|
2020-03-28 17:52:19 +00:00
|
|
|
'livemint.com': /(.+\.livemint\.com\/js\/localWorker\.js|analytics\.htmedia\.in\/analytics-js\/.+\.js)/,
|
2020-03-25 08:07:43 +00:00
|
|
|
'lopinion.fr': /.+\.poool\.fr\/.+/,
|
2020-01-15 17:58:10 +00:00
|
|
|
'lrb.co.uk': /.+\.tinypass\.com\/.+/,
|
2020-08-26 15:18:51 +00:00
|
|
|
'mercuriovalpo.cl': /(.+\.mercuriovalpo\.cl\/impresa\/wp-content\/themes\/papel-digital-2019-desktop\/assets\/(vendor|\d)\.js|pram\.pasedigital\.cl\/API\/User\/Status\?)/,
|
2020-01-31 14:19:17 +00:00
|
|
|
'modernhealthcare.com': /.+\.tinypass\.com\/.+/,
|
2020-06-17 14:45:16 +00:00
|
|
|
'nationalgeographic.com': /.+\.blueconic\.net\/.+/,
|
2020-09-22 19:06:28 +00:00
|
|
|
'nationalreview.com': /(.+\.blueconic\.net\/.+|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/,
|
2020-03-23 16:59:16 +00:00
|
|
|
'newrepublic.com': /.+\.onecount\.net\/js\/.+/,
|
2020-06-29 18:00:56 +00:00
|
|
|
'newsweek.com': /.+\.googletagmanager\.com\/gtm\.js/,
|
2020-09-06 07:00:36 +00:00
|
|
|
'newyorker.com': /.+\.newyorker\.com\/verso\/static\/presenter-articles.+\.js/,
|
2020-09-12 13:40:50 +00:00
|
|
|
'nknews.org': /.+\.nknews\.org\/wp-content\/plugins\/leaky-paywall-ajax\/js\/leaky-paywall-ajax\.js/,
|
2020-03-25 18:31:28 +00:00
|
|
|
'nytimes.com': /(.+meter-svc\.nytimes\.com\/meter\.js.+|.+mwcm\.nyt\.com\/.+\.js)/,
|
2020-02-01 20:25:33 +00:00
|
|
|
'repubblica.it': /scripts\.repubblica\.it\/pw\/pw\.js.+/,
|
2020-09-26 19:20:24 +00:00
|
|
|
'rollingstone.com': /cdn\.cxense\.com/,
|
2020-09-04 17:08:36 +00:00
|
|
|
'sacbee.com': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/,
|
2020-03-31 17:32:16 +00:00
|
|
|
'science-et-vie.com': /.+\.qiota\.com\/.+/,
|
2020-05-02 07:04:23 +00:00
|
|
|
'sciencesetavenir.fr': /.+\.poool\.fr\/.+/,
|
2020-08-21 07:02:30 +00:00
|
|
|
'scmp.com': /.+\.tinypass\.com\/.+/,
|
2020-07-29 15:17:05 +00:00
|
|
|
'sfchronicle.com': /.+\.blueconic\.net\/.+/,
|
|
|
|
'sloanreview.mit.edu': /(.+\.tinypass\.com\/.+|.+\.netdna-ssl\.com\/wp-content\/themes\/smr\/assets\/js\/libs\/welcome-ad\.js)/,
|
2020-09-11 16:07:02 +00:00
|
|
|
'smh.com.au': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/,
|
2020-01-15 17:58:10 +00:00
|
|
|
'spectator.co.uk': /.+\.tinypass\.com\/.+/,
|
2020-02-02 17:20:33 +00:00
|
|
|
'spectator.com.au': /.+\.tinypass\.com\/.+/,
|
2020-08-27 19:16:38 +00:00
|
|
|
'technologyreview.com': /.+\.blueconic\.net\/.+/,
|
2020-02-14 12:08:15 +00:00
|
|
|
'telegraph.co.uk': /.+\.tinypass\.com\/.+/,
|
2020-09-10 20:01:35 +00:00
|
|
|
'theage.com.au': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/,
|
2020-01-30 17:01:37 +00:00
|
|
|
'thedailybeast.com': /.+\.tinypass\.com\/.+/,
|
2020-10-04 06:46:46 +00:00
|
|
|
'thehindu.com': /(cdn\.cxense\.com|.+\.tinypass\.com\/.+)/,
|
2020-02-20 20:11:36 +00:00
|
|
|
'thenation.com': /.+\.tinypass\.com\/.+/,
|
2020-07-13 05:47:51 +00:00
|
|
|
'valeursactuelles.com': /.+\.qiota\.com\/.+/,
|
2020-09-19 16:10:54 +00:00
|
|
|
'variety.com': /cdn\.cxense\.com/,
|
2020-10-08 21:33:49 +00:00
|
|
|
'washingtonpost.com': /.+\.washingtonpost\.com\/.+\/pwapi-proxy\.min\.js/,
|
2020-09-11 16:07:02 +00:00
|
|
|
'watoday.com.au': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/,
|
2020-09-28 18:43:29 +00:00
|
|
|
'waz.de': /(.+\.tinypass\.com\/.+|cdn\.cxense\.com)/,
|
2020-09-03 17:13:27 +00:00
|
|
|
'wsj.com': /(cdn\.ampproject\.org\/v\d\/amp-access-.+\.js|cdn\.cxense\.com)/
|
2019-11-27 18:23:00 +00:00
|
|
|
};
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2020-07-06 17:30:48 +00:00
|
|
|
const au_comm_media_domains = ['bendigoadvertiser.com.au', 'bordermail.com.au', 'canberratimes.com.au', 'centralwesterndaily.com.au', 'dailyadvertiser.com.au', 'dailyliberal.com.au', 'examiner.com.au', 'illawarramercury.com.au', 'newcastleherald.com.au', 'northerndailyleader.com.au', 'portnews.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au'];
|
2020-07-07 17:35:28 +00:00
|
|
|
const au_news_corp_domains = ['adelaidenow.com.au', 'cairnspost.com.au', 'couriermail.com.au', 'dailytelegraph.com.au', 'geelongadvertiser.com.au', 'goldcoastbulletin.com.au', 'heraldsun.com.au', 'ntnews.com.au', 'theaustralian.com.au', 'themercury.com.au', 'townsvillebulletin.com.au', 'weeklytimesnow.com.au'];
|
2020-08-15 16:26:25 +00:00
|
|
|
const au_prov_news_domains = ['news-mail.com.au', 'frasercoastchronicle.com.au', 'gladstoneobserver.com.au', 'dailyexaminer.com.au', 'dailymercury.com.au', 'themorningbulletin.com.au', 'sunshinecoastdaily.com.au', 'gympietimes.com.au', 'northernstar.com.au', 'qt.com.au', 'thechronicle.com.au', 'warwickdailynews.com.au'];
|
2020-07-06 17:30:48 +00:00
|
|
|
|
2019-04-06 23:34:30 +00: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 17:40:29 +00:00
|
|
|
var enabledSites = [];
|
2020-08-20 17:01:12 +00:00
|
|
|
var disabledSites = [];
|
|
|
|
var defaultSites_domains = Object.values(defaultSites);
|
|
|
|
var customSites = {};
|
|
|
|
var customSites_domains = [];
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2020-01-28 22:06:25 +00:00
|
|
|
function setDefaultOptions() {
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.storage.sync.set({
|
2020-01-28 22:06:25 +00:00
|
|
|
sites: defaultSites
|
|
|
|
}, function() {
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.runtime.openOptionsPage();
|
2020-01-28 22:06:25 +00:00
|
|
|
});
|
2020-03-27 18:02:27 +00:00
|
|
|
}
|
2020-03-25 18:31:28 +00:00
|
|
|
|
2020-01-15 17:58:10 +00:00
|
|
|
// Get the enabled sites (from local storage) & add to allow/remove_cookies (if not already in one of these arrays)
|
2020-02-28 15:23:17 +00:00
|
|
|
// Add googlebot- and block_javascript-settings for custom sites
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.storage.sync.get({
|
2020-02-28 15:23:17 +00:00
|
|
|
sites: {},
|
|
|
|
sites_custom: {}
|
|
|
|
}, function (items) {
|
|
|
|
var sites = items.sites;
|
|
|
|
var sites_custom = items.sites_custom;
|
|
|
|
|
2020-06-04 07:04:58 +00:00
|
|
|
for (let key in sites_custom) {
|
|
|
|
var domainVar = sites_custom[key]['domain'].toLowerCase();
|
|
|
|
if (sites_custom[key]['googlebot'] > 0 && !use_google_bot.includes(domainVar)) {
|
|
|
|
use_google_bot.push(domainVar);
|
|
|
|
}
|
|
|
|
if (sites_custom[key]['block_javascript'] > 0) {
|
|
|
|
block_js_custom.push(domainVar);
|
|
|
|
}
|
|
|
|
if (sites_custom[key]['block_javascript_ext'] > 0) {
|
|
|
|
block_js_custom_ext.push(domainVar);
|
|
|
|
}
|
|
|
|
}
|
2020-02-28 15:23:17 +00:00
|
|
|
|
2020-02-29 19:08:32 +00:00
|
|
|
enabledSites = Object.keys(sites).filter(function (key) {
|
|
|
|
return (sites[key] !== '' && sites[key] !== '###');
|
|
|
|
}).map(function (key) {
|
2020-03-09 20:11:38 +00:00
|
|
|
return sites[key].toLowerCase();
|
2020-02-28 15:23:17 +00:00
|
|
|
});
|
2020-08-20 17:01:12 +00:00
|
|
|
customSites = sites_custom;
|
|
|
|
customSites_domains = Object.values(sites_custom).map(x => x.domain);
|
|
|
|
disabledSites = defaultSites_domains.concat(customSites_domains).filter(x => !enabledSites.includes(x) && x !== '###');
|
2020-07-06 17:30:48 +00:00
|
|
|
if (enabledSites.includes('ad.nl'))
|
2020-04-13 17:11:29 +00:00
|
|
|
enabledSites = enabledSites.concat(ad_region_domains);
|
2020-07-06 17:30:48 +00:00
|
|
|
if (enabledSites.includes('###_au_comm_media')) {
|
|
|
|
enabledSites = enabledSites.concat(au_comm_media_domains);
|
|
|
|
for (let domain of au_comm_media_domains) {
|
2020-07-07 17:35:28 +00:00
|
|
|
allow_cookies.push(domain);
|
2020-07-06 17:30:48 +00:00
|
|
|
blockedRegexes[domain] = /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/;
|
|
|
|
}
|
2020-08-23 18:50:30 +00:00
|
|
|
} else
|
|
|
|
disabledSites = disabledSites.concat(au_comm_media_domains);
|
2020-07-07 17:35:28 +00:00
|
|
|
if (enabledSites.includes('###_au_news_corp')) {
|
|
|
|
enabledSites = enabledSites.concat(au_news_corp_domains);
|
|
|
|
for (let domain of au_news_corp_domains) {
|
2020-07-06 17:30:48 +00:00
|
|
|
allow_cookies.push(domain);
|
2020-09-30 14:52:37 +00:00
|
|
|
use_google_bot.push(domain);
|
2020-07-06 17:30:48 +00:00
|
|
|
}
|
2020-08-23 18:50:30 +00:00
|
|
|
} else
|
|
|
|
disabledSites = disabledSites.concat(au_news_corp_domains);
|
2020-08-15 16:26:25 +00:00
|
|
|
if (enabledSites.includes('###_au_prov_news')) {
|
|
|
|
enabledSites = enabledSites.concat(au_prov_news_domains);
|
|
|
|
for (let domain of au_prov_news_domains) {
|
|
|
|
allow_cookies.push(domain);
|
|
|
|
}
|
2020-08-23 18:50:30 +00:00
|
|
|
} else
|
|
|
|
disabledSites = disabledSites.concat(au_prov_news_domains);
|
2020-02-29 19:08:32 +00:00
|
|
|
|
2020-06-04 07:04:58 +00:00
|
|
|
for (let domainVar of enabledSites) {
|
2020-02-28 15:23:17 +00:00
|
|
|
if (!allow_cookies.includes(domainVar) && !remove_cookies.includes(domainVar)) {
|
|
|
|
allow_cookies.push(domainVar);
|
|
|
|
remove_cookies.push(domainVar);
|
|
|
|
}
|
|
|
|
}
|
2020-03-28 13:59:26 +00:00
|
|
|
disableJavascriptOnListedSites();
|
2020-01-14 19:02:04 +00:00
|
|
|
});
|
|
|
|
|
2017-07-08 17:40:29 +00:00
|
|
|
// Listen for changes to options
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.storage.onChanged.addListener(function (changes, namespace) {
|
2020-02-28 15:23:17 +00:00
|
|
|
for (var key in changes) {
|
|
|
|
var storageChange = changes[key];
|
|
|
|
if (key === 'sites') {
|
|
|
|
var sites = storageChange.newValue;
|
2020-02-29 19:08:32 +00:00
|
|
|
enabledSites = Object.keys(sites).filter(function (key) {
|
|
|
|
return (sites[key] !== '' && sites[key] !== '###');
|
|
|
|
}).map(function (key) {
|
2020-02-28 15:23:17 +00:00
|
|
|
return sites[key];
|
|
|
|
});
|
2020-08-20 17:01:12 +00:00
|
|
|
disabledSites = defaultSites_domains.concat(customSites_domains).filter(x => !enabledSites.includes(x) && x !== '###');
|
2020-07-06 17:30:48 +00:00
|
|
|
if (enabledSites.includes('ad.nl'))
|
2020-04-13 17:11:29 +00:00
|
|
|
enabledSites = enabledSites.concat(ad_region_domains);
|
2020-07-06 17:30:48 +00:00
|
|
|
if (enabledSites.includes('###_au_comm_media'))
|
|
|
|
enabledSites = enabledSites.concat(au_comm_media_domains);
|
2020-08-23 18:50:30 +00:00
|
|
|
else
|
|
|
|
disabledSites = disabledSites.concat(au_comm_media_domains);
|
2020-07-07 17:35:28 +00:00
|
|
|
if (enabledSites.includes('###_au_news_corp'))
|
|
|
|
enabledSites = enabledSites.concat(au_news_corp_domains);
|
2020-08-23 18:50:30 +00:00
|
|
|
else
|
|
|
|
disabledSites = disabledSites.concat(au_news_corp_domains);
|
2020-08-15 16:26:25 +00:00
|
|
|
if (enabledSites.includes('###_au_prov_news'))
|
|
|
|
enabledSites = enabledSites.concat(au_prov_news_domains);
|
2020-08-23 18:50:30 +00:00
|
|
|
else
|
|
|
|
disabledSites = disabledSites.concat(au_prov_news_domains);
|
2020-07-06 17:30:48 +00:00
|
|
|
// reset disableJavascriptOnListedSites eventListener
|
2020-03-28 13:59:26 +00:00
|
|
|
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
|
|
|
|
ext_api.webRequest.handlerBehaviorChanged();
|
2020-02-28 15:23:17 +00:00
|
|
|
}
|
|
|
|
if (key === 'sites_custom') {
|
|
|
|
var sites_custom = storageChange.newValue;
|
2020-08-16 07:27:33 +00:00
|
|
|
var sites_custom_old = storageChange.oldValue;
|
2020-08-20 17:01:12 +00:00
|
|
|
customSites = sites_custom;
|
|
|
|
customSites_domains = Object.values(sites_custom).map(x => x.domain);
|
2020-08-16 07:27:33 +00:00
|
|
|
|
|
|
|
// add/remove custom sites in options
|
|
|
|
var sites_custom_added = Object.keys(sites_custom).filter(x => !Object.keys(sites_custom_old).includes(x) && !defaultSites.hasOwnProperty(x));
|
|
|
|
var sites_custom_removed = Object.keys(sites_custom_old).filter(x => !Object.keys(sites_custom).includes(x) && !defaultSites.hasOwnProperty(x));
|
|
|
|
|
|
|
|
chrome.storage.sync.get({
|
|
|
|
sites: {}
|
|
|
|
}, function (items) {
|
|
|
|
var sites = items.sites;
|
|
|
|
for (var key of sites_custom_added)
|
|
|
|
sites[key] = sites_custom[key].domain;
|
|
|
|
for (var key of sites_custom_removed)
|
|
|
|
delete sites[key];
|
|
|
|
|
|
|
|
chrome.storage.sync.set({
|
|
|
|
sites: sites
|
|
|
|
}, function () {
|
|
|
|
true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-28 15:23:17 +00:00
|
|
|
use_google_bot = use_google_bot_default.slice();
|
2020-06-04 07:04:58 +00:00
|
|
|
block_js_custom = [];
|
|
|
|
block_js_custom_ext = [];
|
|
|
|
for (let key in sites_custom) {
|
|
|
|
var domainVar = sites_custom[key]['domain'].toLowerCase();
|
|
|
|
if (sites_custom[key]['googlebot'] > 0 && !use_google_bot.includes(domainVar)) {
|
2020-02-28 15:23:17 +00:00
|
|
|
use_google_bot.push(domainVar);
|
|
|
|
}
|
2020-06-04 07:04:58 +00:00
|
|
|
if (sites_custom[key]['block_javascript'] > 0) {
|
|
|
|
block_js_custom.push(domainVar);
|
|
|
|
}
|
|
|
|
if (sites_custom[key]['block_javascript_ext'] > 0) {
|
|
|
|
block_js_custom_ext.push(domainVar);
|
2020-02-28 15:23:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-04 07:04:58 +00:00
|
|
|
|
|
|
|
// reset disableJavascriptOnListedSites eventListener
|
2020-03-28 13:59:26 +00:00
|
|
|
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
|
|
|
|
ext_api.webRequest.handlerBehaviorChanged();
|
2020-02-28 15:23:17 +00:00
|
|
|
}
|
2020-08-20 17:01:12 +00:00
|
|
|
// Refresh the current tab
|
|
|
|
ext_api.tabs.query({
|
|
|
|
active: true,
|
|
|
|
currentWindow: true
|
|
|
|
}, function (tabs) {
|
|
|
|
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
|
|
|
ext_api.tabs.update(tabs[0].id, {
|
|
|
|
url: tabs[0].url
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Set and show default options on install
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.runtime.onInstalled.addListener(function (details) {
|
2017-07-08 17:40:29 +00:00
|
|
|
if (details.reason == "install") {
|
2020-02-25 21:47:05 +00:00
|
|
|
setDefaultOptions();
|
2017-07-08 17:40:29 +00:00
|
|
|
} else if (details.reason == "update") {
|
2020-08-22 17:21:32 +00:00
|
|
|
ext_api.management.getSelf(function (result) {
|
2020-08-26 15:53:26 +00:00
|
|
|
if (enabledSites.includes('#options_on_update') && result.installType !== 'development')
|
2020-08-22 17:21:32 +00:00
|
|
|
ext_api.runtime.openOptionsPage(); // User updated extension (non-developer mode)
|
|
|
|
});
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-03 17:15:21 +00:00
|
|
|
// repubblica.it bypass
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.webRequest.onBeforeRequest.addListener(function (details) {
|
2020-03-03 17:15:21 +00: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 15:18:12 +00: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-09-03 17:13:27 +00:00
|
|
|
var block_js_default = ["*://cdn.tinypass.com/*", "*://*.piano.io/*", "*://*.poool.fr/*", "*://*.blueconic.net/*", "*://*.cxense.com/*", "*://*.evolok.net/*", "*://js.matheranalytics.com/*", "*://*.onecount.net/*", "*://*.qiota.com/*", "*://*.tribdss.com/*"];
|
2020-02-28 15:23:17 +00:00
|
|
|
var block_js_custom = [];
|
2020-06-04 07:04:58 +00:00
|
|
|
var block_js_custom_ext = [];
|
2020-03-27 18:02:27 +00:00
|
|
|
var block_js = block_js_default.concat(block_js_custom);
|
2020-03-28 13:59:26 +00:00
|
|
|
|
2020-01-28 22:06:25 +00:00
|
|
|
// Disable javascript for these sites/general paywall-scripts
|
2020-03-28 13:59:26 +00:00
|
|
|
function disableJavascriptOnListedSites() {
|
|
|
|
ext_api.webRequest.onBeforeRequest.addListener(function (details) {
|
|
|
|
if (!isSiteEnabled(details)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
cancel: true
|
|
|
|
};
|
|
|
|
}, {
|
|
|
|
urls: block_js,
|
2020-07-15 17:12:20 +00:00
|
|
|
types: ["script", "xmlhttprequest"]
|
2020-03-28 13:59:26 +00:00
|
|
|
},
|
|
|
|
["blocking"]);
|
|
|
|
}
|
2019-05-12 23:31:18 +00:00
|
|
|
|
2020-03-25 18:31:28 +00:00
|
|
|
var extraInfoSpec = ['blocking', 'requestHeaders'];
|
|
|
|
if (ext_api.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty('EXTRA_HEADERS'))
|
|
|
|
extraInfoSpec.push('extraHeaders');
|
|
|
|
|
|
|
|
ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
2020-09-11 14:52:50 +00:00
|
|
|
if (details.type === 'main_frame') {
|
|
|
|
let current_date_str = currentDateStr();
|
|
|
|
if (last_date_str < current_date_str) {
|
|
|
|
bpc_count_daily_users(current_date_str);
|
|
|
|
last_date_str = current_date_str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 18:23:00 +00:00
|
|
|
var requestHeaders = details.requestHeaders;
|
|
|
|
|
|
|
|
var header_referer = '';
|
|
|
|
for (var n in requestHeaders) {
|
2020-09-11 14:52:50 +00:00
|
|
|
if (requestHeaders[n].name.toLowerCase() == 'referer') {
|
|
|
|
header_referer = requestHeaders[n].value;
|
|
|
|
continue;
|
|
|
|
}
|
2019-11-27 18:23:00 +00:00
|
|
|
}
|
2020-05-31 06:57:59 +00:00
|
|
|
// fix brave browser
|
|
|
|
if (!details.originUrl && !header_referer.includes(details.initiator))
|
|
|
|
header_referer = details.initiator;
|
2020-01-13 18:15:37 +00:00
|
|
|
|
2020-06-04 07:04:58 +00:00
|
|
|
// remove cookies for sites medium platform (custom domains)
|
|
|
|
var medium_custom_domain = (matchUrlDomain('cdn-client.medium.com', details.url) && !matchUrlDomain('medium.com', header_referer) && isSiteEnabled({url: 'https://medium.com'}));
|
2020-05-28 14:38:48 +00:00
|
|
|
if (medium_custom_domain) {
|
2020-05-01 10:58:36 +00:00
|
|
|
ext_api.cookies.getAll({domain: urlHost(header_referer)}, function(cookies) {
|
2020-06-04 07:04:58 +00:00
|
|
|
for (let cookie of cookies) {
|
|
|
|
ext_api.cookies.remove({url: (cookie.secure ? "https://" : "http://") + cookie.domain + cookie.path, name: cookie.name});
|
2020-05-01 10:58:36 +00:00
|
|
|
}
|
|
|
|
});
|
2020-01-13 18:15:37 +00:00
|
|
|
}
|
2020-06-01 16:01:43 +00:00
|
|
|
|
2020-06-14 16:09:59 +00:00
|
|
|
// remove cookies Discover Magazine
|
2020-06-14 16:37:06 +00:00
|
|
|
if (matchUrlDomain('ctfassets.net', details.url) && matchUrlDomain('discovermagazine.com', header_referer) && isSiteEnabled({url: 'https://www.discovermagazine.com'})) {
|
2020-06-14 16:09:59 +00:00
|
|
|
ext_api.cookies.getAll({domain: 'discovermagazine.com'}, function(cookies) {
|
|
|
|
for (let cookie of cookies) {
|
|
|
|
ext_api.cookies.remove({url: (cookie.secure ? "https://" : "http://") + cookie.domain + cookie.path, name: cookie.name});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-06-01 16:01:43 +00:00
|
|
|
// block external javascript for custom sites (optional)
|
2020-08-22 11:52:43 +00:00
|
|
|
var domain_blockjs_ext = matchUrlDomain(block_js_custom_ext, header_referer);
|
2020-07-15 17:12:20 +00:00
|
|
|
if (domain_blockjs_ext && !matchUrlDomain(domain_blockjs_ext, details.url) && details.url.match(/(\.js$|\.js\?|\/json\?)/) && isSiteEnabled({url: header_referer})) {
|
2020-06-01 16:01:43 +00:00
|
|
|
return { cancel: true };
|
|
|
|
}
|
2020-03-27 18:02:27 +00:00
|
|
|
|
2019-11-27 18:23:00 +00:00
|
|
|
// check for blocked regular expression: domain enabled, match regex, block on an internal or external regex
|
2020-05-01 10:58:36 +00:00
|
|
|
var blockedDomains = Object.keys(blockedRegexes);
|
2020-05-06 19:05:34 +00:00
|
|
|
var domain = matchUrlDomain(blockedDomains, header_referer);
|
2020-09-19 08:16:23 +00:00
|
|
|
var block_regex = true;
|
2020-05-06 19:05:34 +00:00
|
|
|
if (domain && details.url.match(blockedRegexes[domain]) && isSiteEnabled({url: header_referer})) {
|
2020-09-19 08:16:23 +00:00
|
|
|
if (block_regex)
|
|
|
|
return { cancel: true };
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
|
|
|
|
2020-06-20 07:43:02 +00:00
|
|
|
let inkl_site = (matchUrlDomain('cdn.jsdelivr.net', details.url) && matchUrlDomain('inkl.com', header_referer) && isSiteEnabled({url: header_referer}));
|
2020-09-06 13:45:44 +00:00
|
|
|
let bloomberg_site = (matchUrlDomain('assets.bwbx.io', details.url) && matchUrlDomain('bloomberg.com', header_referer) && isSiteEnabled({url: header_referer}));
|
|
|
|
if (!isSiteEnabled(details) && !(inkl_site) && !(bloomberg_site)) {
|
2019-11-27 18:23:00 +00:00
|
|
|
return;
|
2018-11-24 22:10:21 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 07:04:58 +00:00
|
|
|
// block javascript of (sub)domain for custom sites (optional)
|
2020-08-22 11:52:43 +00:00
|
|
|
var domain_blockjs = matchUrlDomain(block_js_custom, details.url);
|
2020-07-15 17:12:20 +00:00
|
|
|
if (domain_blockjs && matchUrlDomain(domain_blockjs, details.url) && details.url.match(/(\.js$|\.js\?|\/json\?)/)) {
|
2020-06-04 07:04:58 +00:00
|
|
|
return { cancel: true };
|
|
|
|
}
|
|
|
|
|
2017-07-08 17:40:29 +00:00
|
|
|
var tabId = details.tabId;
|
2020-03-27 18:02:27 +00:00
|
|
|
|
2019-04-06 23:34:30 +00:00
|
|
|
var useUserAgentMobile = false;
|
2017-07-08 17:40:29 +00:00
|
|
|
var setReferer = false;
|
|
|
|
|
|
|
|
// if referer exists, set it to google
|
2020-03-27 18:02:27 +00:00
|
|
|
requestHeaders = requestHeaders.map(function (requestHeader) {
|
2017-07-08 17:40:29 +00:00
|
|
|
if (requestHeader.name === 'Referer') {
|
2020-05-01 10:58:36 +00:00
|
|
|
if (details.url.includes("cooking.nytimes.com/api/v1/users/bootstrap")) {
|
2019-02-13 09:33:45 +00: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-06-21 12:32:38 +00:00
|
|
|
} else if (matchUrlDomain(['clarin.com', 'fd.nl'], details.url)) {
|
2019-02-13 09:33:45 +00:00
|
|
|
requestHeader.value = 'https://www.facebook.com/';
|
|
|
|
} else {
|
|
|
|
requestHeader.value = 'https://www.google.com/';
|
|
|
|
}
|
|
|
|
setReferer = true;
|
|
|
|
}
|
2019-04-06 23:34:30 +00:00
|
|
|
if (requestHeader.name === 'User-Agent') {
|
|
|
|
useUserAgentMobile = requestHeader.value.toLowerCase().includes("mobile");
|
|
|
|
}
|
|
|
|
|
2019-02-13 09:33:45 +00:00
|
|
|
return requestHeader;
|
|
|
|
});
|
2017-07-08 17:40:29 +00:00
|
|
|
|
|
|
|
// otherwise add it
|
|
|
|
if (!setReferer) {
|
2020-06-21 12:32:38 +00:00
|
|
|
if (matchUrlDomain(['clarin.com', 'fd.nl'], details.url)) {
|
2017-07-08 17:40:29 +00:00
|
|
|
requestHeaders.push({
|
|
|
|
name: 'Referer',
|
|
|
|
value: 'https://www.facebook.com/'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
requestHeaders.push({
|
|
|
|
name: 'Referer',
|
|
|
|
value: 'https://www.google.com/'
|
|
|
|
});
|
|
|
|
}
|
2019-04-06 23:34:30 +00:00
|
|
|
}
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2019-05-12 20:44:03 +00:00
|
|
|
// override User-Agent to use Googlebot
|
2020-05-01 10:58:36 +00:00
|
|
|
if (matchUrlDomain(use_google_bot, details.url)) {
|
2019-04-06 23:34:30 +00:00
|
|
|
requestHeaders.push({
|
|
|
|
"name": "User-Agent",
|
|
|
|
"value": useUserAgentMobile ? userAgentMobile : userAgentDesktop
|
|
|
|
})
|
2019-05-12 20:44:03 +00:00
|
|
|
requestHeaders.push({
|
|
|
|
"name": "X-Forwarded-For",
|
|
|
|
"value": "66.249.66.1"
|
|
|
|
})
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// remove cookies before page load
|
2020-05-01 10:58:36 +00:00
|
|
|
if (!matchUrlDomain(allow_cookies, details.url)) {
|
|
|
|
requestHeaders = requestHeaders.map(function(requestHeader) {
|
|
|
|
if (requestHeader.name === 'Cookie') {
|
|
|
|
requestHeader.value = '';
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
2020-05-01 10:58:36 +00:00
|
|
|
return requestHeader;
|
|
|
|
});
|
|
|
|
}
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2020-09-14 19:29:13 +00:00
|
|
|
if (tabId !== -1) {
|
|
|
|
ext_api.tabs.get(tabId, function (currentTab) {
|
|
|
|
if (isSiteEnabled(currentTab) || medium_custom_domain) {
|
|
|
|
ext_api.tabs.executeScript(tabId, {
|
|
|
|
file: 'contentScript.js',
|
|
|
|
runAt: 'document_start'
|
2020-08-26 15:18:51 +00:00
|
|
|
}, function (res) {
|
2020-09-14 19:29:13 +00:00
|
|
|
if (ext_api.runtime.lastError || res[0]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {//mercuriovalpo.cl
|
|
|
|
ext_api.tabs.query({
|
|
|
|
active: true,
|
|
|
|
currentWindow: true
|
|
|
|
}, function (tabs) {
|
|
|
|
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
|
|
|
if (isSiteEnabled({url: tabs[0].url}) || medium_custom_domain) {
|
|
|
|
ext_api.tabs.executeScript({
|
|
|
|
file: 'contentScript.js',
|
|
|
|
runAt: 'document_start'
|
|
|
|
}, function (res) {
|
|
|
|
if (ext_api.runtime.lastError || res[0]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-07-08 17:40:29 +00:00
|
|
|
}
|
2020-09-14 19:29:13 +00:00
|
|
|
});
|
|
|
|
}
|
2017-07-08 17:40:29 +00:00
|
|
|
|
|
|
|
return { requestHeaders: requestHeaders };
|
|
|
|
}, {
|
|
|
|
urls: ['<all_urls>']
|
2020-03-25 18:31:28 +00:00
|
|
|
}, extraInfoSpec);
|
|
|
|
// extraInfoSpec is ['blocking', 'requestHeaders'] + possible 'extraHeaders'
|
2017-07-08 17:40:29 +00:00
|
|
|
|
2020-05-01 10:58:36 +00: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); });
|
|
|
|
|
|
|
|
function updateBadge (activeTab) {
|
|
|
|
if (!activeTab) { return; }
|
2020-08-20 17:01:12 +00:00
|
|
|
let badgeText = '';
|
|
|
|
let color = 'red';
|
|
|
|
let currentUrl = activeTab.url;
|
|
|
|
if (currentUrl) {
|
|
|
|
let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl);
|
|
|
|
if (isSiteEnabled({url: currentUrl})) {
|
|
|
|
badgeText = 'ON';
|
|
|
|
color = 'red';
|
|
|
|
} else if (matchUrlDomain(enabledSites, currentUrl)) {
|
|
|
|
badgeText = 'ON-';
|
|
|
|
color = 'orange';
|
|
|
|
} else if (matchUrlDomain(disabledSites, currentUrl)) {
|
|
|
|
badgeText = 'OFF';
|
|
|
|
color = 'blue';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ext_api.browserAction.setBadgeBackgroundColor({color: color});
|
2020-05-01 10:58:36 +00:00
|
|
|
ext_api.browserAction.setBadgeText({text: badgeText});
|
2020-03-03 21:37:45 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 17:01:12 +00:00
|
|
|
function site_switch() {
|
|
|
|
ext_api.tabs.query({
|
|
|
|
active: true,
|
|
|
|
currentWindow: true
|
|
|
|
}, function (tabs) {
|
|
|
|
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
|
|
|
let currentUrl = tabs[0].url;
|
|
|
|
let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl);
|
|
|
|
let defaultSite_title = isDefaultSite ? Object.keys(defaultSites).find(key => defaultSites[key] === isDefaultSite) : '';
|
|
|
|
let isCustomSite = matchUrlDomain(Object.values(customSites_domains), currentUrl);
|
|
|
|
let customSite_title = isCustomSite ? Object.keys(customSites).find(key => customSites[key].domain === isCustomSite) : '';
|
|
|
|
let site_title = defaultSite_title || customSite_title;
|
|
|
|
let domain = isDefaultSite || isCustomSite;
|
|
|
|
if (domain) {
|
|
|
|
let added_site = [];
|
|
|
|
let removed_site = [];
|
|
|
|
if (enabledSites.includes(domain))
|
|
|
|
removed_site.push(site_title);
|
|
|
|
else
|
|
|
|
added_site.push(site_title);
|
|
|
|
chrome.storage.sync.get({
|
|
|
|
sites: {}
|
|
|
|
}, function (items) {
|
|
|
|
var sites = items.sites;
|
|
|
|
for (var key of added_site)
|
|
|
|
sites[key] = domain;
|
|
|
|
for (var key of removed_site)
|
|
|
|
delete sites[key];
|
|
|
|
|
|
|
|
chrome.storage.sync.set({
|
|
|
|
sites: sites
|
|
|
|
}, function () {
|
|
|
|
true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-03-03 21:37:45 +00:00
|
|
|
}
|
|
|
|
|
2017-07-08 17:40:29 +00:00
|
|
|
// remove cookies after page load
|
2020-03-25 18:31:28 +00:00
|
|
|
ext_api.webRequest.onCompleted.addListener(function (details) {
|
2020-05-01 10:58:36 +00:00
|
|
|
var domainVar = matchUrlDomain(remove_cookies, details.url);
|
|
|
|
if (!domainVar || !enabledSites.includes(domainVar))
|
|
|
|
return;
|
|
|
|
ext_api.cookies.getAll({
|
|
|
|
domain: domainVar
|
|
|
|
}, function (cookies) {
|
2020-06-04 07:04:58 +00:00
|
|
|
for (let cookie of cookies) {
|
|
|
|
var cookie_domain = cookie.domain;
|
2020-05-01 10:58:36 +00:00
|
|
|
var rc_domain = cookie_domain.replace(/^(\.?www\.|\.)/, '');
|
|
|
|
// hold specific cookie(s) from remove_cookies domains
|
2020-06-04 07:04:58 +00:00
|
|
|
if ((rc_domain in remove_cookies_select_hold) && remove_cookies_select_hold[rc_domain].includes(cookie.name)) {
|
2020-05-01 10:58:36 +00:00
|
|
|
continue; // don't remove specific cookie
|
2020-03-25 18:31:28 +00:00
|
|
|
}
|
2020-05-01 10:58:36 +00:00
|
|
|
// drop only specific cookie(s) from remove_cookies domains
|
2020-06-04 07:04:58 +00:00
|
|
|
if ((rc_domain in remove_cookies_select_drop) && !(remove_cookies_select_drop[rc_domain].includes(cookie.name))) {
|
2020-05-01 10:58:36 +00:00
|
|
|
continue; // only remove specific cookie
|
|
|
|
}
|
|
|
|
ext_api.cookies.remove({
|
2020-06-04 07:04:58 +00:00
|
|
|
url: (cookie.secure ? "https://" : "http://") + cookie.domain + cookie.path,
|
|
|
|
name: cookie.name
|
2020-05-01 10:58:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-07-08 17:40:29 +00:00
|
|
|
}, {
|
2020-03-25 18:31:28 +00:00
|
|
|
urls: ["<all_urls>"]
|
2018-08-28 23:15:23 +00:00
|
|
|
});
|
2019-02-10 23:43:12 +00:00
|
|
|
|
2020-09-08 14:38:18 +00:00
|
|
|
ext_api.runtime.onMessage.addListener(function (message, sender) {
|
|
|
|
// check storage for opt in
|
|
|
|
ext_api.storage.sync.get("optIn", function (result) {
|
|
|
|
// send message back to content script with value of opt in
|
|
|
|
ext_api.tabs.sendMessage(
|
|
|
|
sender.tab.id, {
|
|
|
|
"optIn": (true == result.optIn)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// show the tab if we haven't registered the user reacting to the prompt.
|
|
|
|
ext_api.storage.sync.get("optInShown", function (result) {
|
|
|
|
if (!result.optInShown) {
|
|
|
|
ext_api.tabs.create({
|
|
|
|
url: "optin/opt-in.html"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-02-10 23:43:12 +00:00
|
|
|
function isSiteEnabled(details) {
|
2020-05-01 10:58:36 +00:00
|
|
|
var enabledSite = matchUrlDomain(enabledSites, details.url);
|
2019-02-10 23:43:12 +00:00
|
|
|
if (enabledSite in restrictions) {
|
2020-05-01 10:58:36 +00:00
|
|
|
return restrictions[enabledSite].test(details.url);
|
2019-02-10 23:43:12 +00:00
|
|
|
}
|
2020-05-01 10:58:36 +00: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) {
|
2020-05-24 18:56:32 +00:00
|
|
|
if (url && url.startsWith('http')) {
|
2020-05-01 10:58:36 +00:00
|
|
|
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-10 23:43:12 +00: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, ' '));
|
|
|
|
}
|
2020-01-28 22:06:25 +00:00
|
|
|
|
|
|
|
function stripQueryStringAndHashFromPath(url) {
|
|
|
|
return url.split("?")[0].split("#")[0];
|
2020-03-25 18:31:28 +00:00
|
|
|
}
|