Update custom flex sites (identify on dom)

merge-requests/10/head
magnolia1234 2 years ago
parent 3bc281ea59
commit cb4fcff10e

@ -8,6 +8,10 @@ var navigator_ua = navigator.userAgent;
var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile');
var kiwi_browser = navigator_ua_mobile && (url_loc === 'chrome') && !navigator_ua.toLowerCase().includes('yabrowser');
if (typeof ext_api.action !== 'object') {
ext_api.action = ext_api.browserAction;
}
const dompurify_sites = ['arcinfo.ch', 'asiatimes.com', 'bloomberg.com', 'cicero.de', 'dn.no', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lequipe.fr', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newscientist.com', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(nl_mediahuis_region_domains, no_nhst_media_domains);
var optin_setcookie = false;
var optin_update = true;
@ -109,7 +113,7 @@ function initSetRules() {
blockedRegexesGeneral = {};
blockedJsInline = {};
blockedJsInlineDomains = [];
init_custom_domains();
init_custom_flex_domains();
}
const userAgentDesktopG = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
@ -366,7 +370,7 @@ ext_api.storage.local.get({
sites: {},
sites_default: Object.keys(defaultSites).filter(x => defaultSites[x].domain && !defaultSites[x].domain.match(/^(#options_|###$)/)),
sites_custom: {},
sites_updated: {},
sites_updated: {},
sites_excluded: [],
ext_version_old: '2.3.9.0',
optIn: false,
@ -495,7 +499,7 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
}
} else
set_rules(optionSites, updatedSites, customSites);
}
}
if (key === 'sites_excluded') {
var sites_excluded = storageChange.newValue ? storageChange.newValue : [];
var sites_excluded_old = storageChange.oldValue ? storageChange.oldValue : [];
@ -793,11 +797,19 @@ if (typeof browser !== 'object') {
}
}
ext_api.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
let tab_status = changeInfo.status;
if (/^http/.test(tab.url) && ((tab_status && tab_status === 'complete') || (!tab_status && changeInfo.url))) {
if (matchUrlDomain(enabledSites, tab.url)) {
runOnTab(tab);
function runOnTab_once(tab) {
let tabId = tab.id;
let url = tab.url;
// load contentScript_once.js to identify custom site (flex) of group
if (!(matchUrlDomain(custom_flex_domains.concat(custom_flex_not_domains, customSites_domains, updatedSites_domains_new, excludedSites), url) || matchUrlDomain(defaultSites_domains, url))) {
ext_api.tabs.executeScript(tabId, {
file: 'contentScript_once.js',
runAt: 'document_start'
}, function (res) {
if (ext_api.runtime.lastError || res[0]) {
return;
}
});
}
// load toggleIcon.js (icon for dark or incognito mode in Chrome))
if (typeof browser !== 'object') {
@ -811,6 +823,15 @@ ext_api.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
});
}
}
ext_api.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
let tab_status = changeInfo.status;
if (/^http/.test(tab.url) && ((tab_status && tab_status === 'complete') || (!tab_status && changeInfo.url))) {
if (matchUrlDomain(enabledSites, tab.url)) {
runOnTab(tab);
}
runOnTab_once(tab);
}
});
setInterval(function () {
@ -820,7 +841,7 @@ setInterval(function () {
last_date_str = current_date_str;
}
}, 60 * 60 * 1000);
var extraInfoSpec = ['blocking', 'requestHeaders'];
if (ext_api.webRequest.OnBeforeSendHeadersOptions.hasOwnProperty('EXTRA_HEADERS'))
extraInfoSpec.push('extraHeaders');
@ -849,182 +870,6 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
}
function customAddRules(custom_domains, custom_cookies = '', custom_block_regex = '', custom_useragent = '', custom_referer = '', custom_amp_unhide = false) {
let custom_domain = urlHost(header_referer).replace(/^(www|m|account|amp|edition|eu)\./, '');
if (custom_cookies) {
if (custom_cookies.allow_cookies && !allow_cookies.includes(custom_domain))
allow_cookies.push(custom_domain);
if (custom_cookies.remove_cookies && !remove_cookies.includes(custom_domain))
remove_cookies.push(custom_domain);
}
if (custom_block_regex) {
if ((typeof custom_block_regex === 'string') && custom_block_regex.includes('{domain}'))
custom_block_regex = new RegExp(custom_block_regex.replace('{domain}', custom_domain.replace(/\./g, '\\.')));
blockedRegexes[custom_domain] = custom_block_regex;
blockedRegexesDomains = Object.keys(blockedRegexes);
}
if (custom_useragent) {
if (custom_useragent === 'googlebot') {
if (!use_google_bot.includes(custom_domain))
use_google_bot.push(custom_domain);
change_headers.push(custom_domain);
}
}
if (custom_referer) {
if (custom_referer === 'twitter') {
if (!use_twitter_referer.includes(custom_domain))
use_twitter_referer.push(custom_domain);
change_headers.push(custom_domain);
}
}
if (custom_amp_unhide) {
if (!amp_unhide.includes(custom_domain))
amp_unhide.push(custom_domain);
}
custom_domains.push(custom_domain);
if (!enabledSites.includes(custom_domain))
enabledSites.push(custom_domain);
return custom_domains;
}
if (!matchUrlDomain(excludedSites, header_referer)) {
// remove cookies for sites medium platform (custom domains)
var medium_custom_domain = (matchUrlDomain('cdn-client.medium.com', details.url) && ['script'].includes(details.type) && !matchUrlDomain(medium_custom_domains.concat(['medium.com']), header_referer) && enabledSites.includes('###_medium_custom'));
if (medium_custom_domain)
medium_custom_domains = customAddRules(medium_custom_domains);
else {
// remove cookies for Leaky Paywall/WordPress sites (opt-in to custom sites)
var leaky_paywall_domain = (details.url.match(/\/leaky-paywall(-|\/)/) && ['script'].includes(details.type) && !matchUrlDomain(leaky_paywall_domains.concat(['griffithreview.com', 'nknews.org']), header_referer) && enabledSites.includes('###_wp_leaky_paywall'));
if (leaky_paywall_domain)
leaky_paywall_domains = customAddRules(leaky_paywall_domains);
else {
// remove cookies & set googlebot-useragent for sites substack platform (custom domains)
var substack_custom_domain = (matchUrlDomain('substackcdn.com', details.url) && ['script', 'stylesheet'].includes(details.type) && !matchUrlDomain(substack_custom_domains.concat(['substack.com']), header_referer) && enabledSites.includes('###_substack_custom'));
if (substack_custom_domain)
substack_custom_domains = customAddRules(substack_custom_domains, '', '', 'googlebot');
else {
let header_referer_hostname = urlHost(header_referer);
let url_hostname = urlHost(details.url);
if (header_referer_hostname.match(/\.(com|net)\.au$/)) {
// block Piano.io for regional Australian Community Media sites (opt-in to custom sites)
var au_comm_media_domain = (details.url.match(/\.au\/story\/(\d){7,}/) && ['main_frame'].includes(details.type) && !matchUrlDomain(au_comm_media_domains, header_referer) && enabledSites.includes('###_au_comm_media'));
if (au_comm_media_domain)
au_comm_media_domains = customAddRules(au_comm_media_domains, {allow_cookies: 1}, blockedRegexes['canberratimes.com.au']);
else if (header_referer_hostname.endsWith('.com.au')) {
// enable regional The West Australian sites (opt-in to custom sites)
var au_thewest_domain = (details.url.startsWith('https://images.thewest.com.au/') && ['image'].includes(details.type) &&
!matchUrlDomain(au_thewest_domains, header_referer) && enabledSites.includes('thewest.com.au'));
if (au_thewest_domain)
au_thewest_domains = customAddRules(au_thewest_domains, {allow_cookies: 1});
}
} else if (header_referer_hostname.endsWith('.ch')) {
// set googlebot-useragent for regional nzz.ch sites (opt-in to custom sites)
var ch_media_domain = (matchUrlDomain('static-chmedia.ch', details.url) && ['script'].includes(details.type) && !matchUrlDomain(ch_media_domains, header_referer) && enabledSites.includes('nzz.ch'));
if (ch_media_domain)
ch_media_domains = customAddRules(ch_media_domains, {allow_cookies: 1}, blockedRegexes['nzz.ch'], 'googlebot');
} else if (header_referer_hostname.endsWith('.cl')) {
// block scripts for regional El Mercurio sites (opt-in to custom sites)
var cl_emol_region_domain = (matchUrlDomain('impresa.soy-chile.cl', details.url) && ['xmlhttprequest'].includes(details.type) && !matchUrlDomain(cl_emol_region_domains, header_referer) && enabledSites.includes('elmercurio.com'));
if (cl_emol_region_domain) {
cl_emol_region_domains = customAddRules(cl_emol_region_domains, '', "(\\.{domain}\\/impresa\\/.+\\/assets\\/(vendor|\\d)\\.js|pram\\.pasedigital\\.cl\\/API\\/User\\/Status\\?)");
}
} else if (header_referer_hostname.endsWith('.de')) {
// set googlebot-useragent for additional Funke sites (opt-in to custom sites)
var de_funke_domain = (matchUrlDomain('funkedigital.de', details.url) && ['script'].includes(details.type) && !matchUrlDomain(de_funke_medien_domains, header_referer) && enabledSites.includes('###_de_funke_medien'));
if (de_funke_domain)
de_funke_medien_domains = customAddRules(de_funke_medien_domains, {allow_cookies: 1}, blockedRegexes['waz.de'], 'googlebot');
else {
// block script for additional Madsack/RND sites (opt-in to custom sites)
var de_madsack_domain = (matchUrlDomain('rndtech.de', details.url) && ['script', 'font'].includes(details.type) && !matchUrlDomain(de_madsack_domains.concat(['madsack.de', 'madsack-medien-campus.de']), header_referer) && enabledSites.includes('###_de_madsack'));
if (de_madsack_domain)
de_madsack_domains = customAddRules(de_madsack_domains, {allow_cookies: 1}, blockedRegexes['haz.de']);
}
} else if (header_referer_hostname.match(/\.(es|cat)$/) || matchUrlDomain(['diariocordoba.com', 'elperiodicodearagon.com', 'elperiodicoextremadura.com', 'elperiodicomediterraneo.com', 'emporda.info'], header_referer)) {
// block Piano.io for unlisted Grupo Prensa Ibérica (opt-in to custom sites)
var es_epiberica_domain = (url_hostname.startsWith('estaticos-cdn.') && ['script', 'font', 'stylesheet'].includes(details.type) && !matchUrlDomain(es_epiberica_domains, header_referer) && enabledSites.includes('###_es_epiberica'));
if (es_epiberica_domain)
es_epiberica_domains = customAddRules(es_epiberica_domains, {allow_cookies: 1}, blockedRegexes['epe.es']);
} else if (header_referer_hostname.endsWith('.fr')) {
// block Poool.fr for Groupe Centre France sites (opt-in to custom sites)
var fr_gcf_domain = (details.url.match(/\.fr\/static\/bloc\/ripolinage\/header\/cf-header\//) && ['script', 'stylesheet'].includes(details.type) && !matchUrlDomain(fr_gcf_domains, header_referer) && enabledSites.includes('###_fr_gcf'));
if (fr_gcf_domain)
fr_gcf_domains = customAddRules(fr_gcf_domains, {allow_cookies: 1}, blockedRegexes['lamontagne.fr']);
} else if (header_referer_hostname.endsWith('.nl')) {
// block Evolok for Mediahuis Noord sites (opt-in to custom sites)
var nl_mediahuis_noord_domain = (matchUrlDomain('ndcmediagroep.nl', details.url) && ['script'].includes(details.type) && !matchUrlDomain(nl_mediahuis_noord_domains, header_referer) && enabledSites.includes('###_nl_mediahuis_noord'));
if (nl_mediahuis_noord_domain)
nl_mediahuis_noord_domains = customAddRules(nl_mediahuis_noord_domains, {allow_cookies: 1}, blockedRegexes['lc.nl']);
} else if (header_referer_hostname.match(/\.(ca|com|net|org)$/)) {
// remove cookies for Groupe Capitales Médias sites
var ca_gcm_domain = (matchUrlDomain('gcm.omerlocdn.com', details.url) && ['xmlhttprequest'].includes(details.type) && !matchUrlDomain(ca_gcm_domains, header_referer) && enabledSites.includes('###_ca_gcm'));
if (ca_gcm_domain)
ca_gcm_domains = customAddRules(ca_gcm_domains, {allow_cookies: 1, remove_cookies: 1});
else {
// block TinyPass for Postmedia Network sites
var ca_postmedia_domain = (matchUrlDomain('postmedia.digital', details.url) && ['script'].includes(details.type) && !matchUrlDomain(ca_postmedia_domains.concat(['canada.com', 'canoe.com', 'driving.ca']), header_referer) && enabledSites.includes('###_ca_postmedia'));
if (ca_postmedia_domain)
ca_postmedia_domains = customAddRules(ca_postmedia_domains, {allow_cookies: 1}, blockedRegexes['nationalpost.com']);
else {
// set googlebot-useragent for Gannett sites
var usa_gannett_domain = (matchUrlDomain('gannett-cdn.com', details.url) && ['xmlhttprequest'].includes(details.type) && !matchUrlDomain(usa_gannett_domains.concat(['usatoday.com']), header_referer) && enabledSites.includes('###_usa_gannett'));
if (usa_gannett_domain)
usa_gannett_domains = customAddRules(usa_gannett_domains, '', blockedRegexes['azcentral.com'], 'googlebot', '', true);
else {
var usa_hearst_comm_domain = (matchUrlDomain('treg.hearstnp.com', details.url) && ['script'].includes(details.type) && !matchUrlDomain(usa_hearst_comm_domains.concat(['sfgate.com']), header_referer) && enabledSites.includes('###_usa_hearst_comm'));
if (usa_hearst_comm_domain)
usa_hearst_comm_domains = customAddRules(usa_hearst_comm_domains, {allow_cookies: 1}, blockedRegexes['houstonchronicle.com']);
else {
// block script for additional Lee Enterprises sites (opt-in to custom sites)
var usa_lee_ent_domain = (details.url.match(/\.townnews\.com\/(central\.)?leetemplates\.com\//) && ['script'].includes(details.type) &&
!matchUrlDomain(usa_lee_ent_domains, header_referer) && enabledSites.includes('###_usa_lee_ent'));
if (usa_lee_ent_domain)
usa_lee_ent_domains = customAddRules(usa_lee_ent_domains, '', blockedRegexes['buffalonews.com']);
else {
// block script for TownNews sites (Blox CMS; opt-in to custom sites)
var usa_townnews_domain = (details.url.match(/\.townnews\.com\/.+\/tncms\//) && ['script'].includes(details.type) &&
!matchUrlDomain(usa_townnews_domains.concat(usa_lee_ent_domains, ['townnews.com', 'galvnews.com', 'nola.com', 'theadvocate.com']), header_referer) && enabledSites.includes('###_usa_townnews'));
if (usa_townnews_domain)
usa_townnews_domains = customAddRules(usa_townnews_domains, '', /\.com\/shared-content\/art\/tncms\/user\/user\.js/);
else {
// block script for additional McClatchy sites (opt-in to custom sites)
var usa_mcc_domain = (((matchUrlDomain('mcclatchyinteractive.com', details.url) && ['script'].includes(details.type)) ||
(matchUrlDomain('mcclatchy.com', details.url) && ['image'].includes(details.type))) &&
!matchUrlDomain(usa_mcc_domains.concat(['mcclatchy.com']), header_referer) && enabledSites.includes('###_usa_mcc'));
if (usa_mcc_domain)
usa_mcc_domains = customAddRules(usa_mcc_domains, '', blockedRegexes['bnd.com']);
else {
// block script for additional MediaNews Group sites (opt-in to custom sites)
var usa_mng_domain = (details.url.match(/\.com\/wp-content\/plugins\/dfm(-|_).+\.js/) && ['script'].includes(details.type) &&
!matchUrlDomain(usa_mng_domains, header_referer) && enabledSites.includes('###_usa_mng'));
if (usa_mng_domain)
usa_mng_domains = customAddRules(usa_mng_domains, '', blockedRegexes['denverpost.com']);
else if (header_referer_hostname.match(/\.com$/)) {
// block cookies for Madavor Media sites
var usa_madavor_domain = (details.url.match(/\.com\/wp-content\/(plugins|themes)\/madavor-/) && ['script'].includes(details.type) && details.url.includes(header_referer_hostname) && !matchUrlDomain(usa_madavor_domains, header_referer) && enabledSites.includes('###_usa_madavor'));
if (usa_madavor_domain)
usa_madavor_domains = customAddRules(usa_madavor_domains);
else {
// set googlebot-useragent for PEI Media sites
var usa_pei_domain = (details.url.match(/\.com\/wp-content\/plugins\/pragmatic-pei-rebranding\/assets\/img\/.+-logo\.svg$/) && ['image', 'xmlhttprequest'].includes(details.type) && details.url.includes(header_referer_hostname) && !matchUrlDomain(usa_pei_domains, header_referer) && enabledSites.includes('###_usa_pei'));
if (usa_pei_domain)
usa_pei_domains = customAddRules(usa_pei_domains, {allow_cookies: 1}, '', 'googlebot');
}
}
}
}
}
}
}
}
}
}
}
}
}
} // not in excludedSites
// block external javascript for custom sites (optional)
if (['script'].includes(details.type)) {
let domain_blockjs_ext = matchUrlDomain(block_js_custom_ext, header_referer);
@ -1177,6 +1022,7 @@ if (matchUrlDomain(change_headers, details.url) && !ignore_types.includes(detail
if (!ext_api.runtime.lastError && tab && isSiteEnabled(tab)) {
runOnTab(tab);
}
runOnTab_once(tab);
});
}
} else {
@ -1190,6 +1036,7 @@ if (matchUrlDomain(change_headers, details.url) && !ignore_types.includes(detail
if (isSiteEnabled(tab)) {
runOnTab(tab);
}
runOnTab_once(tab);
}
});
}
@ -1198,7 +1045,7 @@ if (matchUrlDomain(change_headers, details.url) && !ignore_types.includes(detail
return { requestHeaders: requestHeaders };
}, {
urls: ['<all_urls>']
urls: ['*://*/*']
}, extraInfoSpec);
// extraInfoSpec is ['blocking', 'requestHeaders'] + possible 'extraHeaders'
@ -1253,18 +1100,18 @@ function updateBadge(activeTab) {
if (!result)
badgeText = enabledSites.includes(isCustomSite || isUpdatedSite) ? 'C' : '';
if (color && badgeText)
ext_api.browserAction.setBadgeBackgroundColor({color: color});
ext_api.browserAction.setBadgeText({text: badgeText});
ext_api.action.setBadgeBackgroundColor({color: color});
ext_api.action.setBadgeText({text: badgeText});
});
} else {
if (!badgeText && matchUrlDomain(customSitesExt, currentUrl))
badgeText = '+C';
if (color && badgeText)
ext_api.browserAction.setBadgeBackgroundColor({color: color});
ext_api.browserAction.setBadgeText({text: badgeText});
ext_api.action.setBadgeBackgroundColor({color: color});
ext_api.action.setBadgeText({text: badgeText});
}
} else
ext_api.browserAction.setBadgeText({text: badgeText});
ext_api.action.setBadgeText({text: badgeText});
}
var ext_version_new;
@ -1418,6 +1265,44 @@ function clear_cookies() {
});
}
function customAddRules(custom_domain, rules) {
if (rules.allow_cookies && !allow_cookies.includes(custom_domain))
allow_cookies.push(custom_domain);
if (rules.remove_cookies && !remove_cookies.includes(custom_domain))
remove_cookies.push(custom_domain);
let custom_block_regex = rules.block_regex;
if (custom_block_regex) {
if ((typeof custom_block_regex === 'string') && custom_block_regex.includes('{domain}'))
custom_block_regex = new RegExp(custom_block_regex.replace('{domain}', custom_domain.replace(/\./g, '\\.')));
blockedRegexes[custom_domain] = custom_block_regex;
blockedRegexesDomains = Object.keys(blockedRegexes);
}
let custom_useragent = rules.useragent;
if (custom_useragent) {
if (custom_useragent === 'googlebot') {
if (!use_google_bot.includes(custom_domain))
use_google_bot.push(custom_domain);
change_headers.push(custom_domain);
}
}
let custom_referer = rules.referer;
if (custom_referer) {
if (custom_referer === 'twitter') {
if (!use_twitter_referer.includes(custom_domain))
use_twitter_referer.push(custom_domain);
change_headers.push(custom_domain);
}
}
let custom_amp_unhide = rules.amp_unhide;
if (custom_amp_unhide) {
if (!amp_unhide.includes(custom_domain))
amp_unhide.push(custom_domain);
}
custom_flex_domains.push(custom_domain);
if (!enabledSites.includes(custom_domain))
enabledSites.push(custom_domain);
}
var chrome_scheme = 'light';
ext_api.runtime.onMessage.addListener(function (message, sender) {
if (message.request === 'clear_cookies') {
@ -1427,6 +1312,27 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
if (message.request === 'clear_cookies_domain' && message.data) {
remove_cookies_fn(message.data.domain);
}
if (message.request === 'custom_domain' && message.data) {
let custom_domain = message.data.domain;
let group = message.data.group;
if (group) {
if (enabledSites.includes(group) && custom_domain && !custom_flex_domains.includes(custom_domain)) {
let rules;
if (group === 'elmercurio.com')
rules = {block_regex: "(\\.{domain}\\/impresa\\/.+\\/assets\\/(vendor|\\d)\\.js|pram\\.pasedigital\\.cl\\/API\\/User\\/Status\\?)"};
else {
rules = Object.values(defaultSites).filter(x => x.domain === group)[0];
if (group === '###_usa_gannett')
rules.amp_unhide = 1;
}
if (rules) {
customAddRules(custom_domain, rules);
}
}
} else if (custom_domain) {
custom_flex_not_domains.push(custom_domain);
}
}
if (message.request === 'site_switch') {
site_switch();
}
@ -1504,7 +1410,7 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
let icon_path = {path: {'128': 'bypass.png'}};
if (message.scheme === 'dark')
icon_path = {path: {'128': 'bypass-dark.png'}};
ext_api.browserAction.setIcon(icon_path);
ext_api.action.setIcon(icon_path);
chrome_scheme = message.scheme;
focus_changed = false;
}
@ -1523,27 +1429,6 @@ ext_api.storage.local.get(["optInShown", "customShown"], function (result) {
}
});
// restore custom sites opt-in on reload (chrome-only, load upacked)
if (typeof browser !== 'object') {
ext_api.storage.local.get({
sites: {},
customOptIn: false
}, function (result) {
let options_restore_custom = Object.values(result.sites).includes('#options_restore_custom');
if (result.customOptIn && options_restore_custom) {
ext_api.permissions.contains({
origins: ["<all_urls>"]
}, function (result_perm) {
if (!result_perm) {
ext_api.tabs.create({
url: "options/optin/opt-in.html"
});
}
});
}
});
}
function filterObject(obj, filterFn, mapFn = function (val, key) {
return [key, val];
}) {
@ -1588,6 +1473,10 @@ function matchUrlDomain(domains, url) {
return matchDomain(domains, urlHost(url));
}
function prepHostname(hostname) {
return hostname.replace(/^(www|m|account|amp(\d)?|edition|eu|mobil|wap)\./, '');
}
function getParameterByName(name, url) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),

@ -5,6 +5,7 @@ Post-release
Fix Business Standard (images)
Fix DN.no (images)
Fix The Athletic (regwall)
Update custom flex sites (identify on dom)
* v2.9.6.0 (2022-12-04)
Add DN.no

@ -244,7 +244,7 @@ if ((bg2csData !== undefined) && bg2csData.cs_code) {
// Content workarounds/domain
if (matchDomain('medium.com') || matchDomain(medium_custom_domains) || document.querySelector('script[src^="https://cdn-client.medium.com/"]')) {
if (matchDomain('medium.com') || matchDomain(medium_custom_domains) || document.querySelector('script[src*=".medium.com/"]')) {
let paywall = document.querySelector('div#paywall-background-color');
removeDOMElement(paywall);
if (paywall) {

@ -1,4 +1,5 @@
//"use strict";
//'use strict';
var ext_api = (typeof browser === 'object') ? browser : chrome;
if (matchDomain('gitlab.com')) {
window.setTimeout(function () {
@ -35,6 +36,83 @@ else if (matchDomain('nzherald.co.nz')) {
}, 100);
}
else {
window.setTimeout(function () {
let hostname = window.location.hostname;
let custom_domain = prepHostname(hostname);
let group;
if (hostname) {
if (document.querySelector('script[src*=".medium.com/"]'))
group = '###_medium_custom';
else if (document.querySelector('script[src*="/leaky-paywall/"], script[src*="/leaky-paywall-"]'))
group = '###_wp_leaky_paywall';
else if (document.querySelector('script[src*="/substackcdn.com/"], link[rel="stylesheet"][href*="/substackcdn.com/"]'))
group = '###_substack_custom';
else if (hostname.match(/\.(com|net)\.au$/)) {
if (document.querySelector('a[href*="/australiancommunitymedia.zendesk.com/"]'))
group = '###_au_comm_media';
else if (hostname.endsWith('.com.au')) {
if (document.querySelector('link[href*="/thewest.com.au/"]'))
group = 'thewest.com.au';
}
} else if (hostname.endsWith('.ch')) {
if (document.querySelector('link[href*="/assets.static-chmedia.ch/"]'))
group = 'nzz.ch';
} else if (hostname.endsWith('.cl')) {
if (document.querySelector('meta[content*="/impresa.soy-chile.cl/"]'))
group = 'elmercurio.com';
} else if (hostname.endsWith('.de')) {
if (document.querySelector('script[data-cmp-src*=".funkedigital.de/"], div#fmg-markenanker > a[href="https://www.funkemedien.de/"]'))
group = '###_de_funke_medien';
else if (document.querySelector('link[href*=".rndtech.de/"]'))
group = '###_de_madsack';
} else if (hostname.match(/\.(es|cat)$/) || matchDomain(['diariocordoba.com', 'elperiodicodearagon.com', 'elperiodicoextremadura.com', 'elperiodicomediterraneo.com', 'emporda.info'])) {
if (document.querySelector('link[href*="/estaticos-cdn."]'))
group = '###_es_epiberica';
} else if (hostname.endsWith('.fr')) {
if (document.querySelector('link[href*=".fr/static/bloc/ripolinage/header/cf-header/"]'))
group = '###_fr_gcf';
} else if (hostname.endsWith('.nl')) {
if (document.querySelector('script[src*=".ndcmediagroep.nl/"]'))
group = '###_nl_mediahuis_noord';
} else if (hostname.match(/\.(ca|com|net|org)$/)) {
if (document.querySelector('picture > source[srcset*="%2Fgcm.omerlocdn.com%2F"]'))
group = '###_ca_gcm';
else if (document.querySelector('script[src*=".postmedia.digital/"], meta[content*=".postmedia.digital/"]'))
group = '###_ca_postmedia';
else if (document.querySelector('img[srcset*=".gannett-cdn.com/"]'))
group = '###_usa_gannett';
else if (document.querySelector('script[src*="/treg.hearstnp.com/"]'))
group = '###_usa_hearst_comm';
else if (document.querySelector('script[src*=".townnews.com/"][src*="leetemplates.com/'))
group = '###_usa_lee_ent';
else if (document.querySelector('script[src*=".townnews.com/"][src*="/tncms/"]'))
group = '###_usa_townnews';
else if (document.querySelector('meta[content^="https://www.mcclatchy-wires.com/"], a[href^="https://classifieds.mcclatchy.com/"]'))
group = '###_usa_mcc';
else if (document.querySelector('script[src*=".com/wp-content/plugins/dfm"]'))
group = '###_usa_mng';
else if (hostname.match(/\.com$/)) {
if (document.querySelector('link[href*=".com/wp-content/themes/madavor/"]'))
group = '###_usa_madavor';
else if (document.querySelector('script#wp-parsely-pei-events-js'))
group = '###_usa_pei';
}
}
ext_api.runtime.sendMessage({
request: 'custom_domain',
data: {
domain: custom_domain,
group: group
}
});
}
}, 1000);
}
function matchDomain(domains, hostname) {
var matched_domain = false;
if (!hostname)
@ -45,6 +123,10 @@ function matchDomain(domains, hostname) {
return matched_domain;
}
function prepHostname(hostname) {
return hostname.replace(/^(www|m|account|amp(\d)?|edition|eu|mobil|wap)\./, '');
}
function insert_script(func, insertAfterDom) {
let bpc_script = document.querySelector('script#bpc_script');
if (!bpc_script) {

@ -35,7 +35,7 @@
"page": "options/options.html"
},
"optional_permissions": [
"<all_urls>"
"*://*/*"
],
"content_scripts": [{
"matches": [
@ -632,7 +632,6 @@
"*://*.torontosun.com/*",
"*://*.towardsdatascience.com/*",
"*://*.townandcountrymag.com/*",
"*://*.townnews.com/*",
"*://*.townsvillebulletin.com.au/*",
"*://*.tradewindsnews.com/*",
"*://*.trailrunnermag.com/*",
@ -688,7 +687,9 @@
"*://*.ampproject.org/*",
"*://*.blueconic.net/*",
"*://*.cxense.com/*",
"*://*.ensighten.com/*",
"*://*.evolok.net/*",
"*://*.loader-cdn.azureedge.net/*",
"*://*.matheranalytics.com/*",
"*://*.newsmemory.com/*",
"*://*.omeda.com/*",
@ -709,28 +710,14 @@
"*://*.cedsdigital.it/*",
"*://*.corriereobjects.it/*",
"*://*.emol.cl/*",
"*://*.ensighten.com/*",
"*://*.flip-pay.com/*",
"*://*.funkedigital.de/*",
"*://*.gannett-cdn.com/*",
"*://*.gitlab.com/magnolia1234/*",
"*://*.hadrianpaywall.com/*",
"*://*.hearstnp.com/*",
"*://*.loader-cdn.azureedge.net/*",
"*://*.mcclatchy.com/*",
"*://*.mcclatchyinteractive.com/*",
"*://*.medscapestatic.com/*",
"*://*.ndcmediagroep.nl/*",
"*://*.nyt.com/*",
"*://*.pasedigital.cl/*",
"*://*.postmedia.digital/*",
"*://*.rndtech.de/*",
"*://*.soy-chile.cl/*",
"*://*.static-chmedia.ch/*",
"*://*.substackcdn.com/*",
"*://*.wallkit.net/*",
"*://gcm.omerlocdn.com/*",
"*://webcache.googleusercontent.com/*"
],
"version": "2.9.6.2"
"version": "2.9.6.3"
}

@ -44,7 +44,7 @@ window.addEventListener("load", function () {
document.querySelector('#custom-enable').addEventListener('click', function (event) {
ext_api.permissions.request({
origins: ["<all_urls>"]
origins: ["*://*/*"]
}, function (granted) {
if (granted) {
custom_enabled.innerText = 'YES';
@ -62,7 +62,7 @@ window.addEventListener("load", function () {
document.querySelector('#custom-disable').addEventListener('click', function (event) {
ext_api.permissions.remove({
origins: ["<all_urls>"]
origins: ["<all_urls>", "*://*/*"]
}, function (removed) {
if (removed) {
custom_enabled.innerText = 'NO';

@ -1171,7 +1171,8 @@ var defaultSites = {
block_regex: /(metering\.platform\.latimes\.com\/|cdn\.ampproject\.org\/v\d\/amp-(access|subscriptions)-.+\.js)/
},
"Madavor Media (opt-in to custom sites)": {
domain: "###_usa_madavor"
domain: "###_usa_madavor",
group: []
},
"Madsack Mediengruppe": {
domain: "###_de_madsack",
@ -1474,7 +1475,10 @@ var defaultSites = {
block_regex: /\.poool\.fr\//
},
"PEI Media (opt-in to custom sites)": {
domain: "###_usa_pei"
domain: "###_usa_pei",
group: [],
allow_cookies: 1,
useragent: "googlebot"
},
"Penske Media Corporation": {
domain: "###_usa_penske_media",
@ -1701,7 +1705,9 @@ var defaultSites = {
useragent: "googlebot"
},
"Substack custom domains (paywall-content only; opt-in to custom sites)": {
domain: "###_substack_custom"
domain: "###_substack_custom",
group: [],
useragent: "googlebot"
},
"Süddeutsche Zeitung (link to archive.is)": {
domain: "sueddeutsche.de",
@ -2077,7 +2083,9 @@ var defaultSites = {
]
},
"TownNews sites (Blox CMS)": {
domain: "###_usa_townnews"
domain: "###_usa_townnews",
group: [],
block_regex: /\.com\/shared-content\/art\/tncms\/user\/user\.js/
},
"Tribune Publishing Company": {
domain: "###_usa_tribune",
@ -2205,7 +2213,7 @@ var defaultSites = {
},
"Leaky Paywall (WordPress plugin)": {
domain: "###_wp_leaky_paywall",
allow_cookies: 1,
group: [],
},
"MatherAnalytics": {
domain: "matheranalytics.com",
@ -2245,6 +2253,7 @@ var defaultSites = {
},
"Pigeon (WordPress plugin)": {
domain: "###_wp_pigeon",
group: [],
allow_cookies: 1,
block_regex_general: /\/c\/assets\/pigeon\.js/
},
@ -2290,9 +2299,6 @@ var defaultSites = {
"Check for update rules at startup": {
domain: "#options_optin_update_rules"
},
"Restore opt-in for custom sites (on reload; load unpacked)": {
domain: "#options_restore_custom"
},
"Barron's - no Googlebot (http error 500)": {
domain: "#options_disable_gb_barrons"
},
@ -2301,12 +2307,6 @@ var defaultSites = {
},
}
if (typeof browser === 'object') {
let key = Object.keys(defaultSites).find(key => defaultSites[key].domain === '#options_restore_custom');
if (key)
delete defaultSites[key];
}
var defaultSites_grouped_domains = Object.values(defaultSites).filter(function (value) {
return (value.hasOwnProperty('domain') && value.domain !== '###');
}).map(x => x.domain);
@ -2359,41 +2359,31 @@ expandSiteRules(defaultSites);
// grouped domains (background)
var au_news_corp_domains = grouped_sites['###_au_news_corp'];
var de_westfalen_medien_domains = grouped_sites['###_de_westfalen_medien'];
var es_grupo_vocento_domains = grouped_sites['###_es_grupo_vocento'];
var fr_groupe_sud_ouest_domains = grouped_sites['###_fr_groupe_sud_ouest'];
var it_gedi_domains = grouped_sites['###_it_gedi'];
var nl_mediahuis_region_domains = grouped_sites['###_nl_mediahuis_region'];
var no_nhst_media_domains = grouped_sites['###_no_nhst_media'];
// custom domains (background)
var au_comm_media_domains, au_thewest_domains, ca_gcm_domains, ca_postmedia_domains, ch_media_domains, cl_emol_region_domains, de_funke_medien_domains, de_madsack_domains, es_epiberica_domains, fr_gcf_domains, leaky_paywall_domains, medium_custom_domains, nl_mediahuis_noord_domains, substack_custom_domains, usa_gannett_domains, usa_hearst_comm_domains, usa_lee_ent_domains, usa_madavor_domains, usa_mcc_domains, usa_mng_domains, usa_pei_domains, usa_townnews_domains;
var custom_flex_not = {
"###_ca_postmedia": ["canada.com", "canoe.com", "driving.ca"],
"###_de_madsack": ["madsack.de", "madsack-medien-campus.de"],
"###_wp_leaky_paywall": ["griffithreview.com", "nknews.org", "thewirechina.com"],
"###_medium_custom": ["medium.com"],
"###_substack_custom": ["substack.com"],
"###_usa_gannett": ["usatoday.com"],
"###_usa_hearst_comm": ["sfgate.com"],
"###_usa_mcc": ["mcclatchy.com"],
"###_usa_townnews": ["townnews.com", "galvnews.com", "nola.com", "theadvocate.com"]
}
var custom_flex_domains;
var custom_flex_not_domains;
function init_custom_domains() {
au_comm_media_domains = grouped_sites['###_au_comm_media'];
au_thewest_domains = ['thewest.com.au'];
ca_gcm_domains = grouped_sites['###_ca_gcm'];
ca_postmedia_domains = grouped_sites['###_ca_postmedia'];
ch_media_domains = [];
cl_emol_region_domains = [];
de_funke_medien_domains = grouped_sites['###_de_funke_medien'];
de_madsack_domains = grouped_sites['###_de_madsack'];
es_epiberica_domains = grouped_sites['###_es_epiberica'];
fr_gcf_domains = grouped_sites['###_fr_gcf'];
leaky_paywall_domains = [];
medium_custom_domains = grouped_sites['###_medium_custom'];
nl_mediahuis_noord_domains = [];
substack_custom_domains = [];
usa_gannett_domains = grouped_sites['###_usa_gannett'];
usa_hearst_comm_domains = grouped_sites['###_usa_hearst_comm'];
usa_lee_ent_domains = grouped_sites['###_usa_lee_ent'];
usa_madavor_domains = [];
usa_mcc_domains = grouped_sites['###_usa_mcc'];
usa_mng_domains = grouped_sites['###_usa_mng'];
usa_pei_domains = [];
usa_townnews_domains = [];
function init_custom_flex_domains() {
custom_flex_domains = [];
custom_flex_not_domains = [].concat.apply([], Object.values(custom_flex_not));
}
init_custom_domains();
init_custom_flex_domains();
// sites with no fix (background)
var be_mediahuis_nofix_domains = ['gva.be', 'hbvl.be'];

@ -8,11 +8,6 @@
"block_regex": "\\.poool\\.fr\\/",
"ld_json": "div#poool-widget|div.entry-content"
},
"La Vanguardia": {
"domain": "lavanguardia.com",
"allow_cookies": 1,
"block_regex": "(\\.evolok\\.net\\/|\\.lavanguardia\\.com\\/js\\/godo-basex-)"
},
"The Atlantic": {
"domain": "theatlantic.com",
"block_regex": "cdn\\.theatlantic\\.com\\/_next\\/static\\/chunks\\/[567].+\\.js",
@ -26,10 +21,5 @@
"domain": "washingtonpost.com",
"allow_cookies": 1,
"block_regex": "\\.washingtonpost\\.com\\/tetro\\/metering\\/evaluate"
},
"###_gr_au_nine_domains": {
"group_rule_domains": ["brisbanetimes.com.au", "smh.com.au", "theage.com.au", "watoday.com.au"],
"allow_cookies": 1,
"block_regex": "(api\\.{domain}\\/graphql\\?query=.+PaywallRuleQuery|cdn\\.ampproject\\.org\\/v\\d\\/amp-subscriptions-.+\\.js)"
}
}

Loading…
Cancel
Save