Code: Select all
navigation.addEventListener('navigate', navigateEvent=>{
'traverse' == navigateEvent.navigationType && changeVideo(new URL(navigateEvent.destination.url).pathname)
});
Unfortunately navigation is still experimental and mostly chromium-only, which these days mostly means not Firefox or Safari (desktop or mobile): https://developer.mozilla.org/en-US/doc ... patibility.
In terms of support timelines I don't think Firefox has started development and Safari is as always radio silent, so it's unclear what the future is there.
There is a polyfill apparently, but I can't vouch for it as I haven't personally used this api: https://github.com/virtualstate/navigation