Fix-update Helsingin Sanomat (Finland)

This commit is contained in:
magnolia1234 2021-01-22 15:05:44 +01:00
parent 58b9164fa8
commit 44a5153435
3 changed files with 1 additions and 88 deletions

View file

@ -21,7 +21,6 @@ const restrictions = {
'foreignaffairs.com': /.+\.foreignaffairs\.com\/(articles|fa-caching|interviews|reviews|sites)\/.+/,
'ft.com': /.+\.ft.com\/content\//,
'gestion.pe': /.+\/gestion\.pe\/.+((\w)+(\-)+){3,}.+/,
'hs.fi': /^((?!\/.+\.hs\.fi\/paivanlehti\/).)*$/,
'globo.com': /^((?!\/valor\.globo\.com\/).)*$/,
'quora.com': /^((?!quora\.com\/search\?q=).)*$/,
'seekingalpha.com': /.+\/seekingalpha\.com\/($|(amp\/)?(article|news)\/|samw\/)/,

View file

@ -9,6 +9,7 @@ Add Prospect Magazine (United Kingdom)
Add Ruhr Nachrichten (Germany)
Add The Point Magazine
Fix-update El Pais (Spain)
Fix-update Helsingin Sanomat (Finland)
Fix-update MIT Sloan Management Review
Update block TinyPass (all subdomains)
Update excluded sites (no general block paywall scripts)

View file

@ -1645,93 +1645,6 @@ else if (matchDomain("alternatives-economiques.fr")) {
}, 500); // Delay (in milliseconds)
}
else if (matchDomain("hs.fi")) {
let url = window.location.href;
if (!url.includes('https://dynamic.hs.fi')) {
let iframe = document.querySelector('iframe[src^="https://dynamic.hs.fi/a/"]');
if (iframe && url.includes('.html')) {
window.setTimeout(function () {
window.location.href = iframe.src;
}, 500); // Delay (in milliseconds)
}
csDone = true;
} else {
let paywall = document.querySelector('.paywall-container');
if (paywall) {
let scripts = document.querySelectorAll('script');
let json_script;
for (let script of scripts) {
if (script.innerText.includes('window.__NUXT__='))
json_script = script;
continue;
}
let json_text = json_script.innerHTML.replace(/\r\n/g, '').split('amlData:[')[1].split('metaData')[0].split('paywallComponents:[')[1].slice(0, -4);
let main = document.querySelector('main');
if (main) {
let pars = json_text.split('{type:');
let type, value, slides, src, elem, img, caption, caption_text, par_html, par_text;
let parser = new DOMParser();
for (let par of pars) {
type = par.split(',')[0];
if (type === 'i') { // text
value = par.split('value:')[1].split('}')[0];
par_html = parser.parseFromString('<p>' + value + '</p>', 'text/html');
elem = par_html.querySelector('p');
elem.setAttribute('class', 'article-body px-16 mb-24');
main.appendChild(elem);
} else if (type === 'j') { // quote
value = par.split('text:')[1].split(',position:')[0];
par_html = parser.parseFromString('<p>' + value + '</p>', 'text/html');
elem = par_html.querySelector('p');
elem.setAttribute('class', 'article-body px-16 mb-24');
elem.setAttribute('style', 'font-style: italic;');
main.appendChild(elem);
} else if (type === 'h') { // image
src = par.split('src:"')[1].split('",')[0];
elem = document.createElement('p');
elem.setAttribute('class', 'article-body px-16 mb-24');
img = document.createElement('img');
img.setAttribute('src', 'https://arkku.mediadelivery.fi/img/468/' + src);
img.setAttribute('style', 'width:468px !important');
elem.appendChild(img);
caption = document.createElement('figcaption');
caption_text = par.split('caption:')[1].split(',credits:')[0];
if (caption_text.length)
caption_text = caption_text.slice(1, caption_text.length - 1);
caption.innerText = caption_text;
elem.appendChild(caption);
main.appendChild(elem);
} else if (type === 'r') { // slides
slides = par.split('src:');
for (let slide of slides) {
if (slide.includes('.jpg')) {
src = slide.split(',')[0].replace(/"/g, '');
elem = document.createElement('p');
elem.setAttribute('class', 'article-body px-16 mb-24');
img = document.createElement('img');
img.setAttribute('src', 'https://arkku.mediadelivery.fi/img/468/' + src);
img.setAttribute('style', 'width:468px !important');
elem.appendChild(img);
caption = document.createElement('figcaption');
caption_text = slide.split('text:')[1].split(',"text-style"')[0];
if (caption_text.length)
caption_text = caption_text.slice(1, caption_text.length - 1);
caption.innerText = caption_text;
elem.appendChild(caption);
main.appendChild(elem);
}
}
} else
false; //console.log('type: ' + type + ' par: ' + par);
}
main.appendChild(document.createElement('br'));
}
removeDOMElement(paywall);
csDone = true;
}
}
}
else if (matchDomain("latercera.com")) {
let subscr_banner = document.querySelector('.empty');
removeDOMElement(subscr_banner);