Skip to content

Commit e856c3e

Browse files
author
github-actions
committed
Release from Ophirofox v2.4.26202.21213
1 parent b2d99db commit e856c3e

File tree

1 file changed

+73
-70
lines changed

1 file changed

+73
-70
lines changed

ophirofox.user.js

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 2.4.26199.27938
2+
// @version 2.4.26202.21213
33
// @author Write
44
// @name OphirofoxScript
55
// @grant GM.getValue
@@ -2657,39 +2657,47 @@
26572657
if ("https://www.standaard.be/*".includes(hostname)) {
26582658

26592659
window.addEventListener("load", function(event) {
2660+
let buttonAdded = false;
2661+
const article_title = document.querySelector('header[data-testid="article-header"] h1');
2662+
26602663
function extractKeywords() {
2661-
return document.querySelector("header h1").textContent;
2664+
return article_title.textContent;
26622665
}
26632666

2664-
let buttonAdded = false;
2665-
26662667
async function createLink(elt) {
26672668
if (elt && buttonAdded == false) {
26682669
const a = await ophirofoxEuropresseLink(extractKeywords());
26692670
elt.after(a);
2671+
console.log(elt);
2672+
if (elt !== article_title) {
2673+
//second link is in shadow dom context -> no access to stylesheet
2674+
a.style.display = "block"
2675+
a.style.width = "35%";
2676+
a.style.margin = "0.5rem auto";
2677+
a.style.padding = "0.5rem 0";
2678+
a.style.borderRadius = "0.3rem";
2679+
a.style.backgroundColor = "#ffc700";
2680+
a.style.color = "#000";
2681+
a.style.textDecoration = "none";
2682+
a.style.textAlign = "center";
2683+
}
26702684
}
26712685
}
26722686

26732687
async function onLoad() {
2674-
// Lien Europresse dans le corps de l'article
2675-
const paywall = document.querySelector('[data-cj-root="subscription-wall"]');
2676-
const article_title = document.querySelector('header h1');
2677-
2678-
if (paywall) {
2679-
createLink(article_title);
2680-
}
2681-
2682-
// Lien Europresse dans la modale, au chargement
26832688
const callback = (mutationList, observer) => {
26842689
for (const mutation of mutationList) {
26852690
if (mutation.type === 'childList') {
26862691
for (let node of mutation.addedNodes) {
2687-
const paywall_modal = document.querySelector('.cj-root');
2692+
const paywall_modal = document.querySelector('.PSAPAG_root');
26882693
if (paywall_modal) {
2689-
const subscriptionForm = document.querySelector('[data-current-screen="CtaAuthPaying"] form');
2690-
createLink(subscriptionForm);
2694+
;
2695+
const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot;
2696+
const modal_content = shadow_content.firstChild.lastChild;
2697+
createLink(article_title);
2698+
createLink(modal_content);
2699+
26912700
buttonAdded = true;
2692-
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
26932701
observer.disconnect();
26942702
}
26952703
}
@@ -2718,13 +2726,6 @@
27182726
text-align: center;
27192727
text-decoration: none !important;
27202728
}
2721-
2722-
.ophirofox-modal-link {
2723-
display: block;
2724-
margin-top: 0;
2725-
padding: 0.5rem;
2726-
border-radius: 0;
2727-
}
27282729
`);
27292730
}
27302731

@@ -2878,39 +2879,47 @@
28782879
if ("https://www.gva.be/*".includes(hostname)) {
28792880

28802881
window.addEventListener("load", function(event) {
2882+
let buttonAdded = false;
2883+
const article_title = document.querySelector('header[data-testid="article-header"] h1');
2884+
28812885
function extractKeywords() {
2882-
return document.querySelector("header h1").textContent;
2886+
return article_title.textContent;
28832887
}
28842888

2885-
let buttonAdded = false;
2886-
28872889
async function createLink(elt) {
28882890
if (elt && buttonAdded == false) {
28892891
const a = await ophirofoxEuropresseLink(extractKeywords());
28902892
elt.after(a);
2893+
console.log(elt);
2894+
if (elt !== article_title) {
2895+
//second link is in shadow dom context -> no access to stylesheet
2896+
a.style.display = "block"
2897+
a.style.width = "35%";
2898+
a.style.margin = "0.5rem auto";
2899+
a.style.padding = "0.5rem 0";
2900+
a.style.borderRadius = "0.3rem";
2901+
a.style.backgroundColor = "#ffc700";
2902+
a.style.color = "#000";
2903+
a.style.textDecoration = "none";
2904+
a.style.textAlign = "center";
2905+
}
28912906
}
28922907
}
28932908

28942909
async function onLoad() {
2895-
// Lien Europresse dans le corps de l'article
2896-
const paywall = document.querySelector('[data-cj-root="subscription-wall"]');
2897-
const article_title = document.querySelector('header h1');
2898-
2899-
if (paywall) {
2900-
createLink(article_title);
2901-
}
2902-
2903-
// Lien Europresse dans la modale, au chargement
29042910
const callback = (mutationList, observer) => {
29052911
for (const mutation of mutationList) {
29062912
if (mutation.type === 'childList') {
29072913
for (let node of mutation.addedNodes) {
2908-
const paywall_modal = document.querySelector('.cj-root');
2914+
const paywall_modal = document.querySelector('.PSAPAG_root');
29092915
if (paywall_modal) {
2910-
const subscriptionForm = document.querySelector('[data-current-screen="StopEmailIdentification"] form');
2911-
createLink(subscriptionForm);
2916+
;
2917+
const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot;
2918+
const modal_content = shadow_content.firstChild.lastChild;
2919+
createLink(article_title);
2920+
createLink(modal_content);
2921+
29122922
buttonAdded = true;
2913-
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
29142923
observer.disconnect();
29152924
}
29162925
}
@@ -2939,52 +2948,53 @@
29392948
text-align: center;
29402949
text-decoration: none;
29412950
}
2942-
2943-
.ophirofox-modal-link {
2944-
display: block;
2945-
margin-top: 0;
2946-
padding: 0.5rem;
2947-
border-radius: 0;
2948-
}
29492951
`);
29502952
}
29512953

29522954
if ("https://www.nieuwsblad.be/*".includes(hostname)) {
29532955

29542956
window.addEventListener("load", function(event) {
2957+
let buttonAdded = false;
2958+
const article_title = document.querySelector('header[data-testid="article-header"] h1');
2959+
29552960
function extractKeywords() {
2956-
return document.querySelector("header h1").textContent;
2961+
return article_title.textContent;
29572962
}
29582963

2959-
let buttonAdded = false;
2960-
29612964
async function createLink(elt) {
29622965
if (elt && buttonAdded == false) {
29632966
const a = await ophirofoxEuropresseLink(extractKeywords());
29642967
elt.after(a);
2968+
console.log(elt);
2969+
if (elt !== article_title) {
2970+
//second link is in shadow dom context -> no access to stylesheet
2971+
a.style.display = "block"
2972+
a.style.width = "35%";
2973+
a.style.margin = "0.5rem auto";
2974+
a.style.padding = "0.5rem 0";
2975+
a.style.borderRadius = "0.3rem";
2976+
a.style.backgroundColor = "#ffc700";
2977+
a.style.color = "#000";
2978+
a.style.textDecoration = "none";
2979+
a.style.textAlign = "center";
2980+
}
29652981
}
29662982
}
29672983

29682984
async function onLoad() {
2969-
// Lien Europresse dans le corps de l'article
2970-
const paywall = document.querySelector('[data-cj-root="subscription-wall"]');
2971-
const article_title = document.querySelector('header h1');
2972-
2973-
if (paywall) {
2974-
createLink(article_title);
2975-
}
2976-
2977-
// Lien Europresse dans la modale, au chargement
29782985
const callback = (mutationList, observer) => {
29792986
for (const mutation of mutationList) {
29802987
if (mutation.type === 'childList') {
29812988
for (let node of mutation.addedNodes) {
2982-
const paywall_modal = document.querySelector('.cj-root');
2989+
const paywall_modal = document.querySelector('.PSAPAG_root');
29832990
if (paywall_modal) {
2984-
const subscriptionForm = document.querySelector('[data-current-screen="StopEmailIdentification"] form');
2985-
createLink(subscriptionForm);
2991+
;
2992+
const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot;
2993+
const modal_content = shadow_content.firstChild.lastChild;
2994+
createLink(article_title);
2995+
createLink(modal_content);
2996+
29862997
buttonAdded = true;
2987-
subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link');
29882998
observer.disconnect();
29892999
}
29903000
}
@@ -3013,13 +3023,6 @@
30133023
text-align: center;
30143024
text-decoration: none;
30153025
}
3016-
3017-
.ophirofox-modal-link {
3018-
display: block;
3019-
margin-top: 0;
3020-
padding: 0.5rem;
3021-
border-radius: 0;
3022-
}
30233026
`);
30243027
}
30253028

0 commit comments

Comments
 (0)