From da493d2f1869f5c7c17d6339a1d063e43d5fa1aa Mon Sep 17 00:00:00 2001 From: Joffrey <541722+Write@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:14:55 +0200 Subject: [PATCH] Fix NouvelObs (#244) --- ophirofox/content_scripts/lobs.css | 11 +++++++---- ophirofox/content_scripts/lobs.js | 21 +++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ophirofox/content_scripts/lobs.css b/ophirofox/content_scripts/lobs.css index bd7a3b7..3bc2900 100644 --- a/ophirofox/content_scripts/lobs.css +++ b/ophirofox/content_scripts/lobs.css @@ -9,11 +9,14 @@ font-family: "Karla",ff-karla,sans-serif; font-weight: 700; text-align: center; - margin-bottom: 2rem!important; - + display: block; + width: 200px; + margin-top: 1rem; + margin-bottom: 1rem; + } .ophirofox-europresse:hover, .ophirofox-europresse:active { - background-color: #000000; - color: #ffffff; + background-color: #000000; + color: #ffffff; } \ No newline at end of file diff --git a/ophirofox/content_scripts/lobs.js b/ophirofox/content_scripts/lobs.js index 95343d9..f92b389 100644 --- a/ophirofox/content_scripts/lobs.js +++ b/ophirofox/content_scripts/lobs.js @@ -1,14 +1,19 @@ -function findPremiumBanner() { - const title = document.querySelector(".article-page-header"); - if (!title) return null; - const elems = title.parentElement.querySelectorAll("a"); - return [...elems].find(d => d.href.includes("ph-abo")) +function extractKeywords() { + return document.querySelector("h1").textContent; } +const isPremium = () => { + const metaElement = document.querySelector('meta[name="ad:teaser"]'); + if (metaElement) { + if (metaElement.content === 'true') + return true; + } + return false; +}; + async function onLoad() { - const head = findPremiumBanner(); - if (!head) return; - head.after(await ophirofoxEuropresseLink()); + if (!isPremium()) return; + document.querySelector("h1").after(await ophirofoxEuropresseLink(extractKeywords())); } onLoad().catch(console.error); \ No newline at end of file