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.
https://github.com/look997/PNYT
Code
https://github.com/look997/PNYT/blob/master/pnyt.user.js
I have a small script to YouTube.
The problem started since the videos load without refreshing the page.
popstate event is not enough - it works only when the back / forward-button.
The "setTOFun ()" should be performed each time you charge the new film.
How to do it?
Re: @look997:
You can use a Mutation Observer to watch for changes in the page. Here is an example:
https://greasyfork.org/en/scripts/4346-youtube-remove-list-from-watch-urls/code
On line 32, call your script to parse through the list of added nodes.
Re: @look997:
Could use setInterval and check if the element exists before continuing
If the url is changing in the address bar, but a new page isn't being loaded, they could be modifiying the history. You can use window.onpopstate to detect the change.
Re: @sizzle:
My bad. I didn't read your entire post. You already used popstate. I've had this problem on a similar page. The onpopstate doesn't help. The page doesn't reload, but the url changes.
This might help (you might have to use
@run-at document-start
):var pushState = window.history.pushState; window.history.pushState = window.history.replaceState = function (stateObj, title, url) { console.log('changed to: ' + url); pushState(stateObj, title, url); };