Skip to content

Commit d73d54c

Browse files
author
github-actions
committed
Release from Ophirofox v2.4.26558.25081
1 parent 3394504 commit d73d54c

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

ophirofox.user.js

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 2.4.26551.45883
2+
// @version 2.4.26558.25081
33
// @author Write
44
// @name OphirofoxScript
55
// @grant GM.getValue
@@ -151,6 +151,7 @@
151151
// @include https://www.arretsurimages.net/*
152152
// @include https://www.pressreader.com/*
153153
// @include https://www.usinenouvelle.com/*
154+
// @include https://elpais.com/*
154155
//
155156
// @run-at document-start
156157
//
@@ -3636,4 +3637,75 @@
36363637
}
36373638
`);
36383639
}
3640+
3641+
if ("https://elpais.com/*".includes(hostname)) {
3642+
3643+
window.addEventListener("load", function(event) {
3644+
let buttonAdded = false;
3645+
3646+
function extractKeywords() {
3647+
let currentURL = new URL(window.location);
3648+
// get title at the end of URL pathname.
3649+
// Remove noise characters, and make it search-ready for europress
3650+
const result = currentURL.pathname
3651+
.split("/")
3652+
.pop()
3653+
.replace(/-|\.html$/g, " ")
3654+
.trim();
3655+
return result;
3656+
}
3657+
3658+
async function createLink(title) {
3659+
if (title && buttonAdded == false) {
3660+
const div = document.createElement("div");
3661+
const a = await ophirofoxEuropresseLink(extractKeywords());
3662+
a.textContent = "Lire sur europresse (Lexis Nexis)";
3663+
div.appendChild(a);
3664+
title.after(div);
3665+
}
3666+
}
3667+
3668+
async function onLoad() {
3669+
console.log("ophirofox loaded");
3670+
const callback = (mutationList, observer) => {
3671+
for (const mutation of mutationList) {
3672+
if (mutation.type === "childList") {
3673+
for (let node of mutation.addedNodes) {
3674+
const paywall = document.querySelector("#ctn_freemium_article");
3675+
if (paywall == null) return;
3676+
3677+
if (buttonAdded == false) {
3678+
const article = document.querySelector(".a_s_b");
3679+
createLink(article);
3680+
3681+
const title = document.querySelector("h1");
3682+
createLink(title);
3683+
}
3684+
buttonAdded = true;
3685+
observer.disconnect();
3686+
}
3687+
}
3688+
}
3689+
};
3690+
const htmlElement = document.querySelector("article");
3691+
const observer = new MutationObserver(callback);
3692+
observer.observe(htmlElement, {
3693+
childList: true,
3694+
subtree: true
3695+
});
3696+
}
3697+
onLoad().catch(console.error);
3698+
});
3699+
3700+
pasteStyle(`
3701+
.ophirofox-europresse {
3702+
padding: .5rem;
3703+
font-size: .75rem;
3704+
min-width: 10rem;
3705+
background: #f7cf3c;
3706+
font-weight: 700;
3707+
font-family: MarcinAntB,sans-serif;
3708+
}
3709+
`);
3710+
}
36393711
})();

0 commit comments

Comments
 (0)