Skip to content

Instantly share code, notes, and snippets.

@ponich
Last active August 3, 2022 17:02
Show Gist options
  • Select an option

  • Save ponich/704ebc3e9194554e4b59f49373adb172 to your computer and use it in GitHub Desktop.

Select an option

Save ponich/704ebc3e9194554e4b59f49373adb172 to your computer and use it in GitHub Desktop.
TripperClicker
// ==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