Last active
August 3, 2022 17:02
-
-
Save ponich/704ebc3e9194554e4b59f49373adb172 to your computer and use it in GitHub Desktop.
TripperClicker
This file contains hidden or 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 Simple Tampermonkey Script | |
| // @version 1.0 | |
| // @match https://vk.com/classifieds?w=* | |
| // @grant window.close | |
| // ==/UserScript== | |
| (() => { | |
| const domObserver = new MutationObserver((mutations) => { | |
| mutations.forEach(mutation => { | |
| mutation.addedNodes.forEach(node => { | |
| document.dispatchEvent(new CustomEvent('addedNode', { | |
| detail: node | |
| })); | |
| }); | |
| }); | |
| }); | |
| domObserver.observe(document.querySelector('body'), {subtree: true, childList: true}); | |
| function whenIsReady(element, callback) { | |
| const $element = document.querySelector(element); | |
| if ($element) { | |
| callback($element); | |
| } else { | |
| document.addEventListener('addedNode', (e) => { | |
| if (document.querySelector(element) === e.detail) { | |
| callback(e.detail); | |
| } | |
| }); | |
| } | |
| } | |
| // main code | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment