Skip to content

Commit

Permalink
Adaptation nouveau paywall GVA, HNB, De Standaard (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
RmbxCh authored May 31, 2024
1 parent cdc5002 commit e085875
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 74 deletions.
7 changes: 0 additions & 7 deletions ophirofox/content_scripts/destandaard.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@
color: #000 !important;
text-align: center;
text-decoration: none !important;
}

.ophirofox-modal-link {
display: block;
margin-top: 0;
padding: 0.5rem;
border-radius: 0;
}
41 changes: 24 additions & 17 deletions ophirofox/content_scripts/destandaard.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
let buttonAdded = false;
const article_title = document.querySelector('header[data-testid="article-header"] h1');

function extractKeywords() {
return document.querySelector("header h1").textContent;
return article_title.textContent;
}

let buttonAdded = false;

async function createLink(elt) {
if (elt && buttonAdded == false){
const a = await ophirofoxEuropresseLink(extractKeywords());
elt.after(a);
console.log(elt);
if(elt !== article_title){
//second link is in shadow dom context -> no access to stylesheet
a.style.display = "block"
a.style.width = "35%";
a.style.margin = "0.5rem auto";
a.style.padding = "0.5rem 0";
a.style.borderRadius = "0.3rem";
a.style.backgroundColor = "#ffc700";
a.style.color = "#000";
a.style.textDecoration = "none";
a.style.textAlign = "center";
}
}
}

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.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);
const paywall_modal = document.querySelector('.PSAPAG_root');
if(paywall_modal){;
const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot;
const modal_content = shadow_content.firstChild.lastChild;
createLink(article_title);
createLink(modal_content);

buttonAdded = true;
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
observer.disconnect();
}
}
Expand Down
7 changes: 0 additions & 7 deletions ophirofox/content_scripts/gazetvanantwerpen.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@
color: #000 !important;
text-align: center;
text-decoration: none;
}

.ophirofox-modal-link {
display: block;
margin-top: 0;
padding: 0.5rem;
border-radius: 0;
}
41 changes: 24 additions & 17 deletions ophirofox/content_scripts/gazetvanantwerpen.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
let buttonAdded = false;
const article_title = document.querySelector('header[data-testid="article-header"] h1');

function extractKeywords() {
return document.querySelector("header h1").textContent;
return article_title.textContent;
}

let buttonAdded = false;

async function createLink(elt) {
if (elt && buttonAdded == false){
const a = await ophirofoxEuropresseLink(extractKeywords());
elt.after(a);
console.log(elt);
if(elt !== article_title){
//second link is in shadow dom context -> no access to stylesheet
a.style.display = "block"
a.style.width = "35%";
a.style.margin = "0.5rem auto";
a.style.padding = "0.5rem 0";
a.style.borderRadius = "0.3rem";
a.style.backgroundColor = "#ffc700";
a.style.color = "#000";
a.style.textDecoration = "none";
a.style.textAlign = "center";
}
}
}

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.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);
const paywall_modal = document.querySelector('.PSAPAG_root');
if(paywall_modal){;
const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot;
const modal_content = shadow_content.firstChild.lastChild;
createLink(article_title);
createLink(modal_content);

buttonAdded = true;
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
observer.disconnect();
}
}
Expand Down
7 changes: 0 additions & 7 deletions ophirofox/content_scripts/hetnieuwsblad.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@
color: #000 !important;
text-align: center;
text-decoration: none;
}

.ophirofox-modal-link {
display: block;
margin-top: 0;
padding: 0.5rem;
border-radius: 0;
}
45 changes: 26 additions & 19 deletions ophirofox/content_scripts/hetnieuwsblad.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
let buttonAdded = false;
const article_title = document.querySelector('header[data-testid="article-header"] h1');

function extractKeywords() {
return document.querySelector("header h1").textContent;
return article_title.textContent;
}

let buttonAdded = false;

async function createLink(elt) {
if (elt && buttonAdded == false){
const a = await ophirofoxEuropresseLink(extractKeywords());
elt.after(a);
console.log(elt);
if(elt !== article_title){
//second link is in shadow dom context -> no access to stylesheet
a.style.display = "block"
a.style.width = "35%";
a.style.margin = "0.5rem auto";
a.style.padding = "0.5rem 0";
a.style.borderRadius = "0.3rem";
a.style.backgroundColor = "#ffc700";
a.style.color = "#000";
a.style.textDecoration = "none";
a.style.textAlign = "center";
}
}
}

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
async function onLoad() {
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
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);
const paywall_modal = document.querySelector('.PSAPAG_root');
if(paywall_modal){;
const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot;
const modal_content = shadow_content.firstChild.lastChild;
createLink(article_title);
createLink(modal_content);

buttonAdded = true;
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
observer.disconnect();
}
}
}
}
};

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

0 comments on commit e085875

Please sign in to comment.