Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function to evaluate_js to run the js before the body and anything #1586

Open
nelvismyname opened this issue Jan 25, 2025 · 3 comments
Labels

Comments

@nelvismyname
Copy link

Just make it run before DOM or whatever, basically before the body or anything just as the page is available run it

Basically I am trying to make a discord client and Vencord needs to be ran before the body or anything as it relies on Local Storage which discord removes after the body has loaded.

@r0x0r
Copy link
Owner

r0x0r commented Jan 26, 2025

This is tricky, as you must catch a moment when html is loaded, but before the rest of the code.
I am not sure if this is possible with every renderer or at all. Currently evaluate_js is executed roughly after DOMContentLoaded is fired.
Having said that, I will introduce window.run_js function in the next version, which is a stripped down evalless version of evaluate_js. It executes provided script as is and does not return a result. The function is available slightly earlier than evaluate_js, but probably still not early enough. It maybe possible to hook it another navigation event handler to make it available earlier, but I don't know if it is feasible.

@nelvismyname
Copy link
Author

Thank you so much! Just do what you can do, it really means a lot to me.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants