From b3eb1ba79c4bbc93cf2328f091906c04cc7a2bf4 Mon Sep 17 00:00:00 2001 From: Charlotte Rambeaux <92538181+RmbxCh@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:36:35 +0100 Subject: [PATCH 1/3] Ajout presse belge et The Economist Le Vif, Trends Tendances, Knack, De Standaard, De Morgen --- ophirofox/content_scripts/demorgen.css | 5 +++ ophirofox/content_scripts/demorgen.js | 39 +++++++++++++++++++ ophirofox/content_scripts/destandaard.css | 8 ++++ ophirofox/content_scripts/destandaard.js | 34 ++++++++++++++++ ophirofox/content_scripts/knack.css | 9 +++++ ophirofox/content_scripts/knack.js | 37 ++++++++++++++++++ ophirofox/content_scripts/levif.css | 9 +++++ ophirofox/content_scripts/levif.js | 37 ++++++++++++++++++ ophirofox/content_scripts/theeconomist.css | 10 +++++ ophirofox/content_scripts/theeconomist.js | 32 +++++++++++++++ ophirofox/content_scripts/trendstendances.css | 10 +++++ ophirofox/content_scripts/trendstendances.js | 37 ++++++++++++++++++ 12 files changed, 267 insertions(+) create mode 100644 ophirofox/content_scripts/demorgen.css create mode 100644 ophirofox/content_scripts/demorgen.js create mode 100644 ophirofox/content_scripts/destandaard.css create mode 100644 ophirofox/content_scripts/destandaard.js create mode 100644 ophirofox/content_scripts/knack.css create mode 100644 ophirofox/content_scripts/knack.js create mode 100644 ophirofox/content_scripts/levif.css create mode 100644 ophirofox/content_scripts/levif.js create mode 100644 ophirofox/content_scripts/theeconomist.css create mode 100644 ophirofox/content_scripts/theeconomist.js create mode 100644 ophirofox/content_scripts/trendstendances.css create mode 100644 ophirofox/content_scripts/trendstendances.js diff --git a/ophirofox/content_scripts/demorgen.css b/ophirofox/content_scripts/demorgen.css new file mode 100644 index 0000000..fb7772a --- /dev/null +++ b/ophirofox/content_scripts/demorgen.css @@ -0,0 +1,5 @@ +.ophirofox-europresse { + display: block; + margin-top: 1rem; + text-align: center; +} \ No newline at end of file diff --git a/ophirofox/content_scripts/demorgen.js b/ophirofox/content_scripts/demorgen.js new file mode 100644 index 0000000..93d3513 --- /dev/null +++ b/ophirofox/content_scripts/demorgen.js @@ -0,0 +1,39 @@ +function extractKeywords() { + const titleElem = document.querySelector("h1").childNodes[0]; + return titleElem && titleElem.textContent; +} + +let buttonAdded = false; + +async function addEuropresseButton() { + if(!buttonAdded) { + const elts = document.querySelectorAll('.tm-account'); + if (elts) { + for(let elt of elts){ + const a = await ophirofoxEuropresseLink(extractKeywords()); + elt.after(a); + buttonAdded = true; + } + } + } +} + +async function onLoad() { + const callback = (mutationList, observer) => { + for (const mutation of mutationList) { + if(mutation.type === 'attributes' && mutation.attributeName === 'class'){ + const newClassState = mutation.target.classList.contains('js-tm-backdrop-active'); + if(classState !== newClassState){ + addEuropresseButton(); + } + } + } + }; + + const htmlElement = document.querySelector('body'); + const classState = htmlElement.classList.contains('js-tm-backdrop-active'); + const observer = new MutationObserver(callback); + observer.observe(htmlElement, { attributes: true, subtree: true }); +} + +onLoad().catch(console.error); \ No newline at end of file diff --git a/ophirofox/content_scripts/destandaard.css b/ophirofox/content_scripts/destandaard.css new file mode 100644 index 0000000..4bf0956 --- /dev/null +++ b/ophirofox/content_scripts/destandaard.css @@ -0,0 +1,8 @@ +.ophirofox-europresse { + display: block; + padding: 0.5rem; + background-color: #d90000 !important; + color: #fff !important; + text-align: center; + text-decoration: none !important; +} \ No newline at end of file diff --git a/ophirofox/content_scripts/destandaard.js b/ophirofox/content_scripts/destandaard.js new file mode 100644 index 0000000..b578729 --- /dev/null +++ b/ophirofox/content_scripts/destandaard.js @@ -0,0 +1,34 @@ +function extractKeywords() { + return document.querySelector("h1").textContent; +} + +let buttonAdded = false; + +async function createLink() { + const subscriptionElem = document.querySelector('[data-current-screen="CtaAuthPaying"] form'); + if (subscriptionElem && buttonAdded == false){ + const a = await ophirofoxEuropresseLink(extractKeywords()); + subscriptionElem.after(a); + } +} + +async function onLoad() { + // Lien Europresse dans la modale au chargement de l'article + createLink(); + + // Lien Europresse dans le corps de l'article, une fois la modale fermée + const callback = (mutationList, observer) => { + for (const mutation of mutationList) { + if(mutation.removedNodes.length > 0){ + createLink(); + buttonAdded = true; + } + } + }; + + const htmlElement = document.querySelector('.cj-root'); + const observer = new MutationObserver(callback); + observer.observe(htmlElement, { childList: true}); +} + +onLoad().catch(console.error); \ No newline at end of file diff --git a/ophirofox/content_scripts/knack.css b/ophirofox/content_scripts/knack.css new file mode 100644 index 0000000..d61b085 --- /dev/null +++ b/ophirofox/content_scripts/knack.css @@ -0,0 +1,9 @@ +.ophirofox-europresse { + display: inline-block; + margin-top: 1rem; + padding: 0.5rem 1rem; + border: 1px solid #ee1c24; + color: #ee1c24; + font-size: 1.5rem; + font-weight: bold; +} \ No newline at end of file diff --git a/ophirofox/content_scripts/knack.js b/ophirofox/content_scripts/knack.js new file mode 100644 index 0000000..c9e6cee --- /dev/null +++ b/ophirofox/content_scripts/knack.js @@ -0,0 +1,37 @@ +function extractKeywords() { + const titleElem = document.querySelector("h1").childNodes[0]; + return titleElem && titleElem.textContent; +} + +let buttonAdded = false; + +async function addEuropresseButton() { + if(!buttonAdded) { + const elt = document.querySelector('.datawall-wrapper .register'); + if (elt) { + const a = await ophirofoxEuropresseLink(extractKeywords()); + elt.after(a); + buttonAdded = true; + } + } +} + +async function onLoad() { + const callback = (mutationList, observer) => { + for (const mutation of mutationList) { + if(mutation.type === 'attributes' && mutation.attributeName === 'class'){ + const newClassState = mutation.target.classList.contains('is-hidden'); + if(classState !== newClassState){ + addEuropresseButton(); + } + } + } + }; + + const htmlElement = document.querySelector('#paywall-modal'); + const classState = htmlElement.classList.contains('is-hidden'); + const observer = new MutationObserver(callback); + observer.observe(htmlElement, { attributes: true, subtree: true }); +} + +onLoad().catch(console.error); \ No newline at end of file diff --git a/ophirofox/content_scripts/levif.css b/ophirofox/content_scripts/levif.css new file mode 100644 index 0000000..d61b085 --- /dev/null +++ b/ophirofox/content_scripts/levif.css @@ -0,0 +1,9 @@ +.ophirofox-europresse { + display: inline-block; + margin-top: 1rem; + padding: 0.5rem 1rem; + border: 1px solid #ee1c24; + color: #ee1c24; + font-size: 1.5rem; + font-weight: bold; +} \ No newline at end of file diff --git a/ophirofox/content_scripts/levif.js b/ophirofox/content_scripts/levif.js new file mode 100644 index 0000000..c9e6cee --- /dev/null +++ b/ophirofox/content_scripts/levif.js @@ -0,0 +1,37 @@ +function extractKeywords() { + const titleElem = document.querySelector("h1").childNodes[0]; + return titleElem && titleElem.textContent; +} + +let buttonAdded = false; + +async function addEuropresseButton() { + if(!buttonAdded) { + const elt = document.querySelector('.datawall-wrapper .register'); + if (elt) { + const a = await ophirofoxEuropresseLink(extractKeywords()); + elt.after(a); + buttonAdded = true; + } + } +} + +async function onLoad() { + const callback = (mutationList, observer) => { + for (const mutation of mutationList) { + if(mutation.type === 'attributes' && mutation.attributeName === 'class'){ + const newClassState = mutation.target.classList.contains('is-hidden'); + if(classState !== newClassState){ + addEuropresseButton(); + } + } + } + }; + + const htmlElement = document.querySelector('#paywall-modal'); + const classState = htmlElement.classList.contains('is-hidden'); + const observer = new MutationObserver(callback); + observer.observe(htmlElement, { attributes: true, subtree: true }); +} + +onLoad().catch(console.error); \ No newline at end of file diff --git a/ophirofox/content_scripts/theeconomist.css b/ophirofox/content_scripts/theeconomist.css new file mode 100644 index 0000000..a789340 --- /dev/null +++ b/ophirofox/content_scripts/theeconomist.css @@ -0,0 +1,10 @@ +.ophirofox-europresse{ + display: inline-block; + margin-top: 1rem; + color: #e3120b; + text-decoration: none; +} + +.ophirofox-europresse:hover{ + text-decoration: underline; +} \ No newline at end of file diff --git a/ophirofox/content_scripts/theeconomist.js b/ophirofox/content_scripts/theeconomist.js new file mode 100644 index 0000000..ca28a8f --- /dev/null +++ b/ophirofox/content_scripts/theeconomist.js @@ -0,0 +1,32 @@ +function extractKeywords() { + return document.querySelector("h1").textContent; +} + +async function createLink() { + const a = await ophirofoxEuropresseLink(extractKeywords()); + return a; +} + +async function onLoad() { + const callback = (mutationsList, observer) => { + for (const mutation of mutationsList) { + if(mutation.type === 'childList'){ + for(let node of mutation.addedNodes){ + const subscriptionElem = document.querySelector('section[data-body-id*="cp"]'); + if(node === subscriptionElem){ + const subtitle = document.querySelector('#new-article-template h2'); + createLink().then(function(data){ + subtitle.after(data); + }); + } + } + } + } + }; + + const htmlElement = document.querySelector('#new-article-template'); + const observer = new MutationObserver(callback); + observer.observe(htmlElement, { childList: true, subtree: true}); +} + +onLoad().catch(console.error); \ No newline at end of file diff --git a/ophirofox/content_scripts/trendstendances.css b/ophirofox/content_scripts/trendstendances.css new file mode 100644 index 0000000..5db00f2 --- /dev/null +++ b/ophirofox/content_scripts/trendstendances.css @@ -0,0 +1,10 @@ +.ophirofox-europresse { + display: inline-block; + margin-top: 1rem; + padding: 0.5rem 1rem; + border: 1px solid #5cb4ab; + color: #5cb4ab; + font-size: 1.5rem; + font-weight: bold; + text-decoration: none; +} \ No newline at end of file diff --git a/ophirofox/content_scripts/trendstendances.js b/ophirofox/content_scripts/trendstendances.js new file mode 100644 index 0000000..d455c45 --- /dev/null +++ b/ophirofox/content_scripts/trendstendances.js @@ -0,0 +1,37 @@ +function extractKeywords() { + const titleElem = document.querySelector("h1").childNodes[0]; + return titleElem && titleElem.textContent; +} + +let buttonAdded = false; + +async function addEuropresseButton() { + if(!buttonAdded) { + const elt = document.querySelector('.datawall-wrapper .login'); + if (elt) { + const a = await ophirofoxEuropresseLink(extractKeywords()); + elt.after(a); + buttonAdded = true; + } + } +} + +async function onLoad() { + const callback = (mutationList, observer) => { + for (const mutation of mutationList) { + if(mutation.type === 'attributes' && mutation.attributeName === 'class'){ + const newClassState = mutation.target.classList.contains('is-hidden'); + if(classState !== newClassState){ + addEuropresseButton(); + } + } + } + }; + + const htmlElement = document.querySelector('#paywall-modal'); + const classState = htmlElement.classList.contains('is-hidden'); + const observer = new MutationObserver(callback); + observer.observe(htmlElement, { attributes: true, subtree: true }); +} + +onLoad().catch(console.error); \ No newline at end of file From a00e844264622077809dc088f4c9229f15e65bb7 Mon Sep 17 00:00:00 2001 From: Charlotte Rambeaux <92538181+RmbxCh@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:42:26 +0100 Subject: [PATCH 2/3] ajout presse belge et The Economist --- ophirofox/manifest.json | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/ophirofox/manifest.json b/ophirofox/manifest.json index 26ca02a..8904216 100644 --- a/ophirofox/manifest.json +++ b/ophirofox/manifest.json @@ -501,6 +501,78 @@ "css": [ "content_scripts/le-progres.css" ] + }, + { + "matches": [ + "https://www.levif.be/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/levif.js" + ], + "css": [ + "content_scripts/levif.css" + ] + }, + { + "matches": [ + "https://trends.levif.be/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/trendstendances.js" + ], + "css": [ + "content_scripts/trendstendances.css" + ] + }, + { + "matches": [ + "https://www.knack.be/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/knack.js" + ], + "css": [ + "content_scripts/knack.css" + ] + }, + { + "matches": [ + "https://www.demorgen.be/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/demorgen.js" + ], + "css": [ + "content_scripts/demorgen.css" + ] + }, + { + "matches": [ + "https://www.standaard.be/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/destandaard.js" + ], + "css": [ + "content_scripts/destandaard.css" + ] + }, + { + "matches": [ + "https://www.economist.com/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/theeconomist.js" + ], + "css": [ + "content_scripts/theeconomist.css" + ] } ], "browser_specific_settings": { From 6a0ff9448c790ccc3120dade8881f209f8c9279c Mon Sep 17 00:00:00 2001 From: Charlotte Rambeaux <92538181+RmbxCh@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:54:07 +0100 Subject: [PATCH 3/3] Ajout presse belge + The Economist --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 0f2bba3..4c72ea6 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,19 @@ Voici la liste triée par ordre alphabétique : ### Presse étrangère - [Courrier international](https://www.courrierinternational.com) + - [De Morgen (Belgique - néerlandophone)](https://www.demorgen.be/) + - [De Standaard (Belgique - néerlandophone)](https://www.standaard.be/) + - [Knack (Belgique - néerlandophone)](https://www.knack.be/) - [L'Avenir (Belgique)](https://www.lavenir.net/) - [L'Orient-Le Jour (Liban)](https://www.lorientlejour.com/) - [La DH (Belgique)](https://www.dhnet.be/) - [La Libre Belgique](https://www.lalibre.be/) - [Le Soir (Belgique)](https://www.lesoir.be) - [Le Temps (Suisse)](https://www.letemps.ch/) + - [Le Vif (Belgique)](https://www.levif.be/) - [Sudinfo (Belgique)](https://www.sudinfo.be/) + - [The Economist (Royaume-Uni)](https://www.economist.com/) + - [Trends-Tendances (Belgique)](https://trends.levif.be/) Vous pouvez proposer d'autres sites Web de médias en ouvrant une [demande ici-même](https://github.com/lovasoa/ophirofox/issues).