diff --git a/ophirofox/content_scripts/lesechos.css b/ophirofox/content_scripts/lesechos.css
index a9bb4f60..aecd8f62 100644
--- a/ophirofox/content_scripts/lesechos.css
+++ b/ophirofox/content_scripts/lesechos.css
@@ -6,5 +6,5 @@
border: 1px solid grey;
border-radius: 50px;
text-decoration: none;
- font-size: 0.85em;
-}
+ font-size: 1.2rem;
+}
\ No newline at end of file
diff --git a/ophirofox/content_scripts/lesechos.js b/ophirofox/content_scripts/lesechos.js
index 502bf7ee..dad48d5b 100644
--- a/ophirofox/content_scripts/lesechos.js
+++ b/ophirofox/content_scripts/lesechos.js
@@ -6,7 +6,7 @@ function extractKeywords() {
let buttonAdded = false;
async function addEuropresseButton() {
- if(!buttonAdded) {
+ if (!buttonAdded) {
const elt = document.querySelector("button[aria-label=Commenter]")?.parentElement?.parentElement;
if (elt) {
const a = await ophirofoxEuropresseLink(extractKeywords());
@@ -17,40 +17,63 @@ async function addEuropresseButton() {
}
async function onLoad() {
-
+
/* 2 cases:
- 1. either a page is initially loaded, and we must wait for the actual end of loading (determined
- by a new iframe #rufous-sandbox) and add the button (this is the first observer)
- 2. Or a page is newly routed (for instance, when one goes from the homepage to an article) :
+ 1. either a page is initially loaded, and we must wait for the actual end of loading (determined
+ by a new meta with name ad:postAcces) and add the button (this is the first observer).
+ 2. Or a page is newly routed (for instance, when one goes from the homepage to an article) :
- it is detected with the second observer that watches for changes in
and reset the button
- - we wait for the end of actual loading of the new content by observing
+ - we wait for the end of actual loading of the new content by observing .
*/
-
+
+ const isPremium = () => {
+ if (document.querySelector("meta[name='ad:postAccess']").content == 'subscribers') {
+ return true;
+ }
+ return false;
+ };
+
const callback = (mutationList, observer) => {
+ if (document.querySelector('meta[name="ad:postAccess"]')) {
+ addEuropresseButton();
+ observer.disconnect();
+ return;
+ }
for (const mutation of mutationList) {
for (const e of mutation.addedNodes) {
- if(e.id == "rufous-sandbox") {
- addEuropresseButton();
+ if (e.name == "ad:postAccess") {
+ if (isPremium())
+ addEuropresseButton();
}
}
}
};
const observer = new MutationObserver(callback);
- observer.observe(document.body, { childList: true});
-
+ observer.observe(document.body, {
+ childList: true
+ });
+
const observerTitle = new MutationObserver(() => {
buttonAdded = false;
- addEuropresseButton();
+ if (isPremium())
+ addEuropresseButton();
});
+
const title = document.querySelector("title")
- observerTitle.observe(title, { childList: true, subtree: false });
-
+ observerTitle.observe(title, {
+ childList: true,
+ subtree: false
+ });
+
const observerMain = new MutationObserver(() => {
addEuropresseButton();
- });
- const main = document.querySelector("main")
- observerMain.observe(main, { childList: true, subtree: false });
+ });
+ const main = document.querySelector("main meta[content]")
+ observerMain.observe(main, {
+ childList: true,
+ subtree: false
+ });
}
-onLoad().catch(console.error);
+onLoad().catch(console.error);
\ No newline at end of file