Created
October 17, 2023 14:24
-
-
Save matthiasseghers/3d24236401cf68f86affee639879ec05 to your computer and use it in GitHub Desktop.
Bypass-demorgen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Bypass Paid article | |
// @namespace http://your.namespace.com | |
// @version 0.1 | |
// @description Execute functions when a certain element appears in the DOM | |
// @author You | |
// @match https://www.demorgen.be/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function byPassPayment() { | |
console.log("Bypassing payment..."); | |
// Remove backdrops and overlay. | |
const htmlElement = document.querySelector('html'); | |
htmlElement.classList.remove('js-tm-backdrop-active', 'js-tm-overflow-scroll-active'); | |
// Show the actual article that is hidden. | |
document.querySelectorAll('section.artstyle__main [class^="artstyle__"].js-is-hidden') | |
.forEach(el => el.classList.remove('js-is-hidden')); | |
// Remove overlay elements. | |
document.querySelector('article#PURCHASE__OVERLAY')?.remove(); | |
document.querySelectorAll('[data-temptation-position^="ARTICLE_"]').forEach(el => el.remove()); | |
} | |
function checkAndExecute() { | |
const targetSelector = '.is-article-page.js-tm-backdrop-active.js-tm-overflow-scroll-active'; | |
const targetElement = document.querySelector(targetSelector); | |
if (targetElement) { | |
byPassPayment(); | |
observer.disconnect(); | |
} | |
} | |
const observer = new MutationObserver(checkAndExecute); | |
const observerConfig = { subtree: true, attributes: true }; | |
observer.observe(document.body, observerConfig); | |
checkAndExecute(); // Call the function once to check if the element is already present | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment