From fdf269880c29b5b9f00d520a010410af90a07165 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 1 Nov 2020 12:03:16 +0100 Subject: [PATCH] Fix-update Sueddeutsche Zeitung (+ magazine) --- background.js | 6 ++++-- changelog.txt | 1 + contentScript.js | 22 +++++++++++++++++++--- manifest.json | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/background.js b/background.js index 4707a76..24b8246 100644 --- a/background.js +++ b/background.js @@ -80,6 +80,7 @@ var allow_cookies = [ 'slader.com', 'startribune.com', 'stocknews.com', + 'sueddeutsche.de', 'techinasia.com', 'the-american-interest.com', 'thehindu.com', @@ -638,7 +639,8 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { let bloomberg_site = (matchUrlDomain('assets.bwbx.io', details.url) && matchUrlDomain('bloomberg.com', header_referer) && isSiteEnabled({url: header_referer})); let au_nc_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain(au_news_corp_domains, header_referer) && isSiteEnabled({url: header_referer})); let au_swm_site = (header_referer && urlHost(header_referer).endsWith('com.au') && details.url.includes('https://s.thewest.com.au/')); - if (!isSiteEnabled(details) && !(inkl_site) && !(bloomberg_site) && !(au_nc_amp_site) && !(au_swm_site)) { + let sz_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain('sueddeutsche.de', header_referer) && isSiteEnabled({url: header_referer})); + if (!isSiteEnabled(details) && !inkl_site && !bloomberg_site && !au_nc_amp_site && !au_swm_site && !sz_amp_site) { return; } @@ -712,7 +714,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { if (tabId !== -1) { ext_api.tabs.get(tabId, function (currentTab) { - if (isSiteEnabled(currentTab) || medium_custom_domain || au_swm_site) { + if (isSiteEnabled(currentTab) || medium_custom_domain || au_swm_site || sz_amp_site) { ext_api.tabs.executeScript(tabId, { file: 'contentScript.js', runAt: 'document_start' diff --git a/changelog.txt b/changelog.txt index c602439..a625fe2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Post-release Add Deutsche Wirtschafts Nachrichten Add WirtschaftsWoche (Germany) Fix-update Quartz (newsletter) +Fix-update Sueddeutsche Zeitung (+ magazine) Icon for dark/incognito mode (Chrome) Save options to storage.local (quota exceeded) diff --git a/contentScript.js b/contentScript.js index 630219c..43ef05c 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1087,12 +1087,28 @@ else if (matchDomain("irishtimes.com")) { } else if (matchDomain("sueddeutsche.de")) { + let url = window.location.href; document.addEventListener('DOMContentLoaded', () => { - let reduced_par = document.querySelector('div.sz-article-body__paragraph--reduced'); - let url = window.location.href; - if (url.includes('reduced=true') || reduced_par) + let offer_page = document.querySelector('div.offer-page'); + if (url.startsWith('https://www.sueddeutsche.de') && (url.includes('reduced=true') || offer_page)) window.location.href = url.split('?')[0].replace('www.', 'amphtml.'); + else if (url.startsWith('https://sz-magazin.sueddeutsche.de')) { + if (url.includes('reduced=true') || offer_page) + window.location.href = new URL(url).pathname + '!amp'; + } }); + window.setTimeout(function () { + if (url.includes('!amp')) { + let paragraph_reduced = document.querySelector('.paragraph--reduced'); + if (paragraph_reduced) + paragraph_reduced.classList.remove('paragraph--reduced'); + let paragraph_hidden = document.querySelectorAll('.paragraph--hidden'); + for (let par_hidden of paragraph_hidden) + par_hidden.classList.remove('paragraph--hidden'); + let amp_offerpage = document.querySelector('.amp-offerpage'); + removeDOMElement(amp_offerpage); + } + }, 500); // Delay (in milliseconds) } else if (matchDomain("charliehebdo.fr")) { diff --git a/manifest.json b/manifest.json index 1e2170c..e02809f 100644 --- a/manifest.json +++ b/manifest.json @@ -338,5 +338,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.9.2.4" + "version": "1.9.2.5" } \ No newline at end of file