Skip to content

Commit

Permalink
Réparation du bouton Libération (#188)
Browse files Browse the repository at this point in the history
* Réparation bouton Le Point

* Ajout de Corse Matin, La Tribune, L'Opinion, Nice-Matin

* Rectification du formatage du code

* Ajout L'Orient-Le Jour

* Restylage bouton L'Est Républicain

* Réparation bouton Libération
  • Loading branch information
fmoncomble authored Jan 18, 2024
1 parent ac1ee99 commit 249d5eb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
16 changes: 14 additions & 2 deletions ophirofox/content_scripts/liberation.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
.ophirofox-europresse {
margin-left: 10px;
color: inherit;
font-size: 0.875rem;
line-height: 1.125rem;
/* margin-top: 1.5rem; */
margin-bottom: 10px;
margin-left: 0px;
padding: 5px 10px;
background-color: #eeb54e;
color: #000;
border-radius: 2px;
text-decoration: none;
}

.ophirofox-europresse:hover {
color: #666666;
}
22 changes: 13 additions & 9 deletions ophirofox/content_scripts/liberation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
console.log('Ophirofox injected');

function extractKeywords() {
return document
.querySelector("meta[property='og:title']")
Expand All @@ -6,19 +8,21 @@ function extractKeywords() {

async function createLink() {
const a = await ophirofoxEuropresseLink(extractKeywords());
a.classList.add("ribbon-premium");
return a;
}

function findPremiumBanner() {
const anchor = document.querySelector('div.TypologyArticle__BlockPremium-sc-1vro4tp-2');
if (!anchor) {
return;
}
return anchor;
}

async function onLoad() {
const reserve = document.evaluate(
"//*[contains(text(), 'réservé aux abonnés')]",
document.body,
null,
XPathResult.UNORDERED_NODE_ITERATOR_TYPE
).iterateNext();
if (!reserve) return;
reserve.appendChild(await createLink());
const premiumBanner = findPremiumBanner();
if (!premiumBanner) return;
premiumBanner.after(await createLink());
}

onLoad();

0 comments on commit 249d5eb

Please sign in to comment.