|
1 | 1 | // ==UserScript== |
2 | | -// @version 2.5.250319.1643 |
| 2 | +// @version 2.5.250326.2302 |
3 | 3 | // @author Write |
4 | 4 | // @name OphirofoxScript |
5 | 5 | // @grant GM.getValue |
|
2231 | 2231 | if (match(hostname, "https://www.leparisien.fr/*")) { |
2232 | 2232 |
|
2233 | 2233 | window.addEventListener("load", function(event) { |
| 2234 | + |
2234 | 2235 | function extractKeywords() { |
2235 | 2236 | return document.querySelector("h1").textContent; |
2236 | 2237 | } |
|
2246 | 2247 | head.after(await createLink()); |
2247 | 2248 | } |
2248 | 2249 |
|
2249 | | - function findPremiumBanner(bannerSelector) { |
2250 | | - if (!bannerSelector) return null; |
2251 | | - const elems = bannerSelector.parentElement.querySelectorAll("div"); |
2252 | | - return [...elems].find(d => d.textContent.includes("Cet article est réservé aux abonnés")); |
2253 | | - } |
2254 | | - |
2255 | 2250 | async function onLoad() { |
2256 | | - const bannerSelector = document.querySelector(".paywall-sticky.width_full.d_flex.pt_3_m.pb_3_m.pt_4_nm.pb_4_nm.pos_stick.ff_gct.fw_r.justify_center"); |
2257 | | - if (findPremiumBanner(bannerSelector)) { |
| 2251 | + const bannerSelector = document.querySelector(".btn-subscribe"); |
| 2252 | + if (bannerSelector) { |
2258 | 2253 | addEuropresseButton(); |
2259 | 2254 | } else { |
| 2255 | + // console.log("Premium banner couldn't be found") |
2260 | 2256 | /* Premium banner couldn't be found, use MutationObserver as fallback */ |
2261 | 2257 | var elementFound = false; |
2262 | 2258 | const callback = (mutationList, observer) => { |
2263 | 2259 | for (const mutation of mutationList) { |
2264 | 2260 | for (const e of mutation.addedNodes) { |
2265 | | - const bannerSelectorString = 'paywall-sticky width_full d_flex pt_3_m pb_3_m pt_4_nm pb_4_nm pos_stick ff_gct fw_r justify_center'; |
| 2261 | + const bannerSelectorString = 'btn-subscribe'; |
2266 | 2262 | if (e.className == bannerSelectorString) { |
2267 | 2263 | observer.disconnect(); |
2268 | 2264 | elementFound = true; |
2269 | | - if (findPremiumBanner(e)) { |
2270 | | - addEuropresseButton(); |
2271 | | - } |
| 2265 | + addEuropresseButton(); |
2272 | 2266 | break; |
2273 | 2267 | } |
2274 | 2268 | } |
|
0 commit comments