Skip to content

Commit

Permalink
Fix NouvelObs (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
Write committed Sep 1, 2024
1 parent f2b2085 commit da493d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
11 changes: 7 additions & 4 deletions ophirofox/content_scripts/lobs.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 13 additions & 8 deletions ophirofox/content_scripts/lobs.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit da493d2

Please sign in to comment.