Merge pull request #378 from magnolia1234/master

Add LeParisien.fr & fix Quora & Le Monde & NzHerald & Harper's Magazine default & fix default websites in options
This commit is contained in:
ghost 2019-11-10 15:07:04 -08:00 committed by GitHub
commit 3f1345b864
4 changed files with 41 additions and 18 deletions

View File

@ -54,6 +54,7 @@
[L'Écho](https://lecho.be)\
[Le Devoir](https://www.ledevoir.com)\
[Le Monde](https://www.lemonde.fr)\
[Le Parisien](http://www.leparisien.fr)\
[Les Échos](https://lesechos.fr)\
[Libération](https://liberation.fr)\
[Loeb Classical Library](https://www.loebclassics.com)\

View File

@ -42,6 +42,7 @@ var defaultSites = {
'L\'Echo': 'lecho.be',
'Le Devoir': 'ledevoir.com',
'Le Monde': 'lemonde.fr',
'Le Parisien': 'leparisien.fr',
'Les Echos': 'lesechos.fr',
'Liberation': 'liberation.fr',
'Loeb Classical Library': 'loebclassics.com',
@ -194,8 +195,10 @@ const remove_cookies_select_drop = {
// Override User-Agent with Googlebot
const use_google_bot = [
'barrons.com',
'lemonde.fr',
'mexiconewsdaily.com',
'nytimes.com',
'quora.com',
'telegraph.co.uk',
'theaustralian.com.au',
'thetimes.co.uk',

View File

@ -91,23 +91,21 @@ if (window.location.href.indexOf("the-american-interest.com") !== -1) {
}
if (window.location.href.indexOf("nzherald.co.nz") !== -1) {
const paywall = document.getElementById(
"article-content"
);
const paywall = document.getElementById('article-content');
if (paywall) {
paywall.classList.remove('premium-content');
paywall.classList.add('full-content');
var paras = paywall.querySelectorAll("p, span, h2, div");
var delClass = "";
for (var i = paras.length; i--;) {
if (delClass == "") {
delClass = paras[i].className;
const premium = document.getElementsByClassName('premium-sub')[0];
removeDOMElement(premium);
paywall.classList.remove('premium-content');
paywall.classList.add('full-content');
removeClassesByPrefix(paywall, 'QUnW');
var paras = paywall.querySelectorAll("p, span, h2, div");
for (var i = 0; i < paras.length; i++){
removeClassesByPrefix(paras[i], 'QUnW');
paras[i].classList.remove("ellipsis");
paras[i].removeAttribute('style');
}
paras[i].classList.remove(delClass);
paras[i].removeAttribute('style');
}
}
}
}
}
if (window.location.href.indexOf("parool.nl") !== -1 || window.location.href.indexOf("trouw.nl") !== -1 || window.location.href.indexOf("volkskrant.nl") !== -1) {
document.addEventListener('DOMContentLoaded', () => {
@ -195,6 +193,20 @@ if (window.location.href.indexOf("nytimes.com") !== -1) {
preview_button.click();
}
if (window.location.href.indexOf("leparisien.fr") !== -1) {
window.removeEventListener('scroll', this.scrollListener);
const paywall = document.querySelector('.relative.piano-paywall.below_nav.sticky');
removeDOMElement(paywall);
setTimeout(function () {
var content = document.getElementsByClassName('content');
for (var i = 0; i < content.length; i++) {
content[i].removeAttribute("style");
}
}, 300); // Delay (in milliseconds)
}
function removeDOMElement(...elements) {
for (let element of elements) {
if (element)
@ -202,9 +214,15 @@ function removeDOMElement(...elements) {
}
}
function removeClassesByPrefix(el, prefix) {
for (var i = 0; i < el.classList.length; i++){
if(el.classList[i].startsWith(prefix)) {
el.classList.remove(el.classList[i]);
}
}
function pageContains(selector, text) {
let elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function(element){
return RegExp(text).test(element.textContent);
});

View File

@ -27,7 +27,7 @@ var defaultSites = {
'Glassdoor': 'glassdoor.com',
'Haaretz': 'haaretz.co.il',
'Haaretz English': 'haaretz.com',
'Harper\'s Mag': 'harpers.org',
'Harper\'s Magazine': 'harpers.org',
'Hartford Courant': 'courant.com',
'Harvard Business Review': 'hbr.org',
'Inc.com': 'inc.com',
@ -37,6 +37,7 @@ var defaultSites = {
'L\'Echo': 'lecho.be',
'Le Devoir': 'ledevoir.com',
'Le Monde': 'lemonde.fr',
'Le Parisien': 'leparisien.fr',
'Les Echos': 'lesechos.fr',
'Liberation': 'liberation.fr',
'Loeb Classical Library': 'loebclassics.com',
@ -144,7 +145,7 @@ function renderOptions() {
inputEl.type = 'checkbox';
inputEl.dataset.key = key;
inputEl.dataset.value = value;
inputEl.checked = key in sites;
inputEl.checked = (key in sites) || (key.replace(/\s\(.*\)/, '') in sites);
labelEl.appendChild(inputEl);
labelEl.appendChild(document.createTextNode(' '+key));