Skip to content

Commit 3e89086

Browse files
author
github-actions
committed
Release from Ophirofox v2.5.76.1844
1 parent 8e1836d commit 3e89086

File tree

1 file changed

+90
-1
lines changed

1 file changed

+90
-1
lines changed

ophirofox.user.js

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 2.5.71.1633
2+
// @version 2.5.76.1844
33
// @author Write
44
// @name OphirofoxScript
55
// @grant GM.getValue
@@ -164,6 +164,7 @@
164164
// @include https://www.science-et-vie.com/*
165165
// @include https://investir.lesechos.fr/*
166166
// @include https://www.jeuneafrique.com/*
167+
// @include https://www.leberry.fr/*
167168
//
168169
// @run-at document-start
169170
//
@@ -4336,4 +4337,92 @@
43364337
}
43374338
`);
43384339
}
4340+
4341+
if (match(hostname, "https://www.leberry.fr/*")) {
4342+
4343+
window.addEventListener("load", function(event) {
4344+
//Flag pour ne pas créer multiples bouttons par page.
4345+
let isLinkCreated = false
4346+
4347+
function extractKeywords() {
4348+
const metaElement = document.querySelector('meta[name="og:title"]');
4349+
return metaElement;
4350+
}
4351+
4352+
async function createLink() {
4353+
if (isLinkCreated) return
4354+
isLinkCreated = true
4355+
4356+
const a = await ophirofoxEuropresseLink(extractKeywords());
4357+
a.className = "ophirofox-europresse";
4358+
const paywall = document.querySelector(".bg-premium-light")
4359+
paywall.appendChild(a);
4360+
return a;
4361+
}
4362+
4363+
// Variable pour stocker le timer de surveillance post-injection
4364+
let checkTimer = null;
4365+
4366+
function watchUrlChanges() {
4367+
let currentUrl = window.location.href;
4368+
4369+
// Surveiller les changements d'URL
4370+
setInterval(() => {
4371+
if (currentUrl !== window.location.href) {
4372+
currentUrl = window.location.href;
4373+
isLinkCreated = false
4374+
4375+
// Arrêter la surveillance post-injection
4376+
if (checkTimer) {
4377+
clearInterval(checkTimer);
4378+
checkTimer = null;
4379+
}
4380+
4381+
// Relancer l'observer quand l'URL change
4382+
startObserver();
4383+
}
4384+
}, 500); // Vérifier toutes les 500ms
4385+
}
4386+
4387+
function startObserver() {
4388+
const callback = (mutationList, observer) => {
4389+
for (const mutation of mutationList) {
4390+
if (mutation.type === 'attributes' && mutation.attributeName === 'id') {
4391+
if (!isLinkCreated) {
4392+
createLink()
4393+
}
4394+
observer.disconnect();
4395+
}
4396+
}
4397+
};
4398+
const htmlElement = document.querySelector('body');
4399+
//paywall balise
4400+
const classState = htmlElement.classList.contains('.bg-premium-light');
4401+
const observer = new MutationObserver(callback);
4402+
observer.observe(htmlElement, {
4403+
attributes: true,
4404+
subtree: true
4405+
});
4406+
}
4407+
4408+
async function onLoad() {
4409+
startObserver()
4410+
watchUrlChanges()
4411+
}
4412+
4413+
onLoad().catch(console.error);
4414+
});
4415+
4416+
pasteStyle(`
4417+
.ophirofox-europresse {
4418+
display: inline-block;
4419+
padding: 0.25rem 1rem;
4420+
border-radius: 0.3rem;
4421+
background-color: #ffc700;
4422+
color: #000 !important;
4423+
text-align: center;
4424+
text-decoration: none;
4425+
}
4426+
`);
4427+
}
43394428
})();

0 commit comments

Comments
 (0)