diff --git a/README.md b/README.md index b40658d..462b4b4 100644 --- a/README.md +++ b/README.md @@ -400,7 +400,7 @@ Grouped in options:\ ##### United Kingdom/Ireland [Belfast Telegraph](https://www.belfasttelegraph.co.uk) - -[Business Post](https://www.businesspost.ie) - +[Business Post (link to archive.is)](https://www.businesspost.ie) - [Citywire](https://www.citywire.com) - [Euromoney](https://www.euromoney.com) - [Evening Standard](https://www.standard.co.uk) - diff --git a/background.js b/background.js index da730fc..02877d3 100644 --- a/background.js +++ b/background.js @@ -12,6 +12,8 @@ if (typeof ext_api.action !== 'object') { ext_api.action = ext_api.browserAction; } +const dompurify_sites = ['arcinfo.ch', 'belfasttelegraph.co.uk', 'bloomberg.com', 'cicero.de', 'defector.com', 'ilmanifesto.it', 'iltirreno.it', 'inc42.com', 'independent.ie', 'ipolitics.ca', 'italiaoggi.it', 'jacobin.de', 'lanuovasardegna.it', 'lecourrierdesstrateges.fr', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newscientist.com', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'sloanreview.mit.edu', 'stratfor.com', 'techinasia.com', 'thebulletin.org', 'vn.nl', 'zerohedge.com'].concat(nl_mediahuis_noord_domains, nl_mediahuis_region_domains, no_nhst_media_domains); +var optin_setcookie = false; var optin_update = true; var blocked_referer = false; @@ -347,6 +349,9 @@ function set_rules(sites, sites_updated, sites_custom) { ld_json_next[domain] = rule.ld_json_next; if (rule.ld_google_webcache) ld_google_webcache[domain] = rule.ld_google_webcache; + if (rule.ld_json || rule.ld_json_next || rule.ld_google_webcache) + if (!dompurify_sites.includes(domain)) + dompurify_sites.push(domain); if (rule.add_ext_link && rule.add_ext_link_type) add_ext_link[domain] = {css: rule.add_ext_link, type: rule.add_ext_link_type}; } @@ -383,6 +388,7 @@ ext_api.storage.local.get({ sites_updated: {}, sites_excluded: [], ext_version_old: '2.3.9.0', + optIn: false, optInUpdate: true }, function (items) { var sites = items.sites; @@ -393,6 +399,7 @@ ext_api.storage.local.get({ updatedSites = items.sites_updated; updatedSites_domains_new = Object.values(updatedSites).filter(x => (x.domain && !defaultSites_domains.includes(x.domain) || x.group)).map(x => x.group ? x.group.filter(y => !defaultSites_domains.includes(y)) : x.domain).flat(); var ext_version_old = items.ext_version_old; + optin_setcookie = items.optIn; optin_update = items.optInUpdate; excludedSites = items.sites_excluded; @@ -532,6 +539,9 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) { if (key === 'ext_version_new') { ext_version_new = storageChange.newValue; } + if (key === 'optIn') { + optin_setcookie = storageChange.newValue; + } if (key === 'optInUpdate') { optin_update = storageChange.newValue; } @@ -698,6 +708,8 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) { function blockJsInlineListener(details) { let domain = matchUrlDomain(blockedJsInlineDomains, details.url); let matched = domain && details.url.match(blockedJsInline[domain]); + if (matched && optin_setcookie && ['uol.com.br'].includes(domain)) + matched = false; if (!isSiteEnabled(details) || !matched) return; var headers = details.responseHeaders; @@ -737,7 +749,12 @@ if (typeof browser !== 'object') { let url = tab.url; let rc_domain = matchUrlDomain(remove_cookies, url); let rc_domain_enabled = rc_domain && enabledSites.includes(rc_domain); + let lib_file = 'lib/empty.js'; + if (matchUrlDomain(dompurify_sites, url)) + lib_file = 'lib/purify.min.js'; var bg2csData = {}; + if (optin_setcookie && matchUrlDomain(['crusoe.uol.com.br'], url)) + bg2csData.optin_setcookie = 1; if (matchUrlDomain(amp_unhide, url)) bg2csData.amp_unhide = 1; let amp_redirect_domain = ''; @@ -763,12 +780,19 @@ if (typeof browser !== 'object') { setTimeout(function () { // run contentScript.js on page ext_api.tabs.executeScript(tabId, { - file: 'contentScript.js', + file: lib_file, runAt: 'document_start' }, function (res) { - if (ext_api.runtime.lastError || res[0]) { + if (ext_api.runtime.lastError) return; - } + ext_api.tabs.executeScript(tabId, { + file: 'contentScript.js', + runAt: 'document_start' + }, function (res) { + if (ext_api.runtime.lastError || res[0]) { + return; + } + }) }); // send bg2csData to contentScript.js if (Object.keys(bg2csData).length) { @@ -1277,19 +1301,19 @@ function clear_cookies() { }); } - function customAddRules(custom_domain, rules) { - if (rules.allow_cookies && !allow_cookies.includes(custom_domain)) + function customAddRules(custom_domain, rule) { + if (rule.allow_cookies && !allow_cookies.includes(custom_domain)) allow_cookies.push(custom_domain); - if (rules.remove_cookies && !remove_cookies.includes(custom_domain)) + if (rule.remove_cookies && !remove_cookies.includes(custom_domain)) remove_cookies.push(custom_domain); - let custom_block_regex = rules.block_regex; + let custom_block_regex = rule.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; + let custom_useragent = rule.useragent; if (custom_useragent) { if (custom_useragent === 'googlebot') { if (!use_google_bot.includes(custom_domain)) @@ -1297,7 +1321,7 @@ function clear_cookies() { change_headers.push(custom_domain); } } - let custom_referer = rules.referer; + let custom_referer = rule.referer; if (custom_referer) { if (custom_referer === 'twitter') { if (!use_twitter_referer.includes(custom_domain)) @@ -1305,16 +1329,21 @@ function clear_cookies() { change_headers.push(custom_domain); } } - if (rules.amp_unhide) { + if (rule.amp_unhide) { if (!amp_unhide.includes(custom_domain)) amp_unhide.push(custom_domain); } - if (rules.ld_json) - ld_json[custom_domain] = rules.ld_json; - if (rules.ld_json_next) - ld_json_next[custom_domain] = rules.ld_json_next; - if (rules.add_ext_link && rules.add_ext_link_type) - add_ext_link[custom_domain] = {css: rules.add_ext_link, type: rules.add_ext_link_type}; + if (rule.ld_json) + ld_json[custom_domain] = rule.ld_json; + if (rule.ld_json_next) + ld_json_next[custom_domain] = rule.ld_json_next; + if (rule.ld_google_webcache) + ld_google_webcache[domain] = rule.ld_google_webcache; + if (rule.ld_json || rule.ld_json_next || rule.ld_google_webcache) + if (!dompurify_sites.includes(custom_domain)) + dompurify_sites.push(custom_domain); + if (rule.add_ext_link && rule.add_ext_link_type) + add_ext_link[custom_domain] = {css: rule.add_ext_link, type: rule.add_ext_link_type}; ext_api.tabs.reload({bypassCache: true}); } @@ -1443,6 +1472,19 @@ ext_api.runtime.onMessage.addListener(function (message, sender) { } }); +// show the opt-in tab on installation +ext_api.storage.local.get(["optInShown", "customShown"], function (result) { + if (!result.optInShown || !result.customShown) { + ext_api.tabs.create({ + url: "options/optin/opt-in.html" + }); + ext_api.storage.local.set({ + "optInShown": true, + "customShown": true + }); + } +}); + function filterObject(obj, filterFn, mapFn = function (val, key) { return [key, val]; }) { diff --git a/bpc_count_daily_users.js b/bpc_count_daily_users.js index 81c5be6..a30d466 100644 --- a/bpc_count_daily_users.js +++ b/bpc_count_daily_users.js @@ -37,4 +37,8 @@ function currentDateStr() { } var last_date_str = currentDateStr(); var daily_users; -bpc_count_daily_users(last_date_str); +ext_api.storage.local.get({counter: true}, function (result) { + if (result.counter) + bpc_count_daily_users(last_date_str); +}); + diff --git a/changelog.txt b/changelog.txt index 1077054..8a066d8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,8 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal Post-release Remove Medienhaus Aachen (fix obsolete) +Fix BusinessPost.ie (link to archive.is) +Maintenance contentScript (sanitize html-input) * v3.1.7.0 (2023-05-07) Add Cairns Post, Geelong Advertiser & Townsville Bulletin (Australia News Corp) diff --git a/contentScript.js b/contentScript.js index ed867ad..fad02cd 100644 --- a/contentScript.js +++ b/contentScript.js @@ -3,6 +3,7 @@ var ext_api = (typeof browser === 'object') ? browser : chrome; var domain; var csDone = false; var csDoneOnce = false; +var dompurify_loaded = (typeof DOMPurify === 'function'); var ar_grupo_clarin_domains = ['clarin.com', 'lavoz.com.ar', 'losandes.com.ar']; var be_groupe_ipm_domains = ['dhnet.be', 'lalibre.be', 'lavenir.net']; @@ -52,9 +53,9 @@ if (!matchDomain(arr_localstorage_hold)) { window.localStorage.clear(); } -function runOnMessage(bg2csData) { +function runOnMessage(bg2csData, dompurify_loaded) { // custom/updated sites: load text from json -if (bg2csData.ld_json) { +if (bg2csData.ld_json && dompurify_loaded) { if (bg2csData.ld_json.includes('|')) { window.setTimeout(function () { let ld_json_split = bg2csData.ld_json.split('|'); @@ -80,7 +81,7 @@ if (bg2csData.ld_json) { } if (json_text && article.parentNode) { let parser = new DOMParser(); - let doc = parser.parseFromString('
' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); let article_new = doc.querySelector('div'); if (article_append || !article.parentNode) { article.innerHTML = ''; @@ -97,7 +98,7 @@ if (bg2csData.ld_json) { } } -if (bg2csData.ld_json_next) { +if (bg2csData.ld_json_next && dompurify_loaded) { if (bg2csData.ld_json_next.includes('|')) { window.setTimeout(function () { let ld_json_next_split = bg2csData.ld_json_next.split('|'); @@ -117,7 +118,7 @@ if (bg2csData.ld_json_next) { let json_text = parseHtmlEntities(findKeyJson(json, ['body', 'content', 'description'], 500)); if (json_text && article.parentNode) { let parser = new DOMParser(); - let doc = parser.parseFromString('
' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); let article_new = doc.querySelector('div'); if (article_append || !article.parentNode) { article.innerHTML = ''; @@ -132,7 +133,7 @@ if (bg2csData.ld_json_next) { } // custom/updated sites: load text from Google webcache -if (bg2csData.ld_google_webcache) { +if (bg2csData.ld_google_webcache && dompurify_loaded) { if (bg2csData.ld_google_webcache.includes('|')) { window.setTimeout(function () { let url = window.location.href; @@ -184,6 +185,14 @@ if (bg2csData.add_ext_link) { } } +// check for opt-in confirmation (from background.js) +if (bg2csData.optin_setcookie) { + if (matchDomain(['crusoe.uol.com.br'])) { + if (!cookieExists('crs_subscriber')) + setCookie('crs_subscriber', 1, 'crusoe.uol.com.br', '/', 14); + } +} + // custom/updated sites: try to unhide text on amp-page if (bg2csData.amp_unhide) { window.setTimeout(function () { @@ -255,7 +264,7 @@ if (ext_api.runtime) { function (request, sender) { if (request.msg === 'bg2cs' && !msg_once) { msg_once = true; - runOnMessage(request.data); + runOnMessage(request.data, dompurify_loaded); } }) } @@ -560,7 +569,7 @@ else if (matchDomain('allgaeuer-zeitung.de')) { else if (matchDomain('arcinfo.ch')) { let paywall = document.querySelector('section#paywall-articles'); - if (paywall) { + if (paywall && dompurify_loaded) { removeDOMElement(paywall); let url_id = window.location.pathname.match(/\d+$/).pop(); let html = document.documentElement.outerHTML; @@ -589,7 +598,7 @@ else if (matchDomain('arcinfo.ch')) { if (content) { content = content.replace(/\\u003C/g, '<').replace(/\\u003E/g, '>').replace(/\\u002F/g, '/').replace(/\\"/g, '"').replace(/\\r\\n/g, ''); let parser = new DOMParser(); - let content_new = parser.parseFromString('
' + content + '
', 'text/html'); + let content_new = parser.parseFromString('
' + DOMPurify.sanitize(content) + '
', 'text/html'); let article_top; if (!no_intro) { article_top = article.parentNode.parentNode; @@ -773,7 +782,7 @@ else if (matchDomain('jacobin.de')) { } let content = par.text.replace(/ /g, ''); let parser = new DOMParser(); - let content_new = parser.parseFromString('<' + elem_type + ' class="' + elem_class + (elem_style ? '" style="' + elem_style : '') + '">' + content + '', 'text/html'); + let content_new = parser.parseFromString('<' + elem_type + ' class="' + elem_class + (elem_style ? '" style="' + elem_style : '') + '">' + DOMPurify.sanitize(content) + '', 'text/html'); article.appendChild(content_new.querySelector(elem_type)); } else console.log(par); @@ -1046,7 +1055,6 @@ else if (matchDomain(de_vrm_domains) || document.querySelector('meta[name^="cXen let pars = json_text.split(/(?=

)/); let page_items = json.contentPage.data.context.elements; if (json_text && page_items) { - let parser = new DOMParser(); let n = 0; let new_article = document.createElement('div'); new_article.setAttribute('style', 'font-size: 17px; font-family:Calibri, Helvetica, Arial; margin: auto; max-width: 620px;'); @@ -1565,7 +1573,7 @@ else if (matchDomain('lanouvellerepublique.fr')) { else if (matchDomain('lecourrierdesstrateges.fr')) { window.setTimeout(function () { let paywall = document.querySelector('div.jpw-truncate-btn'); - if (paywall) { + if (paywall && dompurify_loaded) { removeDOMElement(paywall); let json_script = getArticleJsonScript(); if (json_script) { @@ -1575,7 +1583,7 @@ else if (matchDomain('lecourrierdesstrateges.fr')) { let content = document.querySelector('div.content-inner'); if (json_text && content) { let parser = new DOMParser(); - let doc = parser.parseFromString('

' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); let content_new = doc.querySelector('div'); content.parentNode.replaceChild(content_new, content); let hidden_images = document.querySelectorAll('img[src][srcset]'); @@ -1668,7 +1676,7 @@ else if (matchDomain('lesechos.fr')) { let abo_banner = document.querySelector('div[class*="pgxf3b-2"]'); let ad_blocks = document.querySelectorAll('[class*="jzxvkd"]'); hideDOMElement(...ad_blocks); - if (abo_banner) { + if (abo_banner && dompurify_loaded) { removeDOMElement(abo_banner); let url = window.location.href; let html = document.documentElement.outerHTML; @@ -1686,7 +1694,7 @@ else if (matchDomain('lesechos.fr')) { if (paywallNode) { let contentNode = document.createElement('div'); let parser = new DOMParser(); - let article_html = parser.parseFromString('
' + article + '
', 'text/html'); + let article_html = parser.parseFromString('
' + DOMPurify.sanitize(article) + '
', 'text/html'); let article_par = article_html.querySelector('div'); if (article_par) { contentNode.appendChild(article_par); @@ -1740,12 +1748,12 @@ else if (matchDomain('loeildelaphotographie.com')) { else if (matchDomain('marianne.net')) { let paywall = document.querySelector('div.paywall'); - if (paywall) { + if (paywall && dompurify_loaded) { let article_source = document.querySelector('div.article-body[data-content-src]'); if (article_source) { let article_text = decode_utf8(atob(article_source.getAttribute('data-content-src'))); let parser = new DOMParser(); - let html = parser.parseFromString('
' + article_text + '
', 'text/html'); + let html = parser.parseFromString('
' + DOMPurify.sanitize(article_text) + '
', 'text/html'); let article = html.querySelector('div'); article_source.innerHTML = ''; article_source.appendChild(article); @@ -1904,7 +1912,7 @@ else if (matchDomain('ilmanifesto.it')) { window.setTimeout(function () { if (window.location.pathname.match(/((\w)+(\-)+){3,}/)) { let paywall = document.querySelector('div[class^="PostPaywall_PostPaywall__"]'); - if (paywall) { + if (paywall && dompurify_loaded) { removeDOMElement(paywall); let json_script = document.querySelector('script#__NEXT_DATA__'); if (json_script) { @@ -1915,7 +1923,7 @@ else if (matchDomain('ilmanifesto.it')) { if (article) { article.innerHTML = ''; let parser = new DOMParser(); - let doc = parser.parseFromString('
' + article_new + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(article_new) + '
', 'text/html'); let content_new = doc.querySelector('div'); article.appendChild(content_new); } @@ -1936,7 +1944,7 @@ else if (matchDomain('ilmanifesto.it')) { else if (matchDomain(['iltirreno.it', 'lanuovasardegna.it'])) { if (window.location.pathname.includes('/news/')) { let paywall = document.querySelector('div.MuiBox-root > h4.MuiTypography-h4'); - if (paywall) { + if (paywall && dompurify_loaded) { let article = document.querySelector('div.MuiGrid-root.MuiGrid-grid-sm-7 > div'); if (article) { removeDOMElement(paywall.parentNode); @@ -1952,7 +1960,7 @@ else if (matchDomain(['iltirreno.it', 'lanuovasardegna.it'])) { let article_new = JSON.parse(json.text).props.pageProps.article.content; if (article_new) { let parser = new DOMParser(); - let doc = parser.parseFromString('
' + article_new + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(article_new) + '
', 'text/html'); let content_new = doc.querySelector('div'); article.innerHTML = ''; article.appendChild(content_new); @@ -1999,7 +2007,7 @@ else if (matchDomain(it_quotidiano_domains)) { else if (matchDomain('italiaoggi.it')) { let paywall = document.querySelector('div.boxAbb'); - if (paywall) { + if (paywall && dompurify_loaded) { let overlay = document.querySelector('div.article-locked-overlay'); removeDOMElement(paywall, overlay); let article_locked = document.querySelector('div.article-locked'); @@ -2014,7 +2022,7 @@ else if (matchDomain('italiaoggi.it')) { if (json_text && content) { let parser = new DOMParser(); json_text = json_text.replace(/&apos;/g, "'").replace(/;/g, ''); - let doc = parser.parseFromString('
' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); let content_new = doc.querySelector('div'); content.parentNode.replaceChild(content_new, content); } @@ -2138,7 +2146,7 @@ else if (matchDomain(be_roularta_domains)) { else if (matchDomain(['lc.nl', 'dvhn.nl'])) { if (true) { let paywall = document.querySelector('div.signupPlus, div.pw-wrapper'); - if (paywall) { + if (paywall && dompurify_loaded) { let intro = document.querySelector('div.startPayWall'); removeDOMElement(paywall, intro); let html = document.documentElement.outerHTML; @@ -2170,7 +2178,7 @@ else if (matchDomain(['lc.nl', 'dvhn.nl'])) { if (par.typename === 'HTMLCustomEmbed') { if (par.code) { let parser = new DOMParser(); - let article_html = parser.parseFromString('
' + par.code + '
', 'text/html'); + let article_html = parser.parseFromString('
' + DOMPurify.sanitize(par.code) + '
', 'text/html'); elem = article_html.querySelector('div'); } } else if (par.insertbox_head || par.insertbox_text) { @@ -2251,7 +2259,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) { if (close_button) close_button.click(); let premium = document.querySelector('div.common-components-plus_pluslabel--container'); - if (premium) { + if (premium && dompurify_loaded) { let hidden_article = document.querySelector('div[data-auth-body="article"]'); if (hidden_article) hidden_article.removeAttribute('style'); @@ -2275,7 +2283,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) { par_elem = ''; par_key = par[key]; if (key === 'subhead') { - par_html = parser.parseFromString('
' + par_key + '
', 'text/html'); + par_html = parser.parseFromString('
' + DOMPurify.sanitize(par_key) + '
', 'text/html'); par_elem = par_html.querySelector('div'); } else if (key === 'twitter' || key === 'instagram') { par_elem = document.createElement('a'); @@ -2313,7 +2321,7 @@ else if (matchDomain(nl_mediahuis_region_domains)) { par_div.innerText += par[key].credit ? '\n' + par[key].credit : ''; par_elem.appendChild(par_div); } else { - par_html = parser.parseFromString('

' + par_key + '', 'text/html'); + par_html = parser.parseFromString('

' + DOMPurify.sanitize(par_key) + '', 'text/html'); par_elem = par_html.querySelector('p'); } if (par_elem) @@ -2424,7 +2432,7 @@ else if (matchDomain('telegraaf.nl')) { else if (matchDomain('vn.nl')) { let paywall = document.querySelector('div.content__message-no-access-container'); - if (paywall) { + if (paywall && dompurify_loaded) { let content_restriction = document.querySelector('div.content__restriction'); removeDOMElement(paywall, content_restriction); let body = document.querySelector('body'); @@ -2444,7 +2452,7 @@ else if (matchDomain('vn.nl')) { let content = document.querySelector('div[data-article-content-target]'); if (json_text && content) { let parser = new DOMParser(); - let doc = parser.parseFromString('

' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe'], ADD_ATTR: ['frameborder']}) + '
', 'text/html'); let content_new = doc.querySelector('div'); content.parentNode.replaceChild(content_new, content); } @@ -2462,7 +2470,7 @@ else if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) { let flip_pay = document.querySelector('div#flip-pay[style]'); - if (flip_pay) { + if (flip_pay && dompurify_loaded) { let content = document.querySelector('script[data-fragment-type="ArticleContent"]'); if (content) { removeDOMElement(flip_pay); @@ -2511,7 +2519,7 @@ if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) { } } } else if (type !== 'ad') { - let html = parser.parseFromString('

' + item + '

', 'text/html'); + let html = parser.parseFromString('

' + DOMPurify.sanitize(item, {ADD_TAGS: ['iframe']}) + '

', 'text/html'); elem = html.querySelector('p'); if (!['p', 'subhead', 'legacy-ml'].includes(type)) { console.log(type); @@ -2538,47 +2546,14 @@ if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) { } else if (matchDomain('businesspost.ie')) { - function bpie_main() { - if ($) { - let article_id_dom = document.querySelector('article[id]'); - let article_id; - if (article_id_dom) - article_id = article_id_dom.id; - if (article_id) { - let bp_ajaxurl = 'https://www.businesspost.ie/wp-admin/admin-ajax.php'; - let data_ajax = { - action: 'fetch_article_content', - type: 'POST', - data: { - id: article_id - }, - dataType: 'json', - contentType: 'application/json' - }; - $.ajax({ - type: 'POST', - url: bp_ajaxurl, - data: data_ajax, - success: function (data) { - $('main article .article-body-section').html(data); - } - }); - } - } else - window.location.reload(true); + let url = window.location.href; + let paywall = document.querySelector('div#bp_paywall_content'); + if (paywall) { + removeDOMElement(paywall); + let article = document.querySelector('div.article-body-section'); + if (article) + article.firstChild.before(archiveLink(url)); } - csDoneOnce = true; - window.setTimeout(function () { - let paywall = document.querySelector('div#bp_paywall_content'); - let article_id_dom = document.querySelector('article[id]'); - let article_id; - if (article_id_dom) - article_id = article_id_dom.id; - if (paywall || article_id) { - removeDOMElement(paywall); - insert_script(bpie_main); - } - }, 500); } else if (matchDomain('citywire.com')) { @@ -2740,8 +2715,6 @@ else if (matchDomain(ar_grupo_clarin_domains)) { } else if (matchDomain('crusoe.uol.com.br')) { - if (!cookieExists('crs_subscriber')) - setCookie('crs_subscriber', 1, 'crusoe.uol.com.br', '/', 14); let paywall = document.querySelector('#wallcontent'); let ads = document.querySelectorAll('#gpt-leaderboard, .ads_desktop, .catchment-box'); removeDOMElement(paywall, ...ads); @@ -3064,7 +3037,7 @@ else if (matchDomain('bloomberg.com')) { } let shimmering_content = document.querySelectorAll('div.shimmering-text'); let body_transparent = document.querySelector('div[class*="nearly-transparent-text-blur"]'); - if (shimmering_content.length || body_transparent) { + if ((shimmering_content.length || body_transparent) && dompurify_loaded) { removeDOMElement(...shimmering_content); if (body_transparent) removeClassesByPrefix(body_transparent, 'nearly-transparent-text-blur'); @@ -3092,7 +3065,7 @@ else if (matchDomain('bloomberg.com')) { if (article) { article_class += ' art_done'; let parser = new DOMParser(); - let doc = parser.parseFromString('
' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe', 'script']}) + '
', 'text/html'); let article_new = doc.querySelector('div'); if (article_new) { article.parentNode.replaceChild(article_new, article); @@ -3255,7 +3228,7 @@ else if (matchDomain('dallasnews.com')) { else if (matchDomain('defector.com')) { let paywall = document.querySelector('[class^="ContentGate_wrapper__"]'); - if (paywall) { + if (paywall && dompurify_loaded) { removeDOMElement(paywall); let url = window.location.href; try { @@ -3268,7 +3241,7 @@ else if (matchDomain('defector.com')) { let article_new = doc.querySelector('div[class^="PostContent_wrapper__"]'); let article = document.querySelector('div[class^="PostContent_wrapper__"]'); if (article && article_new) - article.parentNode.replaceChild(article_new, article); + article.parentNode.replaceChild(DOMPurify.sanitize(article_new), article); }); } }); @@ -3659,7 +3632,7 @@ else if (matchDomain('inkl.com')) { else if (matchDomain('ipolitics.ca')) { let login = document.querySelector('div.login'); - if (login) { + if (login && dompurify_loaded) { removeDOMElement(login); let json_script = document.querySelector('script#__NEXT_DATA__'); if (json_script) { @@ -3675,7 +3648,7 @@ else if (matchDomain('ipolitics.ca')) { article.innerHTML = ''; article.classList.remove('locked'); let parser = new DOMParser(); - let doc = parser.parseFromString('
' + article_new + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(article_new) + '
', 'text/html'); let content_new = doc.querySelector('div'); article.appendChild(content_new); } @@ -3910,7 +3883,7 @@ else if (matchDomain('nzherald.co.nz')) { else if (matchDomain('outlookbusiness.com')) { let paywall = document.querySelector('div#csc-paywall'); - if (paywall) { + if (paywall && dompurify_loaded) { removeDOMElement(paywall); let json_script = document.querySelector('script#__NEXT_DATA__'); if (json_script) { @@ -3921,7 +3894,7 @@ else if (matchDomain('outlookbusiness.com')) { if (article) { article.innerHTML = ''; let parser = new DOMParser(); - let doc = parser.parseFromString('
' + article_new + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(article_new) + '
', 'text/html'); let content_new = doc.querySelector('div'); article.appendChild(content_new); } @@ -4156,7 +4129,7 @@ else if (matchDomain('stratfor.com')) { hidden_image.setAttribute('src', hidden_image.getAttribute('data-src')); if (window.location.pathname.match(/(\/(\d){4}-([a-z]|-)+-forecast(-([a-z]|-)+)?|-forecast-(\d){4}-([a-z]|[0-9]|-)+)$/)) { let json_script = document.querySelector('script#__NEXT_DATA__'); - if (json_script) { + if (json_script && dompurify_loaded) { let json = JSON.parse(json_script.innerText); if (json && json.props.pageProps.data) { let overview_div = document.querySelector('div[class^="overview_overview__"] > div'); @@ -4166,7 +4139,7 @@ else if (matchDomain('stratfor.com')) { let data_overview = data.overview; if (!parseHtmlEntities(data_overview).includes(data.teaser_body)) data_overview = '

' + data.teaser_body + '

' + data_overview; - let doc = parser.parseFromString('
' + data_overview + '

Sections

' + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(data_overview) + '

Sections

' + '
', 'text/html'); let content_new = doc.querySelector('div'); let sections = data.section; for (let section of sections) { @@ -4215,7 +4188,7 @@ else if (matchDomain('studocu.com')) { else if (matchDomain('techinasia.com')) { let paywall = document.querySelector('.paywall-content'); - if (paywall) { + if (paywall && dompurify_loaded) { paywall.classList.remove('paywall-content'); let url = window.location.href; let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/'); @@ -4228,7 +4201,7 @@ else if (matchDomain('techinasia.com')) { let content = document.querySelector('div.content'); if (json_text && content) { let parser = new DOMParser(); - let doc = parser.parseFromString('
' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); let content_new = doc.querySelector('div.content'); content.parentNode.replaceChild(content_new, content); } @@ -4639,7 +4612,7 @@ else if (matchDomain(no_nhst_media_domains)) { } else { window.setTimeout(function () { let paywall = document.querySelector('iframe#paywall-iframe'); - if (paywall) { + if (paywall && dompurify_loaded) { let intro = document.querySelector('div.global-article-selector'); let article = paywall.parentNode; removeDOMElement(paywall, intro); @@ -4654,7 +4627,7 @@ else if (matchDomain(no_nhst_media_domains)) { if (json) { let json_text = json.article.body; let parser = new DOMParser(); - let doc = parser.parseFromString('
' + json_text + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text, {ADD_ATTR: ['itemprop'], ADD_TAGS: ['link']}) + '
', 'text/html'); let article_new = doc.querySelector('div'); if (article_new) { if (article) @@ -4785,7 +4758,7 @@ else if (matchDomain('wsj.com')) { else if (matchDomain('zerohedge.com')) { window.setTimeout(function () { let paywall = document.querySelector('div[class^="PremiumOverlay_container__"]'); - if (paywall) { + if (paywall && dompurify_loaded) { removeDOMElement(paywall); let json_script = document.querySelector('script#__NEXT_DATA__'); if (json_script) { @@ -4797,7 +4770,7 @@ else if (matchDomain('zerohedge.com')) { if (article) { article.innerHTML = ''; let parser = new DOMParser(); - let doc = parser.parseFromString('
' + article_new + '
', 'text/html'); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(article_new) + '
', 'text/html'); let content_new = doc.querySelector('div'); article.appendChild(content_new); } @@ -5012,7 +4985,8 @@ function replaceDomElementExtSrc(url, html, proxy, base64, selector, text_fail = } let parser = new DOMParser(); window.setTimeout(function () { - let doc = parser.parseFromString(html, 'text/html'); + let doc = parser.parseFromString(DOMPurify.sanitize(html, {ADD_ATTR: ['layout', 'itemprop'], ADD_TAGS: ['amp-img', 'iframe']}), 'text/html'); + //console.log(DOMPurify.removed); let article_new = doc.querySelector(selector_source); if (article_new) { if (article && article.parentNode) diff --git a/custom/manifest.json b/custom/manifest.json index 23ab493..0cbaa53 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.1.7.1" + "version": "3.1.7.2" } diff --git a/lib/empty.js b/lib/empty.js new file mode 100644 index 0000000..e69de29 diff --git a/lib/purify.min.js b/lib/purify.min.js new file mode 100644 index 0000000..6baa5c9 --- /dev/null +++ b/lib/purify.min.js @@ -0,0 +1,3 @@ +/*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;c||(c=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),a||(a=function(e){return e}),s||(s=function(e,t){return new e(...t)});const m=b(Array.prototype.forEach),u=b(Array.prototype.pop),f=b(Array.prototype.push),p=b(String.prototype.toLowerCase),d=b(String.prototype.toString),h=b(String.prototype.match),g=b(String.prototype.replace),T=b(String.prototype.indexOf),y=b(String.prototype.trim),E=b(RegExp.prototype.test),A=(_=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),r=1;r/gm),H=a(/\${[\w\W]*}/gm),z=a(/^data-[\-\w.\u00B7-\uFFFF]/),B=a(/^aria-[\-\w]+$/),W=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=a(/^(?:\w+script|data):/i),Y=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),j=a(/^html$/i);var q=Object.freeze({__proto__:null,MUSTACHE_EXPR:P,ERB_EXPR:F,TMPLIT_EXPR:H,DATA_ATTR:z,ARIA_ATTR:B,IS_ALLOWED_URI:W,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:Y,DOCTYPE_NAME:j});const X=()=>"undefined"==typeof window?null:window,K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};var V=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X();const o=e=>t(e);if(o.version="3.0.3",o.removed=[],!n||!n.document||9!==n.document.nodeType)return o.isSupported=!1,o;const r=n.document,a=r.currentScript;let{document:l}=n;const{DocumentFragment:c,HTMLTemplateElement:s,Node:_,Element:b,NodeFilter:P,NamedNodeMap:F=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:H,DOMParser:z,trustedTypes:B}=n,G=b.prototype,Y=R(G,"cloneNode"),V=R(G,"nextSibling"),$=R(G,"childNodes"),Z=R(G,"parentNode");if("function"==typeof s){const e=l.createElement("template");e.content&&e.content.ownerDocument&&(l=e.content.ownerDocument)}let J,Q="";const{implementation:ee,createNodeIterator:te,createDocumentFragment:ne,getElementsByTagName:oe}=l,{importNode:re}=r;let ie={};o.isSupported="function"==typeof e&&"function"==typeof Z&&ee&&void 0!==ee.createHTMLDocument;const{MUSTACHE_EXPR:ae,ERB_EXPR:le,TMPLIT_EXPR:ce,DATA_ATTR:se,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:ue,ATTR_WHITESPACE:fe}=q;let{IS_ALLOWED_URI:pe}=q,de=null;const he=N({},[...w,...D,...L,...x,...k]);let ge=null;const Te=N({},[...O,...I,...M,...U]);let ye=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ee=null,Ae=null,_e=!0,be=!0,Ne=!1,Se=!0,Re=!1,we=!1,De=!1,Le=!1,ve=!1,xe=!1,Ce=!1,ke=!0,Oe=!1;const Ie="user-content-";let Me=!0,Ue=!1,Pe={},Fe=null;const He=N({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ze=null;const Be=N({},["audio","video","img","source","image","track"]);let We=null;const Ge=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ye="http://www.w3.org/1998/Math/MathML",je="http://www.w3.org/2000/svg",qe="http://www.w3.org/1999/xhtml";let Xe=qe,Ke=!1,Ve=null;const $e=N({},[Ye,je,qe],d);let Ze;const Je=["application/xhtml+xml","text/html"],Qe="text/html";let et,tt=null;const nt=l.createElement("form"),ot=function(e){return e instanceof RegExp||e instanceof Function},rt=function(e){if(!tt||tt!==e){if(e&&"object"==typeof e||(e={}),e=S(e),Ze=Ze=-1===Je.indexOf(e.PARSER_MEDIA_TYPE)?Qe:e.PARSER_MEDIA_TYPE,et="application/xhtml+xml"===Ze?d:p,de="ALLOWED_TAGS"in e?N({},e.ALLOWED_TAGS,et):he,ge="ALLOWED_ATTR"in e?N({},e.ALLOWED_ATTR,et):Te,Ve="ALLOWED_NAMESPACES"in e?N({},e.ALLOWED_NAMESPACES,d):$e,We="ADD_URI_SAFE_ATTR"in e?N(S(Ge),e.ADD_URI_SAFE_ATTR,et):Ge,ze="ADD_DATA_URI_TAGS"in e?N(S(Be),e.ADD_DATA_URI_TAGS,et):Be,Fe="FORBID_CONTENTS"in e?N({},e.FORBID_CONTENTS,et):He,Ee="FORBID_TAGS"in e?N({},e.FORBID_TAGS,et):{},Ae="FORBID_ATTR"in e?N({},e.FORBID_ATTR,et):{},Pe="USE_PROFILES"in e&&e.USE_PROFILES,_e=!1!==e.ALLOW_ARIA_ATTR,be=!1!==e.ALLOW_DATA_ATTR,Ne=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Re=e.SAFE_FOR_TEMPLATES||!1,we=e.WHOLE_DOCUMENT||!1,ve=e.RETURN_DOM||!1,xe=e.RETURN_DOM_FRAGMENT||!1,Ce=e.RETURN_TRUSTED_TYPE||!1,Le=e.FORCE_BODY||!1,ke=!1!==e.SANITIZE_DOM,Oe=e.SANITIZE_NAMED_PROPS||!1,Me=!1!==e.KEEP_CONTENT,Ue=e.IN_PLACE||!1,pe=e.ALLOWED_URI_REGEXP||W,Xe=e.NAMESPACE||qe,ye=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ot(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ye.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ot(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ye.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(ye.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Re&&(be=!1),xe&&(ve=!0),Pe&&(de=N({},[...k]),ge=[],!0===Pe.html&&(N(de,w),N(ge,O)),!0===Pe.svg&&(N(de,D),N(ge,I),N(ge,U)),!0===Pe.svgFilters&&(N(de,L),N(ge,I),N(ge,U)),!0===Pe.mathMl&&(N(de,x),N(ge,M),N(ge,U))),e.ADD_TAGS&&(de===he&&(de=S(de)),N(de,e.ADD_TAGS,et)),e.ADD_ATTR&&(ge===Te&&(ge=S(ge)),N(ge,e.ADD_ATTR,et)),e.ADD_URI_SAFE_ATTR&&N(We,e.ADD_URI_SAFE_ATTR,et),e.FORBID_CONTENTS&&(Fe===He&&(Fe=S(Fe)),N(Fe,e.FORBID_CONTENTS,et)),Me&&(de["#text"]=!0),we&&N(de,["html","head","body"]),de.table&&(N(de,["tbody"]),delete Ee.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');J=e.TRUSTED_TYPES_POLICY,Q=J.createHTML("")}else void 0===J&&(J=K(B,a)),null!==J&&"string"==typeof Q&&(Q=J.createHTML(""));i&&i(e),tt=e}},it=N({},["mi","mo","mn","ms","mtext"]),at=N({},["foreignobject","desc","title","annotation-xml"]),lt=N({},["title","style","font","a","script"]),ct=N({},D);N(ct,L),N(ct,v);const st=N({},x);N(st,C);const mt=function(e){let t=Z(e);t&&t.tagName||(t={namespaceURI:Xe,tagName:"template"});const n=p(e.tagName),o=p(t.tagName);return!!Ve[e.namespaceURI]&&(e.namespaceURI===je?t.namespaceURI===qe?"svg"===n:t.namespaceURI===Ye?"svg"===n&&("annotation-xml"===o||it[o]):Boolean(ct[n]):e.namespaceURI===Ye?t.namespaceURI===qe?"math"===n:t.namespaceURI===je?"math"===n&&at[o]:Boolean(st[n]):e.namespaceURI===qe?!(t.namespaceURI===je&&!at[o])&&(!(t.namespaceURI===Ye&&!it[o])&&(!st[n]&&(lt[n]||!ct[n]))):!("application/xhtml+xml"!==Ze||!Ve[e.namespaceURI]))},ut=function(e){f(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},ft=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!ge[e])if(ve||xe)try{ut(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},pt=function(e){let t,n;if(Le)e=""+e;else{const t=h(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Ze&&Xe===qe&&(e=''+e+"");const o=J?J.createHTML(e):e;if(Xe===qe)try{t=(new z).parseFromString(o,Ze)}catch(e){}if(!t||!t.documentElement){t=ee.createDocument(Xe,"template",null);try{t.documentElement.innerHTML=Ke?Q:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(l.createTextNode(n),r.childNodes[0]||null),Xe===qe?oe.call(t,we?"html":"body")[0]:we?t.documentElement:r},dt=function(e){return te.call(e.ownerDocument||e,e,P.SHOW_ELEMENT|P.SHOW_COMMENT|P.SHOW_TEXT,null,!1)},ht=function(e){return e instanceof H&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof F)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},gt=function(e){return"object"==typeof _?e instanceof _:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Tt=function(e,t,n){ie[e]&&m(ie[e],(e=>{e.call(o,t,n,tt)}))},yt=function(e){let t;if(Tt("beforeSanitizeElements",e,null),ht(e))return ut(e),!0;const n=et(e.nodeName);if(Tt("uponSanitizeElement",e,{tagName:n,allowedTags:de}),e.hasChildNodes()&&!gt(e.firstElementChild)&&(!gt(e.content)||!gt(e.content.firstElementChild))&&E(/<[/\w]/g,e.innerHTML)&&E(/<[/\w]/g,e.textContent))return ut(e),!0;if(!de[n]||Ee[n]){if(!Ee[n]&&At(n)){if(ye.tagNameCheck instanceof RegExp&&E(ye.tagNameCheck,n))return!1;if(ye.tagNameCheck instanceof Function&&ye.tagNameCheck(n))return!1}if(Me&&!Fe[n]){const t=Z(e)||e.parentNode,n=$(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o)t.insertBefore(Y(n[o],!0),V(e))}}return ut(e),!0}return e instanceof b&&!mt(e)?(ut(e),!0):"noscript"!==n&&"noembed"!==n||!E(/<\/no(script|embed)/i,e.innerHTML)?(Re&&3===e.nodeType&&(t=e.textContent,t=g(t,ae," "),t=g(t,le," "),t=g(t,ce," "),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),Tt("afterSanitizeElements",e,null),!1):(ut(e),!0)},Et=function(e,t,n){if(ke&&("id"===t||"name"===t)&&(n in l||n in nt))return!1;if(be&&!Ae[t]&&E(se,t));else if(_e&&E(me,t));else if(!ge[t]||Ae[t]){if(!(At(e)&&(ye.tagNameCheck instanceof RegExp&&E(ye.tagNameCheck,e)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(e))&&(ye.attributeNameCheck instanceof RegExp&&E(ye.attributeNameCheck,t)||ye.attributeNameCheck instanceof Function&&ye.attributeNameCheck(t))||"is"===t&&ye.allowCustomizedBuiltInElements&&(ye.tagNameCheck instanceof RegExp&&E(ye.tagNameCheck,n)||ye.tagNameCheck instanceof Function&&ye.tagNameCheck(n))))return!1}else if(We[t]);else if(E(pe,g(n,fe,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==T(n,"data:")||!ze[e]){if(Ne&&!E(ue,g(n,fe,"")));else if(n)return!1}else;return!0},At=function(e){return e.indexOf("-")>0},_t=function(e){let t,n,r,i;Tt("beforeSanitizeAttributes",e,null);const{attributes:a}=e;if(!a)return;const l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ge};for(i=a.length;i--;){t=a[i];const{name:c,namespaceURI:s}=t;if(n="value"===c?t.value:y(t.value),r=et(c),l.attrName=r,l.attrValue=n,l.keepAttr=!0,l.forceKeepAttr=void 0,Tt("uponSanitizeAttribute",e,l),n=l.attrValue,l.forceKeepAttr)continue;if(ft(c,e),!l.keepAttr)continue;if(!Se&&E(/\/>/i,n)){ft(c,e);continue}Re&&(n=g(n,ae," "),n=g(n,le," "),n=g(n,ce," "));const m=et(e.nodeName);if(Et(m,r,n)){if(!Oe||"id"!==r&&"name"!==r||(ft(c,e),n=Ie+n),J&&"object"==typeof B&&"function"==typeof B.getAttributeType)if(s);else switch(B.getAttributeType(m,r)){case"TrustedHTML":n=J.createHTML(n);break;case"TrustedScriptURL":n=J.createScriptURL(n)}try{s?e.setAttributeNS(s,c,n):e.setAttribute(c,n),u(o.removed)}catch(e){}}}Tt("afterSanitizeAttributes",e,null)},bt=function e(t){let n;const o=dt(t);for(Tt("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)Tt("uponSanitizeShadowNode",n,null),yt(n)||(n.content instanceof c&&e(n.content),_t(n));Tt("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t,n,i,a,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Ke=!e,Ke&&(e="\x3c!--\x3e"),"string"!=typeof e&&!gt(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!o.isSupported)return e;if(De||rt(l),o.removed=[],"string"==typeof e&&(Ue=!1),Ue){if(e.nodeName){const t=et(e.nodeName);if(!de[t]||Ee[t])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof _)t=pt("\x3c!----\x3e"),n=t.ownerDocument.importNode(e,!0),1===n.nodeType&&"BODY"===n.nodeName||"HTML"===n.nodeName?t=n:t.appendChild(n);else{if(!ve&&!Re&&!we&&-1===e.indexOf("<"))return J&&Ce?J.createHTML(e):e;if(t=pt(e),!t)return ve?null:Ce?Q:""}t&&Le&&ut(t.firstChild);const s=dt(Ue?e:t);for(;i=s.nextNode();)yt(i)||(i.content instanceof c&&bt(i.content),_t(i));if(Ue)return e;if(ve){if(xe)for(a=ne.call(t.ownerDocument);t.firstChild;)a.appendChild(t.firstChild);else a=t;return(ge.shadowroot||ge.shadowrootmod)&&(a=re.call(r,a,!0)),a}let m=we?t.outerHTML:t.innerHTML;return we&&de["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&E(j,t.ownerDocument.doctype.name)&&(m="\n"+m),Re&&(m=g(m,ae," "),m=g(m,le," "),m=g(m,ce," ")),J&&Ce?J.createHTML(m):m},o.setConfig=function(e){rt(e),De=!0},o.clearConfig=function(){tt=null,De=!1},o.isValidAttribute=function(e,t,n){tt||rt({});const o=et(e),r=et(t);return Et(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&(ie[e]=ie[e]||[],f(ie[e],t))},o.removeHook=function(e){if(ie[e])return u(ie[e])},o.removeHooks=function(e){ie[e]&&(ie[e]=[])},o.removeAllHooks=function(){ie={}},o}();return V})); +//# sourceMappingURL=purify.min.js.map diff --git a/manifest.json b/manifest.json index d24ef93..401ea66 100644 --- a/manifest.json +++ b/manifest.json @@ -754,5 +754,5 @@ "*://html.onlineviewer.net/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.1.7.1" + "version": "3.1.7.2" } diff --git a/options/optin/opt-in.html b/options/optin/opt-in.html index 4a5aa0a..fc857bf 100644 --- a/options/optin/opt-in.html +++ b/options/optin/opt-in.html @@ -4,7 +4,7 @@ - Bypass Paywalls Clean (setCookie/custom sites opt-in) + Bypass Paywalls Clean (setCookie, custom sites & check update opt-in) @@ -12,9 +12,18 @@
-

Bypass Paywalls Clean
- custom sites/check update opt-in

+

Bypass Paywalls Clean
- setCookie, custom sites & check update opt-in

+
+

setCookie opt-in

+

For some sites a necessary cookie has to be set (this cookie doesn't contain any personal information about the user or device):

+ CrusoƩ

+

setCookie opt-in enabled:

+
+ + +

custom sites opt-in

If you want to enable custom sites and also have the option to remove cookies/block general paywall-scripts of 'unlisted' sites:
@@ -33,6 +42,15 @@

+
+
+

daily users counter opt-in

+

Very basic daily users counter (by counting the download of an empty json-file (no personal information is shared)):
+

daily users counter enabled:

+
+ + +

diff --git a/options/optin/opt-in.js b/options/optin/opt-in.js index e91bca9..b618694 100644 --- a/options/optin/opt-in.js +++ b/options/optin/opt-in.js @@ -7,9 +7,34 @@ var custom_switch = ((manifestData.optional_permissions && manifestData.optional window.addEventListener("load", function () { document.getElementById("button-close").addEventListener("click", function () { + ext_api.storage.local.set({ + "optInShown": true, + "customShown": true + }); window.close(); }); + var opt_in_enabled = document.getElementById('opt-in-enabled'); + ext_api.storage.local.get("optIn", function (result) { + opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO'; + }); + + document.getElementById("optin-enable").addEventListener("click", function () { + ext_api.storage.local.set({ + "optIn": true, + "optInShown": true + }); + opt_in_enabled.innerText = 'YES'; + }); + + document.getElementById("optin-disable").addEventListener("click", function () { + ext_api.storage.local.set({ + "optIn": false, + "optInShown": true + }); + opt_in_enabled.innerText = 'NO'; + }); + var custom_enabled = document.getElementById('custom-enabled'); ext_api.permissions.contains({ origins: ["*://*/*"] @@ -35,6 +60,9 @@ window.addEventListener("load", function () { } else { custom_enabled.innerText = 'NO'; } + ext_api.storage.local.set({ + "customShown": true + }); }); }); @@ -48,6 +76,9 @@ window.addEventListener("load", function () { "customOptIn": false }); } + ext_api.storage.local.set({ + "customShown": true + }); }); }); @@ -71,4 +102,23 @@ window.addEventListener("load", function () { }); update_enabled.innerText = 'NO'; }); + + var counter_enabled = document.getElementById('counter-enabled'); + ext_api.storage.local.get({counter: true}, function (result) { + counter_enabled.innerText = result.counter ? 'YES' : 'NO'; + }); + + document.getElementById("counter-enable").addEventListener("click", function () { + ext_api.storage.local.set({ + "counter": true + }); + counter_enabled.innerText = 'YES'; + }); + + document.getElementById("counter-disable").addEventListener("click", function () { + ext_api.storage.local.set({ + "counter": false + }); + counter_enabled.innerText = 'NO'; + }); }); diff --git a/sites.js b/sites.js index 38b2ed8..0914cf9 100644 --- a/sites.js +++ b/sites.js @@ -270,7 +270,7 @@ var defaultSites = { allow_cookies: 1, block_regex: /(\.tinypass\.com\/|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ }, - "Business Post.ie": { + "Business Post.ie (link to archive.is)": { domain: "businesspost.ie", allow_cookies: 1, block_regex: /\.piano\.io\// @@ -2198,6 +2198,7 @@ var defaultSites = { "UOL.com.br": { domain: "uol.com.br", allow_cookies: 1, + block_js_inline: /crusoe\.uol\.com\.br\/(diario|edicoes)\/.+/, block_regex: /(paywall\.folha\.uol\.com\.br\/|\.(tinypass|matheranalytics)\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/, useragent: "googlebot" }, @@ -2512,6 +2513,7 @@ expandSiteRules(defaultSites); var au_news_corp_domains = grouped_sites['###_au_news_corp']; var de_madsack_domains = grouped_sites['###_de_madsack']; var es_grupo_vocento_domains = grouped_sites['###_es_grupo_vocento']; +var nl_mediahuis_noord_domains = grouped_sites['###_nl_mediahuis_noord']; var nl_mediahuis_region_domains = grouped_sites['###_nl_mediahuis_region']; var no_nhst_media_domains = grouped_sites['###_no_nhst_media'];