Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.
Here is an interesting hybrid MutationObserver + setTimeout
https://greasyfork.org/en/scripts/460977-autoclick-resume-button-in-rooms-at-character-ai/code
I'm not sure how effective it is, but provided that the filtering
childList: true subtree: true
insufficient. And the use of larger triggers is too resource-consuming, so perhaps in some cases it is justified
You can also use some of the ready-made function libraries. Many of them are used by greasyfork authors
// https://stackoverflow.com/a/68262400
// best https://codepad.co/snippet/wait-for-an-element-to-exist-via-mutation-observer
// alt:
// https://git.io/waitForKeyElements.js
// https://github.com/fuzetsu/userscripts/tree/master/wait-for-elements
// https://github.com/CoeJoder/waitForKeyElements.js/blob/master/waitForKeyElements.js
// https://gist.githubusercontent.com/sidneys/ee7a6b80315148ad1fb6847e72a22313/raw/
// https://greasyfork.org/scripts/21927-arrive-js/code/arrivejs.js (ex: https://greasyfork.org/en/scripts/429783-confirm-and-upload-imgur)
// https://greasyfork.org/scripts/464780-global-module/code/global_module.js
I know of at least 2 other alternatives
https://github.com/AndShy/Ali-Total-Price
https://greasyfork.org/en/scripts/6119-aliexpress-plus
Sorry for the late reply. Sites (openuserjs.org) don't notify me of new posts if I'm logged in via github
here is an implementation example on MutationObserver
MutationObserver checks after every change. In some cases, setInterval is more efficient due to the cost of fewer resources.
waitElement('body') .then(el => { console.log('el:', el); }); function waitElement(selector, container) { if (container && !(container instanceof HTMLElement)) return console.error('wait > container not HTMLElement:', container); return new Promise(resolve => { if (element = (container || document.body || document).querySelector(selector)) return resolve(element); const observer = new MutationObserver(mutations => { if (element = (container || document.body || document).querySelector(selector)) { resolve(element); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); }); }
you can use asynchronous calls
await Promise.resolve(document.body.querySelector(selector))
or you can use Promise. But alas, it does not return the element itself. It is only suitable for waiting for the html element
function waitElement(selector = required(), container) { if (typeof selector !== 'string') return console.error('wait > selector:', typeof selector); if (container && !(container instanceof HTMLElement)) return console.error('wait > container not HTMLElement:', container); // console.debug('waitElement:', selector); return Promise.resolve((container || document.body).querySelector(selector)); }
thanks i updated
Re: @asakjs:
Added a choice of language and auto. But not sure what will work