bypass-paywalls-firefox-clean/contentScript_once.js

187 lines
9.6 KiB
JavaScript
Raw Normal View History

//'use strict';
var ext_api = (typeof browser === 'object') ? browser : chrome;
if (matchDomain('gitlab.com')) {
2022-03-17 18:39:21 +00:00
window.setTimeout(function () {
2023-03-14 16:00:17 +00:00
let bio = document.querySelector('p.profile-user-bio');
2022-03-17 18:39:21 +00:00
if (bio) {
let split = bio.innerText.split(/(https:[\w\-/.]+)|\|/g).filter(x => x && x.trim());
bio.innerText = '';
for (let part of split) {
let elem;
if (part.startsWith('https')) {
elem = document.createElement('a');
elem.innerText = part;
elem.href = part;
elem.appendChild(document.createElement('br'));
} else {
elem = document.createElement('b');
elem.appendChild(document.createTextNode(part));
if (!part.includes(':'))
elem.appendChild(document.createElement('br'));
}
bio.appendChild(elem);
}
}
}, 1000);
2021-09-05 16:47:28 +00:00
}
else {
window.setTimeout(function () {
let hostname = window.location.hostname;
let custom_domain = getCookieDomain(hostname);
let group;
if (hostname) {
if (document.querySelector('script[src*=".medium.com/"]') || matchDomain(['plainenglish.io']))
group = 'medium.com';
2023-02-08 20:58:02 +00:00
else if (document.querySelector('script[src*="/leaky-paywall"], link[href*="/leaky-paywall"]'))
group = '###_wp_leaky_paywall';
else if (document.querySelector('script[src*="/substackcdn.com/"], link[rel="stylesheet"][href*="/substackcdn.com/"]'))
group = '###_substack_custom';// no fix
2023-04-16 12:41:01 +00:00
else if (document.querySelector('script[src*="/wp-content/themes/pmgnews/scripts/promedia.js"], form[action^="https://go.promedia.nl/"]'))
group = '###_nl_promedia';
else if (hostname.match(/\.(com|net)\.au$/) && !matchDomain(['insideretail.com.au'])) {
if (document.querySelector('a[href^="https://austcommunitymedia.my.site.com/"]'))
group = '###_au_comm_media';
else if (hostname.endsWith('.com.au')) {
if (document.querySelector('li > a[href*=".sevenwestmedia.com.au"]'))
group = 'thewest.com.au';
}
} else if (hostname.endsWith('.be')) {
if (matchDomain(['gva.be', 'hbvl.be', 'nieuwsblad.be', 'standaard.be']))
group = '###_be_mediahuis';// no fix
} else if (hostname.endsWith('.cl')) {
2023-09-30 11:28:40 +00:00
if (document.querySelector('head > meta[property="og:image"][content*="/impresa.soy-chile.cl/"]'))
group = 'elmercurio.com';
2023-01-08 08:35:56 +00:00
} else if (hostname.match(/\.(de|at|ch)$/) || matchDomain(['horizont.net', 'lebensmittelzeitung.net'])) {
2023-07-24 16:33:33 +00:00
if (document.querySelector('script[src*="/dfv.containers.piwik.pro/"]'))
group = '###_de_dfv_medien';
else 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('div.navigation__personalization > a[href^="https://www.haas-mediengruppe.de/"]'))
group = '###_de_haas_medien';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('head > link[href*=".rndtech.de/"]'))
group = '###_de_madsack';
else if (document.querySelector('a.mgw-logo[href^="https://mgw.de"]'))
2023-07-24 16:33:33 +00:00
group = '###_de_mgw';
else if (matchDomain(['cannstatter-zeitung.de', 'esslinger-zeitung.de', 'frankenpost.de', 'insuedthueringen.de', 'krzbb.de', 'kurier.de', 'np-coburg.de', 'verlagshaus-jaumann.de']))
group = '###_de_mhs';
2023-05-08 07:04:58 +00:00
else if (matchDomain(['aachener-nachrichten.de', 'aachener-zeitung.de', 'ga.de', 'rp-online.de', 'saarbruecker-zeitung.de', 'volksfreund.de']))
group = '###_de_rp_aachen_medien';// no fix
else if (matchDomain(['buerstaedter-zeitung.de', 'hochheimer-zeitung.de', 'lampertheimer-zeitung.de', 'lauterbacher-anzeiger.de', 'main-spitze.de', 'mittelhessen.de', 'oberhessische-zeitung.de', 'wormser-zeitung.de']))
2023-02-05 13:25:33 +00:00
group = '###_de_vrm';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('head > link[href*="/assets.static-chmedia.ch/"]'))
2023-01-08 08:35:56 +00:00
group = 'nzz.ch';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('head > link[href*=".tamedia.ch/"]'))
group = '###_ch_tamedia';// no fix
} else if (hostname.match(/\.(es|cat)$/) || matchDomain(['diariocordoba.com', 'elperiodicodearagon.com', 'elperiodicoextremadura.com', 'elperiodicomediterraneo.com', 'emporda.info'])) {
2023-09-30 11:28:40 +00:00
if (document.querySelector('head > link[href*="/estaticos-cdn."]'))
group = '###_es_epiberica';
else if (document.querySelector('div > ul > li > a[href="https://www.sportlife.es/"]'))
group = '###_es_sport_life';
2023-02-03 12:29:41 +00:00
} else if (hostname.endsWith('.fi')) {
2023-09-30 11:28:40 +00:00
if (document.querySelector('head > link[href^="https://assets.almatalent.fi"]'))
2023-02-03 12:29:41 +00:00
group = '###_fi_alma_talent';// no fix
} else if (hostname.endsWith('.fr')) {
2023-09-30 11:28:40 +00:00
if (document.querySelector('head > link[href*=".fr/static/bloc/ripolinage/header/cf-header/"]'))
group = '###_fr_gcf';
} else if (hostname.endsWith('.it')) {
2023-09-30 11:28:40 +00:00
if (document.querySelector('head > link[href^="//citynews.stgy.ovh/"]'))
group = '###_it_citynews';// no fix
2023-05-18 06:22:47 +00:00
else if (matchDomain(['gazzettadimodena.it', 'gazzettadireggio.it', 'lanuovaferrara.it']))
group = '###_it_gruppo_sae';
} else if (hostname.endsWith('.nl')) {
2023-09-30 11:28:40 +00:00
if (document.querySelector('head > link[href*=".ndcmediagroep.nl/"]'))
group = '###_nl_mediahuis_noord';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('head > link[rel="dns-prefetch"][href^="https://vmn-"][href$="imgix.net"]'))
2023-07-13 05:41:38 +00:00
group = '###_nl_vmnmedia';// no fix
2023-07-03 14:18:24 +00:00
} else if (hostname.endsWith('.se')) {
if (document.querySelector('footer > div > div > a[href="https://www.nwtmedia.se/"]'))
group = '###_se_nwt_media';
2023-02-17 17:19:29 +00:00
} else if (hostname.endsWith('.co.uk')) {
if (document.querySelector('footer > div a[href^="https://www.nationalworldplc.com"]'))
group = '###_uk_nat_world';
2023-09-21 18:55:33 +00:00
else if (matchDomain(['investmentweek.co.uk']))
group = '###_uk_incisive_media';
2023-03-27 16:54:50 +00:00
} else if (hostname.match(/\.(ca|com|net|news|org)$/)) {
if (document.querySelector('picture > source[srcset*="%2Fgcm.omerlocdn.com%2F"]'))
group = '###_ca_gcm';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('script[src*=".postmedia.digital/"], head > meta[content*=".postmedia.digital/"]'))
group = '###_ca_postmedia';
2023-10-24 06:08:45 +00:00
else if (document.querySelector('script[src*=".axate.io/"], script[src*=".agate.io/"]'))
group = '###_uk_axate.io';
2023-09-21 18:55:33 +00:00
else if (matchDomain(['businessgreen.com', 'internationalinvestment.net', 'professionaladviser.com', 'professionalpensions.com']))
group = '###_uk_incisive_media';
2023-08-26 13:52:41 +00:00
else if (document.querySelector('script[src="https://cdn.blueconic.net/bridgetowermedia.js"], header.site-header > div.btm-header'))
group = '###_usa_bridge_tower';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('img[srcset^="https://www.gannett-cdn.com/"], head > link[href*=".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';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('head > meta[content^="https://www.mcclatchy-wires.com/"], a[href^="https://classifieds.mcclatchy.com/"], script[src*=".mcclatchyinteractive.com/"]'))
group = '###_usa_mcc';
2023-09-22 11:12:49 +00:00
else if (document.querySelector('script[src*="/wp-content/plugins/dfm"], amp-img#paywall[src*=".com/wp-content/plugins/dfm-amp-mods/"]'))
group = '###_usa_mng';
else if (hostname.match(/\.com$/)) {
if (matchDomain(['journalauto.com', 'journaldupneu.com', 'j2rauto.com']))
group = '###_fr_synerj';
2023-09-30 11:28:40 +00:00
else if (document.querySelector('head > link[href*=".com/wp-content/themes/madavor/"]'))
group = '###_usa_madavor';
else if (matchDomain(['centralmaine.com', 'pressherald.com', 'sunjournal.com']))
group = '###_usa_maine_trust';
2023-03-24 15:06:51 +00:00
else if (document.querySelector('img[data-src*="/wp-content/plugins/pragmatic-pei-rebranding/"]'))
group = '###_usa_pei';
2023-04-21 13:40:41 +00:00
else if (matchDomain(['dayton.com', 'daytondailynews.com', 'journal-news.com', 'springfieldnewssun.com']))
group = 'ajc.com';// Cox First Media
else if (matchDomain(['accountingtoday.com', 'benefitnews.com', 'bondbuyer.com', 'dig-in.com', 'financial-planning.com', 'nationalmortgagenews.com']))
group = 'americanbanker.com';// Arizent
}
} else {
if (matchDomain(['insideretail.asia', 'insideretail.co.nz' ,'insideretail.com.au', 'insideretail.us']))
group = '###_au_inside_retail';
}
ext_api.runtime.sendMessage({
request: 'custom_domain',
data: {
domain: custom_domain,
group: group
}
});
}
}, 1000);
}
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;
}
2022-11-24 16:30:56 +00:00
function getCookieDomain(hostname) {
let domain = hostname;
let n = 0;
let parts = hostname.split('.');
let str = '_gd' + (new Date()).getTime();
try {
while (n < (parts.length - 1) && document.cookie.indexOf(str + '=' + str) == -1) {
domain = parts.slice(-1 - (++n)).join('.');
document.cookie = str + "=" + str + ";domain=" + domain + ";";
}
document.cookie = str + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=" + domain + ";";
} catch (e) {
console.log(e);
}
return domain;
}