From befe5a06e9269069fd3ca60fc1844d1c005c9fe5 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Wed, 10 Aug 2022 19:19:32 +0200 Subject: [PATCH] Fix TheTimes.co.uk (epaper-fix obsolete) --- background.js | 5 ++--- changelog.txt | 1 + contentScript.js | 47 +++++++------------------------------------- custom/manifest.json | 2 +- manifest.json | 2 +- sites.js | 3 +-- sites_updated.json | 37 ++++------------------------------ 7 files changed, 17 insertions(+), 80 deletions(-) diff --git a/background.js b/background.js index 4612245..720c9d3 100755 --- a/background.js +++ b/background.js @@ -5,7 +5,7 @@ var manifestData = ext_api.runtime.getManifest(); var ext_name = manifestData.name; var ext_version = manifestData.version; -const cs_limit_except = ['elespanol.com', 'faz.net', 'nation.africa', 'nationalgeographic.com', 'thetimes.co.uk'].concat(de_westfalen_medien_domains); +const cs_limit_except = ['elespanol.com', 'faz.net', 'nation.africa', 'nationalgeographic.com'].concat(de_westfalen_medien_domains); const dompurify_sites = ['aachener-nachrichten.de', 'aachener-zeitung.de', 'asiatimes.com', 'bloomberg.com', 'cicero.de', 'golem.de', 'hs.fi', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lesechos.fr', 'limburger.nl', 'marianne.net', 'newleftreview.org', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'spiegel.de', 'stratfor.com', 'tagesspiegel.de', 'techinasia.com', 'thetimes.co.uk', 'timesofindia.com', 'vn.nl', 'welt.de', 'wiwo.de'].concat(be_mediahuis_domains, nl_mediahuis_region_domains, no_nhst_media_domains); var currentTabUrl = ''; var csDone = false; @@ -34,6 +34,7 @@ var restrictions = { 'statista.com': /^((?!\.statista\.com\/(outlook|study)\/).)*$/, 'techinasia.com': /\.techinasia\.com\/.+/, 'theatlantic.com': /^((?!\/newsletters\.theatlantic\.com\/).)*$/, + 'thetimes.co.uk': /^((?!epaper\.thetimes\.co\.uk).)*$/, 'timeshighereducation.com': /\.timeshighereducation\.com\/((features|news|people)\/|.+((\w)+(\-)+){3,}.+|sites\/default\/files\/)/ } @@ -969,7 +970,6 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { allow_ext_source = allow_ext_source || bpc_amp_site || (matchUrlDomain('elespanol.com', header_referer) && matchUrlDomain('eestatic.com', details.url)) || (matchUrlDomain('elmercurio.com', header_referer) && matchUrlDomain('emol.cl', details.url)) || - (matchUrlDomain('epaper.thetimes.co.uk', header_referer) && matchUrlDomain(['prcdn.co'], details.url)) || (matchUrlDomain('law360.com', header_referer) && matchUrlDomain('law360news.com', details.url)) || (matchUrlDomain('lesechos.fr', header_referer) && matchUrlDomain('lesechos.com', details.url)) || (matchUrlDomain('marketwatch.com', header_referer) && matchUrlDomain('wsj.net', details.url)) || @@ -1001,7 +1001,6 @@ if (matchUrlDomain(change_headers, details.url) && !['font', 'image', 'styleshee !(matchUrlDomain('barrons.com', details.url) && enabledSites.includes('#options_disable_gb_barrons')) && !(matchUrlDomain(['economictimes.com', 'economictimes.indiatimes.com'], details.url) && !details.url.split(/\?|#/)[0].endsWith('.cms')) && !(matchUrlDomain('theaustralian.com.au', details.url) && !details.url.startsWith('https://www.theaustralian.com.au/the-oz/')) && - !(matchUrlDomain('thetimes.co.uk', details.url) && !(details.url.match(/\/epaper\.thetimes\.co\.uk\/article\//) || mobile)) && !(matchUrlDomain('wsj.com', details.url) && enabledSites.includes('#options_disable_gb_wsj')); var bingbotEnabled = matchUrlDomain(use_bing_bot, details.url) && !(matchUrlDomain('stratfor.com', details.url) && details.url.match(/(\/(\d){4}-([a-z]||-)+-forecast(-([a-z]|-)+)?|-forecast-(\d){4}-([a-z]|[0-9]||-)+)$/)); diff --git a/changelog.txt b/changelog.txt index d569afe..41f7413 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Post-release Add Aachener Nachrichten & Zeitung Remove World Politics Review (fix obsolete) Fix Limburger.nl & Mediahuis Belgie (mobile) +Fix TheTimes.co.uk (epaper-fix obsolete) * v2.7.9.0 (2022-08-07) Add Limburger.nl diff --git a/contentScript.js b/contentScript.js index 48e6176..167713f 100755 --- a/contentScript.js +++ b/contentScript.js @@ -39,7 +39,7 @@ var usa_outside_mag_domains = ["backpacker.com", "betamtb.com", "betternutrition var usa_tribune_domains = ['baltimoresun.com', 'chicagotribune.com', 'courant.com', 'dailypress.com', 'mcall.com', 'nydailynews.com', 'orlandosentinel.com', 'pilotonline.com', 'sun-sentinel.com']; // clean local storage of sites (with an exemption for hold-list) -var arr_localstorage_hold = ['aachener-nachrichten.de', 'aachener-zeitung.de', 'abc.es', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.com', 'businessoffashion.com', 'challenges.fr', 'charliehebdo.fr', 'cmjornal.pt', 'corriere.it', 'corrieredellosport.it', 'eldiario.es', 'elespanol.com', 'elle.fr', 'elpais.com', 'elperiodico.com', 'enotes.com', 'estadao.com.br', 'forbes.com', 'fortune.com', 'economictimes.com', 'freiepresse.de', 'ilfoglio.it', 'inc42.com', 'lanouvellerepublique.fr', 'lesechos.fr', 'mid-day.com', 'nytimes.com', 'nzherald.co.nz', 'scmp.com', 'seekingalpha.com', 'substack.com', 'telegraph.co.uk', 'thehindu.com', 'thetimes.co.uk', 'wsj.com'].concat(de_funke_medien_domains, de_westfalen_medien_domains, es_epiberica_domains, es_grupo_vocento_domains, es_unidad_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, fr_groupe_nice_matin_domains, it_quotidiano_domains, ca_gcm_domains, nl_dpg_media_domains, no_nhst_media_domains, usa_hearst_comm_domains); +var arr_localstorage_hold = ['aachener-nachrichten.de', 'aachener-zeitung.de', 'abc.es', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.com', 'businessoffashion.com', 'challenges.fr', 'charliehebdo.fr', 'cmjornal.pt', 'corriere.it', 'corrieredellosport.it', 'eldiario.es', 'elespanol.com', 'elle.fr', 'elpais.com', 'elperiodico.com', 'enotes.com', 'estadao.com.br', 'forbes.com', 'fortune.com', 'economictimes.com', 'freiepresse.de', 'ilfoglio.it', 'inc42.com', 'lanouvellerepublique.fr', 'lesechos.fr', 'mid-day.com', 'nytimes.com', 'nzherald.co.nz', 'scmp.com', 'seekingalpha.com', 'substack.com', 'telegraph.co.uk', 'theatlantic.com', 'thehindu.com', 'thetimes.co.uk', 'wsj.com'].concat(de_funke_medien_domains, de_westfalen_medien_domains, es_epiberica_domains, es_grupo_vocento_domains, es_unidad_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, fr_groupe_nice_matin_domains, it_quotidiano_domains, ca_gcm_domains, nl_dpg_media_domains, no_nhst_media_domains, usa_hearst_comm_domains); if (!matchDomain(arr_localstorage_hold)) { window.localStorage.clear(); } @@ -65,9 +65,9 @@ if ((bg2csData !== undefined) && bg2csData.ld_json && dompurify_loaded) { let ld_json_split = bg2csData.ld_json.split('|'); let paywall_sel = ld_json_split[0]; let article_sel = ld_json_split[1]; - let paywall = document.querySelector(paywall_sel); - if (paywall) { - removeDOMElement(paywall); + let paywall = document.querySelectorAll(paywall_sel); + if (paywall.length) { + removeDOMElement(...paywall); let json_script = getArticleJsonScript(); if (json_script) { let json_text = parseHtmlEntities(JSON.parse(json_script.text).articleBody); @@ -92,9 +92,9 @@ if ((bg2csData !== undefined) && bg2csData.ld_google_webcache && dompurify_loade let ld_google_webcache_split = bg2csData.ld_google_webcache.split('|'); let paywall_sel = ld_google_webcache_split[0]; let article_sel = ld_google_webcache_split[1]; - let paywall = document.querySelector(paywall_sel); - if (paywall) { - removeDOMElement(paywall); + let paywall = document.querySelectorAll(paywall_sel); + if (paywall.length) { + removeDOMElement(...paywall); let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split('?')[0]; replaceDomElementExt(url_cache, true, false, article_sel); } @@ -2360,39 +2360,6 @@ else if (matchDomain('thetimes.co.uk')) { removeDOMElement(...banners, ...ads); }, 1500); } - } else { - if (url.includes('/textview')) { - let article_locks = document.querySelectorAll('article[aid] > div > div > a.readmore.dis[href="javascript:void(0)"]'); - for (let elem of article_locks) { - let article = elem.closest('article[aid]'); - if (article) - elem.href = 'article/' + article.getAttribute('aid'); - } - let headers = document.querySelectorAll('article[aid] > header > hgroup > h1'); - for (let elem of headers) { - let article = elem.closest('article[aid]'); - if (article && !elem.innerHTML.includes('')) { - let new_link = document.createElement('a'); - new_link.href = 'article/' + article.getAttribute('aid'); - new_link.innerText = elem.innerText; - elem.innerText = ''; - elem.appendChild(new_link); - } - } - let continued_links = document.querySelectorAll('a.continued[href="javascript:void(0)"]'); - for (let elem of continued_links) { - let pagenr = parseInt(elem.innerText.replace('Continued from ', '')); - if (pagenr) - elem.href = url.replace(/\/page\/(\d)+\/textview/, '/page/' + pagenr + '/textview'); - } - let bottom_links = document.querySelectorAll('article > a[id^="athumb_"][article-id][href="javascript:void(0)"]'); - for (let elem of bottom_links) - elem.href = 'article/' + elem.getAttribute('article-id'); - } else { - let pages = document.querySelectorAll('div.page-left, div.page-right'); - for (let page of pages) - page.style.height = 'auto'; - } } } diff --git a/custom/manifest.json b/custom/manifest.json index db4e17d..f88bb33 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -43,5 +43,5 @@ "webRequestBlocking", "" ], - "version": "2.7.9.1" + "version": "2.7.9.2" } diff --git a/manifest.json b/manifest.json index 106be9d..e19c2d2 100755 --- a/manifest.json +++ b/manifest.json @@ -692,5 +692,5 @@ "*://gcm.omerlocdn.com/*", "*://webcache.googleusercontent.com/*" ], - "version": "2.7.9.1" + "version": "2.7.9.2" } diff --git a/sites.js b/sites.js index 56c4e6b..6658a09 100755 --- a/sites.js +++ b/sites.js @@ -1864,8 +1864,7 @@ var defaultSites = { }, "The Times (UK)": { domain: "thetimes.co.uk", - allow_cookies: 1, - useragent: "googlebot" + allow_cookies: 1 }, "The Times Literary Supplement": { domain: "the-tls.co.uk", diff --git a/sites_updated.json b/sites_updated.json index 665041b..374fc23 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -1,38 +1,13 @@ { - "Belfast Telegraph (setCookie opt-in)": { - "domain": "belfasttelegraph.co.uk", - "allow_cookies": 1, - "block_regex": "(cdn\\.flip-pay\\.com\\/clients\\/inm\\/flip-pay\\.js)", - "cs_code": [{ - "cond": "div#flip-pay[style]", - "rm_attrib": "style" - } - ] - }, "Groene Amsterdammer": { "domain": "groene.nl", "remove_cookies_select_hold": ["accept-cookies", "popunder-hidden"], "useragent": "googlebot" }, - "Irish Independent (setCookie opt-in)": { - "domain": "independent.ie", - "allow_cookies": 1, - "block_regex": "(cdn\\.flip-pay\\.com\\/clients\\/inm\\/flip-pay\\.js)", - "cs_code": [{ - "cond": "div#flip-pay[style]", - "rm_attrib": "style" - } - ] - }, - "Law.com (free articles only)": { - "domain": "law.com", - "allow_cookies": 1, - "remove_cookies": 1, - "referer": "facebook" - }, "Substack": { "domain": "substack.com", - "useragent": "googlebot" + "useragent": "googlebot", + "new_site": 1 }, "Suomen Sotilas": { "domain": "suomensotilas.fi", @@ -42,7 +17,8 @@ "cond": "div.epfl-pw-obscured", "rm_class": "epfl-pw-obscured" } - ] + ], + "new_site": 1 }, "The Athletic": { "domain": "###_usa_theathletic", @@ -56,10 +32,5 @@ "rm_elem": 1 } ] - }, - "Winnipeg Free Press": { - "domain": "winnipegfreepress.com", - "allow_cookies": 1, - "block_regex": "(account\\.winnipegfreepress\\.com\\/api\\/v\\d\\/auth\\/identify|cdn\\.cxense\\.com\\/)" } }