Fix Tech in Asia (json)

Update options (search)
This commit is contained in:
magnolia1234 2024-03-13 19:44:25 +01:00
parent a65c3feb88
commit 2f8eefe068
9 changed files with 101 additions and 60 deletions

View file

@ -529,6 +529,7 @@ ext_api.storage.local.get({
// reset ungrouped sites // reset ungrouped sites
let ungrouped_sites = { let ungrouped_sites = {
'The Athletic': 'theathletic.com', 'The Athletic': 'theathletic.com',
'The Stage Media (UK)': '###_uk_thestage_media',
'The Week (regwall)': 'theweek.com' 'The Week (regwall)': 'theweek.com'
}; };
for (let key in ungrouped_sites) { for (let key in ungrouped_sites) {

View file

@ -8,6 +8,8 @@ Add Observador.pt
Fix Autosport (js) Fix Autosport (js)
Fix Fast Company (premium) Fix Fast Company (premium)
Fix Mid-Day (amp-redirect) Fix Mid-Day (amp-redirect)
Fix Tech in Asia (json)
Update options (search)
* v3.5.9.0 (2024-03-10) * v3.5.9.0 (2024-03-10)
Add Funke Mediengruppe (fetch from archive.is) Add Funke Mediengruppe (fetch from archive.is)

View file

@ -5142,37 +5142,31 @@ else if (matchDomain('swarajyamag.com')) {
} }
else if (matchDomain('techinasia.com')) { else if (matchDomain('techinasia.com')) {
window.setTimeout(function () { let paywall = document.querySelector('div.paywall-content');
let paywall = document.querySelector('div.paywall-content'); if (paywall && dompurify_loaded) {
if (paywall && dompurify_loaded) { paywall.classList.remove('paywall-content');
paywall.classList.remove('paywall-content'); let url = window.location.href;
let par_missing = paywall.querySelectorAll('div[id^="attachment_"], a.flourish-credit'); let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/');
let attach_xhr = Array.from(par_missing).some(x => !x.hasChildNodes()); fetch(url_xhr)
if (attach_xhr) { .then(response => {
let url = window.location.href; if (response.ok) {
let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/'); response.json().then(json => {
fetch(url_xhr) let json_text = json.posts[0].content;
.then(response => { json_text = json_text.replace(/width\=\"(\d){3,}\"/g, 'width="100%"').replace(/height\=\"(\d){3,}\"/g, 'height="100%"');
if (response.ok) { let content = document.querySelector('div.content');
response.json().then(json => { if (json_text && content) {
let json_text = json.posts[0].content; let parser = new DOMParser();
json_text = json_text.replace(/width\=\"(\d){3,}\"/g, 'width="100%"').replace(/height\=\"(\d){3,}\"/g, 'height="100%"'); let doc = parser.parseFromString('<div class="jsx-1794864983 content">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let content = document.querySelector('div.content'); let content_new = doc.querySelector('div.content');
if (json_text && content) { content.parentNode.replaceChild(content_new, content);
let parser = new DOMParser();
let doc = parser.parseFromString('<div class="jsx-1794864983 content">' + DOMPurify.sanitize(json_text) + '</div>', 'text/html');
let content_new = doc.querySelector('div.content');
content.parentNode.replaceChild(content_new, content);
}
});
} }
}); });
} }
} });
let splash_subscribe = document.querySelector('div.splash-subscribe'); }
let paywall_hard = document.querySelector('div.paywall-hard'); let splash_subscribe = document.querySelector('div.splash-subscribe');
removeDOMElement(splash_subscribe, paywall_hard); let paywall_hard = document.querySelector('div.paywall-hard');
}, 3000); removeDOMElement(splash_subscribe, paywall_hard);
} }
else if (matchDomain(['techtarget.com', 'computerweekly.com', 'lemagit.fr'])) { else if (matchDomain(['techtarget.com', 'computerweekly.com', 'lemagit.fr'])) {

View file

@ -51,5 +51,5 @@
"webRequestBlocking", "webRequestBlocking",
"*://*/*" "*://*/*"
], ],
"version": "3.5.9.4" "version": "3.5.9.5"
} }

View file

@ -1,6 +1,6 @@
{ {
"###_remove_sites": { "###_remove_sites": {
"cs_code": "dn.se, faithfullymagazine.com, gazetaprawna.pl, lyrik.fr, mailplus.co.uk", "cs_code": "dn.se, faithfullymagazine.com, gazetaprawna.pl, lyrik.fr, mailplus.co.uk, portfolio.hu",
"domain": "###" "domain": "###"
}, },
"Abajournal.com": { "Abajournal.com": {
@ -18,7 +18,7 @@
"block_regex": "\\.acadienouvelle\\.com\\/script\\.js", "block_regex": "\\.acadienouvelle\\.com\\/script\\.js",
"domain": "acadienouvelle.com" "domain": "acadienouvelle.com"
}, },
"Airmail.news (refresh)": { "Airmail.news": {
"add_ext_link": "div.paywall-card|div.article-text", "add_ext_link": "div.paywall-card|div.article-text",
"add_ext_link_type": "archive.is", "add_ext_link_type": "archive.is",
"allow_cookies": 1, "allow_cookies": 1,
@ -644,16 +644,9 @@
"Physicsworld.com": { "Physicsworld.com": {
"domain": "physicsworld.com" "domain": "physicsworld.com"
}, },
"Piratewires.com (refresh)": { "Piratewires.com": {
"allow_cookies": 1, "allow_cookies": 1,
"cs_code": "[{\"cond\":\"div[class*='article_articleRestricted_']\", \"rm_attrib\":\"class\"}, {\"cond\":\"div[class^='fixedOverlay']\", \"rm_elem\":1}]", "domain": "piratewires.com",
"domain": "piratewires.com"
},
"Portfolio.hu": {
"add_ext_link": "section.paywall|article",
"add_ext_link_type": "archive.is",
"allow_cookies": 1,
"domain": "portfolio.hu",
"useragent": "googlebot" "useragent": "googlebot"
}, },
"Pourleco.com": { "Pourleco.com": {
@ -790,10 +783,11 @@
"domain": "t3n.de", "domain": "t3n.de",
"ld_json": "div.c-pro-wall__wrapper|div.pro-blur>p" "ld_json": "div.c-pro-wall__wrapper|div.pro-blur>p"
}, },
"Tamedia.ch (refresh)": { "Tamedia.ch": {
"add_ext_link": "div#piano-premium|p[class^='ArticleParagraph_root_']", "add_ext_link": "div#piano-premium|p[class^='ArticleParagraph_root_']",
"add_ext_link_type": "google_search_tool", "add_ext_link_type": "google_search_tool",
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "\\.tinypass\\.com",
"domain": "###_ch_tamedia" "domain": "###_ch_tamedia"
}, },
"Taxscan.in": { "Taxscan.in": {

View file

@ -857,5 +857,5 @@
"*://archive.vn/*", "*://archive.vn/*",
"*://webcache.googleusercontent.com/*" "*://webcache.googleusercontent.com/*"
], ],
"version": "3.5.9.4" "version": "3.5.9.5"
} }

View file

@ -10,7 +10,7 @@
<h1 id="top">Options | <small><span id="version"></span><br><span id="version_new"></span></small></h1> <h1 id="top">Options | <small><span id="version"></span><br><span id="version_new"></span></small></h1>
<br><a href="https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/blob/master/changelog.txt" target="_blank">Changelog</a> <br><a href="https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/blob/master/changelog.txt" target="_blank">Changelog</a>
<div style="width:90%;"> <div style="width:90%;">
<br>Some selected sites will have their cookies cleared; uncheck the sites (or add to excluded sites) for which you have an account or else you will be logged out at every visit.<br> <br>Some selected sites will have their cookies cleared; uncheck the sites (or add to excluded sites) for which you have an account.<br>
If you also want to block general paywall-scripts for unlisted sites you have to opt-in to custom sites (host permission for access to all sites is needed). If you also want to block general paywall-scripts for unlisted sites you have to opt-in to custom sites (host permission for access to all sites is needed).
<!-- To view some sites (check list) a necessary cookie has to be set (enable this in opt-in). --> <!-- To view some sites (check list) a necessary cookie has to be set (enable this in opt-in). -->
</div> </div>
@ -23,6 +23,7 @@
<small><button id="clear_sites_updated">Clear updated sites</button></small> <small><button id="clear_sites_updated">Clear updated sites</button></small>
<small><button><a href="options_excluded.html" style="text-decoration:none;color:inherit">Excluded sites</a></button></small> <small><button><a href="options_excluded.html" style="text-decoration:none;color:inherit">Excluded sites</a></button></small>
<small><button><a href="#save" style="text-decoration:none;color:inherit">Go to bottom</a></button></small> <small><button><a href="#save" style="text-decoration:none;color:inherit">Go to bottom</a></button></small>
<input id="search" type="text" size="30" placeholder="Search (domain)name ...">
</div> </div>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<strong style="color:red;"><div id="perm-custom"></div></strong> <strong style="color:red;"><div id="perm-custom"></div></strong>

View file

@ -5,7 +5,7 @@ function save_options(event) {
var inputEls = document.querySelectorAll('#bypass_sites input'); var inputEls = document.querySelectorAll('#bypass_sites input');
var sites = {}; var sites = {};
var sites = Array.from(inputEls).reduce(function(memo, inputEl) { var sites = Array.from(inputEls).reduce(function (memo, inputEl) {
if (inputEl.checked) { if (inputEl.checked) {
memo[inputEl.dataset.key] = inputEl.dataset.value; memo[inputEl.dataset.key] = inputEl.dataset.value;
} }
@ -14,17 +14,17 @@ function save_options(event) {
ext_api.storage.local.set({ ext_api.storage.local.set({
sites: sites sites: sites
}, function() { }, function () {
// Update status to let user know options were saved. // Update status to let user know options were saved.
if (event) { if (event) {
var status_label = document.querySelectorAll('[id^="status"]'); var status_label = document.querySelectorAll('[id^="status"]');
for (let status of status_label) { for (let status of status_label) {
status.textContent = 'Options saved.'; status.textContent = 'Options saved.';
setTimeout(function () { setTimeout(function () {
status.textContent = ''; status.textContent = '';
}, 800); }, 800);
} }
} }
}); });
} }
@ -116,8 +116,55 @@ function renderOptions() {
}); });
} }
function handleSearch() {
let search = document.getElementById('search').value.toLowerCase().replace('www.', '');
let listItems = document.querySelectorAll('#bypass_sites > label');
grouped_sites = filterObject(grouped_sites, function (val, key) {
return val.length
});
ext_api.storage.local.get({
sites_updated: {},
sites_custom: {}
}, function (items) {
let sites_updated_groups = filterObject(items.sites_updated, function (val, key) {
return val.group
}, function (val, key) {
return [val.domain, val.group]
});
for (let site in sites_updated_groups) {
let site_default = Object.keys(defaultSites).find(key => compareKey(key, site)) || site;
grouped_sites[site_default] = sites_updated_groups[site];
}
let sites_custom_groups = filterObject(items.sites_custom, function (val, key) {
return val.group
}, function (val, key) {
return [val.domain, val.group.split(',')]
});
for (let site in sites_custom_groups)
grouped_sites[site] = sites_custom_groups[site];
for (let item of listItems) {
let itemText = item.textContent.toLowerCase();
let itemInput = item.querySelector('input[data-value]');
let itemDomain = itemInput ? itemInput.getAttribute('data-value') : '';
let itemGroup = itemDomain ? grouped_sites[itemDomain] : '';
if (itemText.includes(search) || !itemDomain || (itemDomain && (itemDomain.match(/^(###$|#options_[^d])/) || itemDomain.includes(search) || (itemGroup && itemGroup.includes(search)))))
item.style.display = 'block';
else
item.style.display = 'none';
}
});
let selectButtons = document.querySelectorAll('#select-all, #select-none');
for (let elem of selectButtons) {
if (search == '')
elem.style.display = 'block';
else
elem.style.display = 'none';
}
}
function selectAll() { function selectAll() {
var inputEls = Array.from(document.querySelectorAll('input')); var inputEls = Array.from(document.querySelectorAll('input[data-key]'));
inputEls = inputEls.filter(function (input) { inputEls = inputEls.filter(function (input) {
return (!input.dataset.value.match(/^#options_(disable|optin)_/)); return (!input.dataset.value.match(/^#options_(disable|optin)_/));
}); });
@ -169,6 +216,7 @@ document.getElementById('save').addEventListener('click', save_options);
document.getElementById('save_top').addEventListener('click', save_options); document.getElementById('save_top').addEventListener('click', save_options);
document.getElementById('select-all').addEventListener('click', selectAll); document.getElementById('select-all').addEventListener('click', selectAll);
document.getElementById('select-none').addEventListener('click', selectNone); document.getElementById('select-none').addEventListener('click', selectNone);
document.getElementById("button-close").addEventListener('click', closeButton); document.getElementById('button-close').addEventListener('click', closeButton);
document.getElementById('check_sites_updated').addEventListener('click', check_sites_updated); document.getElementById('check_sites_updated').addEventListener('click', check_sites_updated);
document.getElementById('clear_sites_updated').addEventListener('click', clear_sites_updated); document.getElementById('clear_sites_updated').addEventListener('click', clear_sites_updated);
document.getElementById('search').addEventListener('input', handleSearch);

View file

@ -2262,6 +2262,7 @@ var defaultSites = {
"Tech in Asia": { "Tech in Asia": {
domain: "techinasia.com", domain: "techinasia.com",
allow_cookies: 1, allow_cookies: 1,
useragent: "googlebot",
cs_dompurify: 1 cs_dompurify: 1
}, },
"TechTarget Group": { "TechTarget Group": {
@ -2621,7 +2622,7 @@ var defaultSites = {
block_regex: /\.tinypass\.com\// block_regex: /\.tinypass\.com\//
}, },
"The Stage Media (UK)": { "The Stage Media (UK)": {
"domain": "uk_thestage_media", "domain": "###_uk_thestage_media",
"allow_cookies": 1, "allow_cookies": 1,
"group": [ "group": [
"thebookseller.com", "thebookseller.com",
@ -3097,4 +3098,4 @@ var fr_groupe_ebra_nofix_domains = ['bienpublic.com', 'dna.fr', 'estrepublicain.
var fr_indigo_nofix_domains = ['africaintelligence.com', 'africaintelligence.fr', 'glitz.paris', 'intelligenceonline.com', 'intelligenceonline.fr', 'lalettre.fr']; var fr_indigo_nofix_domains = ['africaintelligence.com', 'africaintelligence.fr', 'glitz.paris', 'intelligenceonline.com', 'intelligenceonline.fr', 'lalettre.fr'];
var it_gedi_nofix_domains = ['gelocal.it', 'limesonline.com']; var it_gedi_nofix_domains = ['gelocal.it', 'limesonline.com'];
var nl_mediahuis_region_nofix_domains = ['gooieneemlander.nl', 'haarlemsdagblad.nl', 'ijmuidercourant.nl', 'leidschdagblad.nl', 'noordhollandsdagblad.nl']; var nl_mediahuis_region_nofix_domains = ['gooieneemlander.nl', 'haarlemsdagblad.nl', 'ijmuidercourant.nl', 'leidschdagblad.nl', 'noordhollandsdagblad.nl'];
var nofix_sites = ['11freunde.de', 'aamulehti.fi', 'aftenposten.no', 'aftonbladet.se', 'allgaeuer-zeitung.de', 'arkansasonline.com', 'asahi.com', 'asiatimes.com', 'aviationweek.com', 'badische-zeitung.de', 'bhaskar.com', 'bloomberglaw.com', 'bloombergtax.com', 'bnef.com', 'bnn.de', 'borsen.dk', 'businessinsider.de', 'businessinsider.jp', 'businesslive.co.za', 'businesstimes.com.sg', 'caixin.com', 'caixinglobal.com', 'caravanmagazine.in', 'catalyst-journal.com', 'chegg.com', 'codesports.com.au', 'compactmag.com', 'coursehero.com', 'deutsche-wirtschafts-nachrichten.de', 'die-glocke.de', 'dn.no', 'dn.se', 'elordenmundial.com', 'entrepreneur.com', 'epw.in', 'ewmagazine.nl', 'falter.at', 'finance.si', 'franc-tireur.fr', 'ftchinese.com', 'ftchineselive.com', 'gamestar.de', 'geo.de', 'golem.de', 'gp.se', 'gva.be', 'handelsblatt.com', 'hbrarabic.com', 'hbrchina.org', 'hbrfrance.fr', 'heise.de', 'hs.fi', 'information.dk', 'investors.com', 'iltalehti.fi', 'jacobin.com', 'jeuneafrique.com', 'jungefreiheit.de', 'kleinezeitung.at', 'krone.at', 'laverita.info', 'lavie.fr', 'lavozdegalicia.es', 'law360.co.uk', 'law360.com', 'le1hebdo.fr', 'leconomiste.com', 'lefigaro.fr', 'lefilmfrancais.com', 'lemonde.fr', 'lequipe.fr', 'lesjours.fr', 'letemps.ch', 'liberation.fr', 'libertiesjournal.com', 'lr-online.de', 'main-echo.de', 'mainpost.de', 'manager-magazin.de', 'medianama.com', 'mediapart.fr', 'milanofinanza.it', 'mittelbayerische.de', 'monde-diplomatique.fr', 'mondediplo.com', 'money.it', 'moneycontrol.com', 'moodys.com', 'morningstar.com', 'motorsport.com', 'moz.de', 'nachrichten.at', 'nationaljournal.com', 'nature.com', 'nbr.co.nz', 'newcriterion.com', 'news24.com', 'newslaundry.com', 'nn.de', 'nwzonline.de', 'on3.com', 'ouest-france.fr', 'philonomist.com', 'pnp.de', 'politicopro.com', 'politiken.dk', 'pressreader.com', 'publico.pt', 'puck.news', 'quillette.com', 'rbc.ru', 'republic.ru', 'rheinpfalz.de', 'risk.net', 'rnz.de', 'saechsische.de', 'sciencedirect.com', 'springer.com', 'statnews.com', 'stern.de', 'stimme.de', 'streetinsider.com', 'substack.com', 'svd.se', 'swp.de', 'taxation.co.uk', 'taxjournal.com', 'the-ken.com', 'theinformation.com', 'theinitium.com', 'themorningcontext.com', 'theparisreview.org', 'thestar.com.my', 'thewirechina.com', 'timeslive.co.za', 'weltwoche.ch', 'weltwoche.de', 'wissenschaft.de', 'worldpoliticsreview.com', 'wz.de', 'zaobao.com.sg'].concat(de_funke_medien_nofix_domains, de_rp_aachen_medien_nofix_domains, de_westfalen_medien_nofix_domains, fr_be_groupe_rossel_nofix_domains, fr_groupe_ebra_nofix_domains, fr_indigo_nofix_domains, it_gedi_nofix_domains, nl_mediahuis_region_nofix_domains); var nofix_sites = ['11freunde.de', 'aamulehti.fi', 'aftenposten.no', 'aftonbladet.se', 'allgaeuer-zeitung.de', 'americanscientist.org', 'arkansasonline.com', 'asahi.com', 'asiatimes.com', 'aviationweek.com', 'badische-zeitung.de', 'bhaskar.com', 'bloomberglaw.com', 'bloombergtax.com', 'bnef.com', 'bnn.de', 'borsen.dk', 'businessinsider.de', 'businessinsider.jp', 'businesslive.co.za', 'businesstimes.com.sg', 'caixin.com', 'caixinglobal.com', 'caravanmagazine.in', 'catalyst-journal.com', 'chegg.com', 'codesports.com.au', 'compactmag.com', 'coursehero.com', 'deutsche-wirtschafts-nachrichten.de', 'die-glocke.de', 'dn.no', 'dn.se', 'elordenmundial.com', 'entrepreneur.com', 'epw.in', 'ewmagazine.nl', 'falter.at', 'finance.si', 'franc-tireur.fr', 'ftchinese.com', 'ftchineselive.com', 'gamestar.de', 'geo.de', 'golem.de', 'gp.se', 'gva.be', 'handelsblatt.com', 'hbrarabic.com', 'hbrchina.org', 'hbrfrance.fr', 'heise.de', 'hs.fi', 'information.dk', 'investors.com', 'iltalehti.fi', 'jacobin.com', 'jeuneafrique.com', 'jungefreiheit.de', 'kleinezeitung.at', 'krone.at', 'laverita.info', 'lavie.fr', 'lavozdegalicia.es', 'law360.co.uk', 'law360.com', 'le1hebdo.fr', 'leconomiste.com', 'lefigaro.fr', 'lefilmfrancais.com', 'lemonde.fr', 'lequipe.fr', 'lesjours.fr', 'letemps.ch', 'liberation.fr', 'libertiesjournal.com', 'lr-online.de', 'main-echo.de', 'mainpost.de', 'manager-magazin.de', 'medianama.com', 'mediapart.fr', 'milanofinanza.it', 'mittelbayerische.de', 'monde-diplomatique.fr', 'mondediplo.com', 'money.it', 'moneycontrol.com', 'moodys.com', 'morningstar.com', 'motorsport.com', 'moz.de', 'nachrichten.at', 'nationaljournal.com', 'nature.com', 'nbr.co.nz', 'newcriterion.com', 'news24.com', 'newslaundry.com', 'nn.de', 'nwzonline.de', 'on3.com', 'ouest-france.fr', 'philonomist.com', 'pnp.de', 'politicopro.com', 'politiken.dk', 'pressreader.com', 'publico.pt', 'puck.news', 'quillette.com', 'rbc.ru', 'republic.ru', 'rheinpfalz.de', 'risk.net', 'rnz.de', 'saechsische.de', 'sciencedirect.com', 'springer.com', 'statnews.com', 'stern.de', 'stimme.de', 'streetinsider.com', 'substack.com', 'svd.se', 'swp.de', 'taxation.co.uk', 'taxjournal.com', 'the-ken.com', 'theinformation.com', 'theinitium.com', 'themorningcontext.com', 'theparisreview.org', 'thestar.com.my', 'thewirechina.com', 'timeslive.co.za', 'weltwoche.ch', 'weltwoche.de', 'wissenschaft.de', 'worldpoliticsreview.com', 'wz.de', 'zaobao.com.sg'].concat(de_funke_medien_nofix_domains, de_rp_aachen_medien_nofix_domains, de_westfalen_medien_nofix_domains, fr_be_groupe_rossel_nofix_domains, fr_groupe_ebra_nofix_domains, fr_indigo_nofix_domains, it_gedi_nofix_domains, nl_mediahuis_region_nofix_domains);