Skip to content

Commit

Permalink
Ajout presse belge et The Economist (#209)
Browse files Browse the repository at this point in the history
* Ajout presse belge et The Economist

Le Vif, Trends Tendances, Knack, De Standaard, De Morgen

* ajout presse belge et The Economist

* Ajout presse belge + The Economist
  • Loading branch information
RmbxCh authored Feb 19, 2024
1 parent 0725c96 commit 36c94ae
Show file tree
Hide file tree
Showing 14 changed files with 345 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
5 changes: 5 additions & 0 deletions ophirofox/content_scripts/demorgen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.ophirofox-europresse {
display: block;
margin-top: 1rem;
text-align: center;
}
39 changes: 39 additions & 0 deletions ophirofox/content_scripts/demorgen.js
Original file line number Diff line number Diff line change
@@ -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);
8 changes: 8 additions & 0 deletions ophirofox/content_scripts/destandaard.css
Original file line number Diff line number Diff line change
@@ -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;
}
34 changes: 34 additions & 0 deletions ophirofox/content_scripts/destandaard.js
Original file line number Diff line number Diff line change
@@ -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);
9 changes: 9 additions & 0 deletions ophirofox/content_scripts/knack.css
Original file line number Diff line number Diff line change
@@ -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;
}
37 changes: 37 additions & 0 deletions ophirofox/content_scripts/knack.js
Original file line number Diff line number Diff line change
@@ -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);
9 changes: 9 additions & 0 deletions ophirofox/content_scripts/levif.css
Original file line number Diff line number Diff line change
@@ -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;
}
37 changes: 37 additions & 0 deletions ophirofox/content_scripts/levif.js
Original file line number Diff line number Diff line change
@@ -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);
10 changes: 10 additions & 0 deletions ophirofox/content_scripts/theeconomist.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.ophirofox-europresse{
display: inline-block;
margin-top: 1rem;
color: #e3120b;
text-decoration: none;
}

.ophirofox-europresse:hover{
text-decoration: underline;
}
32 changes: 32 additions & 0 deletions ophirofox/content_scripts/theeconomist.js
Original file line number Diff line number Diff line change
@@ -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);
10 changes: 10 additions & 0 deletions ophirofox/content_scripts/trendstendances.css
Original file line number Diff line number Diff line change
@@ -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;
}
37 changes: 37 additions & 0 deletions ophirofox/content_scripts/trendstendances.js
Original file line number Diff line number Diff line change
@@ -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);
72 changes: 72 additions & 0 deletions ophirofox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 36c94ae

Please sign in to comment.