Skip to content

Commit 97b59ae

Browse files
author
github-actions
committed
Release from Ophirofox v2.6.10403.1738
1 parent 2579f47 commit 97b59ae

1 file changed

Lines changed: 57 additions & 50 deletions

File tree

ophirofox.user.js

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 2.6.10403.1420
2+
// @version 2.6.10403.1738
33
// @author Write
44
// @name OphirofoxScript
55
// @grant GM.getValue
@@ -1597,30 +1597,24 @@
15971597

15981598
window.addEventListener("load", function(event) {
15991599
function extractKeywords() {
1600-
return document.querySelector("h1").textContent;
1600+
return document.querySelector("h1")?.textContent;
16011601
}
16021602

1603-
async function createLink() {
1604-
const span = document.createElement("span");
1605-
span.textContent = "Lire sur Europresse";
1606-
span.className = "premium-message ophirofox-europresse";
1607-
1603+
async function injectButton() {
1604+
if (document.querySelector('.ophirofox-europresse')) return;
1605+
const reserved = document.querySelector(".typo-p2-paragraph p");
1606+
if (!reserved || reserved.textContent.trim() !== "Article réservé aux abonnés") return;
16081607
const a = await ophirofoxEuropresseLink(extractKeywords());
1609-
a.classList.add("btn", "btn--premium");
1610-
a.innerHTML = "";
1611-
a.appendChild(span);
1612-
1613-
return a;
1608+
a.classList.add("ophirofox-europresse", "btn", "relative", "btn-outline", "btn-primary", "btn-sm", "typo-caption-important", "self-start", "px-4", "py-1");
1609+
reserved.closest(".typo-p2-paragraph").after(a);
16141610
}
16151611

1616-
async function onLoad() {
1617-
const reserve = document.querySelector(".premium-message");
1618-
if (!reserve) return;
1619-
1620-
reserve.parentElement.appendChild(await createLink());
1621-
}
1622-
1623-
onLoad().catch(console.error);
1612+
const observer = new MutationObserver(() => injectButton().catch(console.error));
1613+
observer.observe(document.body, {
1614+
childList: true,
1615+
subtree: true
1616+
});
1617+
injectButton().catch(console.error);
16241618
});
16251619

16261620
pasteStyle(`
@@ -2306,7 +2300,7 @@
23062300
}
23072301

23082302
async function onLoad() {
2309-
const head = document.querySelector(".article-premium-header");
2303+
const head = document.querySelector(".badge-premium");
23102304
if (!head) return;
23112305
head.appendChild(await createLink());
23122306
}
@@ -2788,30 +2782,41 @@
27882782
if (match(hostname, "https://www.latribune.fr/*")) {
27892783

27902784
window.addEventListener("load", function(event) {
2791-
function extractKeywords() {
2792-
return document.querySelector('h1').textContent;
2793-
}
2794-
2795-
async function createLink() {
2796-
const a = await ophirofoxEuropresseLink(extractKeywords());
2797-
a.classList.add();
2798-
return a;
2785+
function injectButton() {
2786+
const banner = document.querySelector('.bg-premium-10');
2787+
if (!banner) return;
2788+
if (banner.querySelector('.ophirofox-europresse')) return;
2789+
const premiumBanner = [...banner.querySelectorAll('p')]
2790+
.find(p => p.textContent === 'Ce contenu est réservé aux abonnés');
2791+
if (!premiumBanner) return;
2792+
ophirofoxEuropresseLink(document.querySelector('h1')?.textContent)
2793+
.then(a => premiumBanner.after(a));
27992794
}
28002795

2801-
function findPremiumBanner() {
2802-
const title = document.querySelector('.rev-premium-tag-article-lt__container');
2803-
if (!title) return null;
2804-
const elems = title.querySelectorAll('p');
2805-
return [...elems].find((d) => d.textContent === 'Ce contenu est réservé aux abonnés');
2806-
}
2796+
function watchPage(callback) {
2797+
// Navigation SPA via History API
2798+
const origPush = history.pushState.bind(history);
2799+
const origReplace = history.replaceState.bind(history);
2800+
history.pushState = (...args) => {
2801+
origPush(...args);
2802+
callback();
2803+
};
2804+
history.replaceState = (...args) => {
2805+
origReplace(...args);
2806+
callback();
2807+
};
2808+
window.addEventListener('popstate', callback);
28072809

2808-
async function onLoad() {
2809-
const premiumBanner = findPremiumBanner();
2810-
if (!premiumBanner) return;
2811-
premiumBanner.after(await createLink());
2810+
// MutationObserver pour le rendu dynamique
2811+
const observer = new MutationObserver(callback);
2812+
observer.observe(document.body, {
2813+
childList: true,
2814+
subtree: true
2815+
});
28122816
}
28132817

2814-
onLoad().catch(console.error);
2818+
watchPage(() => injectButton());
2819+
injectButton();
28152820
});
28162821

28172822
pasteStyle(`
@@ -2877,7 +2882,7 @@
28772882
}
28782883

28792884
function findPremiumBanner() {
2880-
const title = document.querySelector('div.header-subscriber');
2885+
const title = document.querySelector('.tag-premium');
28812886
if (!title) return null;
28822887
return title;
28832888
}
@@ -4036,29 +4041,31 @@
40364041

40374042
window.addEventListener("load", function(event) {
40384043
function extractKeywords() {
4039-
return document.querySelector(".editoSocialBar__item[data-title]").dataset.title
4044+
return document.querySelector("h1")?.textContent;
40404045
}
4041-
40424046
async function createLink() {
40434047
const a = await ophirofoxEuropresseLink(extractKeywords());
4044-
a.style = 'font-family: "arimo-bold",Arial,Helvetica,sans-serif; border-bottom: 2px solid #000; margin-left : 1rem'
4048+
a.style.cssText = `
4049+
font-family: "arimo-bold",Arial,Helvetica,sans-serif;
4050+
border-bottom: 2px solid #000;
4051+
float: right;
4052+
margin-left: 10px;
4053+
4054+
font-weight: 600;
4055+
`;
40454056
return a;
40464057
}
40474058

40484059
function findPremiumBanner() {
4049-
const div = document.querySelector(".epPayWallTop");
4060+
const div = document.querySelector(".c-paywall-label");
40504061
if (!div) return null;
4051-
console.log('all div', div)
4052-
console.log('last child', div.lastElementChild)
4053-
return elem = div.lastElementChild;
4062+
return div.lastElementChild;
40544063
}
4055-
40564064
async function onLoad() {
40574065
const premiumBanner = findPremiumBanner();
40584066
if (!premiumBanner) return;
40594067
premiumBanner.after(await createLink());
40604068
}
4061-
40624069
onLoad().catch(console.error);
40634070
});
40644071

0 commit comments

Comments
 (0)