I investigated the Safari/UserScripts issue and found that the root cause appears to be the execution context isolation in UserScripts. The userscript context cannot access page globals (e.g. window.player, NEXT_DATA), so site helpers fail to obtain the required video information.
I implemented a proof-of-concept in my fork by introducing a page-context bridge between the page and the userscript. It restores access to page globals and allows VOT to work correctly in Safari/UserScripts.
If it's useful, feel free to reuse or adapt any part of the implementation:
https://github.com/Acobat12/userscripts/blob/main/src/ext/content-scripts/entry-userscripts.js
If you'd like, I can also prepare a pull request.
I investigated the Safari/UserScripts issue and found that the root cause appears to be the execution context isolation in UserScripts. The userscript context cannot access page globals (e.g. window.player, NEXT_DATA), so site helpers fail to obtain the required video information.
I implemented a proof-of-concept in my fork by introducing a page-context bridge between the page and the userscript. It restores access to page globals and allows VOT to work correctly in Safari/UserScripts.
If it's useful, feel free to reuse or adapt any part of the implementation:
https://github.com/Acobat12/userscripts/blob/main/src/ext/content-scripts/entry-userscripts.js
If you'd like, I can also prepare a pull request.