Skip to content

Instantly share code, notes, and snippets.

@ngseke
Created June 20, 2023 05:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngseke/34bf7450052c40a9cf0ebd5eac258398 to your computer and use it in GitHub Desktop.
Save ngseke/34bf7450052c40a9cf0ebd5eac258398 to your computer and use it in GitHub Desktop.
Liberate 87pu
// ==UserScript==
// @name Liberate 87pu
// @namespace http://tampermonkey.net/
// @version 0.1
// @author You
// @match https://www.87pu.com.tw/*
// @grant none
// ==/UserScript==
(function () {
function waitForEl(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, { childList: true, subtree: true });
});
}
function removeAds () {
const selectors = ['.a-post-show', '#viptoneWindow', '#liveVideo', '.update_vip_bar']
selectors.forEach(async (ad) => {
await waitForEl(ad)
;[...document.querySelectorAll(ad)].forEach(el => el?.remove())
})
}
function liberate () {
ẵ = () => 1
}
removeAds()
liberate()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment