Skip to content

Commit

Permalink
Fix bugs et style dans presse belge, UK et USA (#211)
Browse files Browse the repository at this point in the history
* Add files via upload

Fix : lien après h1 plutot que h2, parfois absent

* FIX: bouton ne s'affichait pas systématiquement

* Fix style : bouton plus facilement repérable
  • Loading branch information
RmbxCh authored Feb 23, 2024
1 parent 5790470 commit b48e6c3
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 76 deletions.
8 changes: 7 additions & 1 deletion ophirofox/content_scripts/demorgen.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.ophirofox-europresse {
display: block;
margin-top: 1rem;
width: 12vw;
margin: 1rem auto;
padding: 0.25rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000 !important;
text-align: center;
text-decoration: none;
}
1 change: 1 addition & 0 deletions ophirofox/content_scripts/demorgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function onLoad() {
const newClassState = mutation.target.classList.contains('js-tm-backdrop-active');
if(classState !== newClassState){
addEuropresseButton();
observer.disconnect();
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions ophirofox/content_scripts/destandaard.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.ophirofox-europresse {
display: block;
padding: 0.5rem;
background-color: #d90000 !important;
color: #fff !important;
display: inline-block;
margin-top: 1rem;
padding: 0.25rem 1rem;
border-radius: 0.3rem;
background-color: #ffc700 !important;
color: #000 !important;
text-align: center;
text-decoration: none !important;
}

.ophirofox-modal-link {
display: block;
margin-top: 0;
padding: 0.5rem;
border-radius: 0;
}
38 changes: 25 additions & 13 deletions ophirofox/content_scripts/destandaard.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
function extractKeywords() {
return document.querySelector("h1").textContent;
return document.querySelector("header h1").textContent;
}

let buttonAdded = false;

async function createLink() {
const subscriptionElem = document.querySelector('[data-current-screen="CtaAuthPaying"] form');
if (subscriptionElem && buttonAdded == false){
async function createLink(elt) {
if (elt && buttonAdded == false){
const a = await ophirofoxEuropresseLink(extractKeywords());
subscriptionElem.after(a);
elt.after(a);
}
}

async function onLoad() {
// Lien Europresse dans la modale au chargement de l'article
createLink();
// Lien Europresse dans le corps de l'article
const paywall = document.querySelector('[data-cj-root="subscription-wall"]');
const article_title = document.querySelector('header h1');

if(paywall){
createLink(article_title);
}

// Lien Europresse dans le corps de l'article, une fois la modale fermée
// Lien Europresse dans la modale, au chargement
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if(mutation.removedNodes.length > 0){
createLink();
buttonAdded = true;
if(mutation.type === 'childList'){
for(let node of mutation.addedNodes){
const paywall_modal = document.querySelector('.cj-root');
if(paywall_modal){
const subscriptionForm = document.querySelector('[data-current-screen="CtaAuthPaying"] form');
createLink(subscriptionForm);
buttonAdded = true;
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
observer.disconnect();
}
}
}
}
};

const htmlElement = document.querySelector('.cj-root');
const htmlElement = document.querySelector('body');
const observer = new MutationObserver(callback);
observer.observe(htmlElement, { childList: true});
observer.observe(htmlElement, { childList: true });
}

onLoad().catch(console.error);
7 changes: 4 additions & 3 deletions ophirofox/content_scripts/financialtimes.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.ophirofox-europresse {
display: inline-block;
margin-bottom: 1rem;
padding: 0.25rem 1rem;
border: 1px solid #fff;
color: #fff;
padding: 0.5rem 1.5rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000;
text-decoration: none;
}
15 changes: 13 additions & 2 deletions ophirofox/content_scripts/gazetvanantwerpen.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
.ophirofox-europresse {
display: inline-block;
margin-top: 1rem;
padding: 0.25rem 1rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000 !important;
text-align: center;
text-decoration: none;
}

.ophirofox-modal-link {
display: block;
margin-top: 0;
padding: 0.5rem;
border: 1px solid #d21d10;
text-align: center;
border-radius: 0;
}
38 changes: 25 additions & 13 deletions ophirofox/content_scripts/gazetvanantwerpen.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
function extractKeywords() {
return document.querySelector("h1").textContent;
return document.querySelector("header h1").textContent;
}

let buttonAdded = false;

async function createLink() {
const subscriptionElem = document.querySelector('[data-current-screen="StopEmailIdentification"] form');
if (subscriptionElem && buttonAdded == false){
async function createLink(elt) {
if (elt && buttonAdded == false){
const a = await ophirofoxEuropresseLink(extractKeywords());
subscriptionElem.after(a);
elt.after(a);
}
}

async function onLoad() {
// Lien Europresse dans la modale au chargement de l'article
createLink();
// Lien Europresse dans le corps de l'article
const paywall = document.querySelector('[data-cj-root="subscription-wall"]');
const article_title = document.querySelector('header h1');

if(paywall){
createLink(article_title);
}

// Lien Europresse dans le corps de l'article, une fois la modale fermée
// Lien Europresse dans la modale, au chargement
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if(mutation.removedNodes.length > 0){
createLink();
buttonAdded = true;
if(mutation.type === 'childList'){
for(let node of mutation.addedNodes){
const paywall_modal = document.querySelector('.cj-root');
if(paywall_modal){
const subscriptionForm = document.querySelector('[data-current-screen="StopEmailIdentification"] form');
createLink(subscriptionForm);
buttonAdded = true;
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
observer.disconnect();
}
}
}
}
};

const htmlElement = document.querySelector('.cj-root');
const htmlElement = document.querySelector('body');
const observer = new MutationObserver(callback);
observer.observe(htmlElement, { childList: true});
observer.observe(htmlElement, { childList: true });
}

onLoad().catch(console.error);
8 changes: 7 additions & 1 deletion ophirofox/content_scripts/hetlaatstenieuws.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.ophirofox-europresse {
display: block;
margin-top: 1rem;
width: 12vw;
margin: 1rem auto;
padding: 0.25rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000 !important;
text-align: center;
text-decoration: none !important;
}
1 change: 1 addition & 0 deletions ophirofox/content_scripts/hetlaatstenieuws.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function onLoad() {
const newClassState = mutation.target.classList.contains('js-tm-backdrop-active');
if(classState !== newClassState){
addEuropresseButton();
observer.disconnect();
}
}
}
Expand Down
15 changes: 13 additions & 2 deletions ophirofox/content_scripts/hetnieuwsblad.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
.ophirofox-europresse {
display: inline-block;
margin-top: 1rem;
padding: 0.25rem 1rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000 !important;
text-align: center;
text-decoration: none;
}

.ophirofox-modal-link {
display: block;
margin-top: 0;
padding: 0.5rem;
border: 1px solid #0071c7;
text-align: center;
border-radius: 0;
}
44 changes: 28 additions & 16 deletions ophirofox/content_scripts/hetnieuwsblad.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
function extractKeywords() {
return document.querySelector("h1").textContent;
return document.querySelector("header h1").textContent;
}

let buttonAdded = false;

async function createLink() {
const subscriptionElem = document.querySelector('[data-current-screen="StopEmailIdentification"] form');
if (subscriptionElem && buttonAdded == false){
async function createLink(elt) {
if (elt && buttonAdded == false){
const a = await ophirofoxEuropresseLink(extractKeywords());
subscriptionElem.after(a);
elt.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
async function onLoad() {
// Lien Europresse dans le corps de l'article
const paywall = document.querySelector('[data-cj-root="subscription-wall"]');
const article_title = document.querySelector('header h1');

if(paywall){
createLink(article_title);
}

// Lien Europresse dans la modale, au chargement
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if(mutation.removedNodes.length > 0){
createLink();
buttonAdded = true;
if(mutation.type === 'childList'){
for(let node of mutation.addedNodes){
const paywall_modal = document.querySelector('.cj-root');
if(paywall_modal){
const subscriptionForm = document.querySelector('[data-current-screen="StopEmailIdentification"] form');
createLink(subscriptionForm);
buttonAdded = true;
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
observer.disconnect();
}
}
}
}
};

const htmlElement = document.querySelector('.cj-root');
const htmlElement = document.querySelector('body');
const observer = new MutationObserver(callback);
observer.observe(htmlElement, { childList: true});
observer.observe(htmlElement, { childList: true });
}

onLoad().catch(console.error);
10 changes: 6 additions & 4 deletions ophirofox/content_scripts/knack.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.ophirofox-europresse {
display: inline-block;
margin-top: 1rem;
padding: 0.5rem 1rem;
border: 1px solid #ee1c24;
color: #ee1c24;
padding: 0.5rem 1.5rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000;
font-family: "Aeonik","Publica Slab","Helvetica","Arial",sans-serif;
font-size: 1.5rem;
font-weight: bold;
text-decoration: none;
}
10 changes: 6 additions & 4 deletions ophirofox/content_scripts/levif.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.ophirofox-europresse {
display: inline-block;
margin-top: 1rem;
padding: 0.5rem 1rem;
border: 1px solid #ee1c24;
color: #ee1c24;
padding: 0.5rem 1.5rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000;
font-family: "Aeonik","Publica Slab","Helvetica","Arial",sans-serif;
font-size: 1.5rem;
font-weight: bold;
text-decoration: none;
}
9 changes: 4 additions & 5 deletions ophirofox/content_scripts/theeconomist.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.ophirofox-europresse{
display: inline-block;
margin-top: 1rem;
color: #e3120b;
padding: 0.25rem 1rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000;
text-decoration: none;
}

.ophirofox-europresse:hover{
text-decoration: underline;
}
5 changes: 3 additions & 2 deletions ophirofox/content_scripts/theeconomist.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ async function onLoad() {
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');
const subtitle = document.querySelector('#new-article-template h1');
createLink().then(function(data){
subtitle.after(data);
});
observer.disconnect();
}
}
}
Expand All @@ -26,7 +27,7 @@ async function onLoad() {

const htmlElement = document.querySelector('#new-article-template');
const observer = new MutationObserver(callback);
observer.observe(htmlElement, { childList: true, subtree: true});
observer.observe(htmlElement, { childList: true, subtree: true });
}

onLoad().catch(console.error);
9 changes: 5 additions & 4 deletions ophirofox/content_scripts/trendstendances.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.ophirofox-europresse {
display: inline-block;
margin-top: 1rem;
padding: 0.5rem 1rem;
border: 1px solid #5cb4ab;
color: #5cb4ab;
padding: 0.5rem 1.5rem;
border-radius: 0.3rem;
background-color: #ffc700;
color: #000;
font-family: "Aeonik","Publica Slab","Helvetica","Arial",sans-serif;
font-size: 1.5rem;
font-weight: bold;
text-decoration: none;
}
Loading

0 comments on commit b48e6c3

Please sign in to comment.