What I'm trying to do is write a Chrome extension that will add a Javascript snippet that will fire after all the Javascript code has been run on the page, but before the onload event occurs. (There is a code on the page that has an event for the onload event). I tried everything I thought about my extension, but I did not find a consistent way to do this with the Google Chrome extension.
I tried to set the run_at value to both "document_start" and "document_end" along with adding this fragment to both the head and body, both to <script > </script > with internal html and <script > </script > with using src pointing to the file in the extension. Nothing works sequentially.
Has anyone been lucky with this or with thoughts on how to act?
UPDATE!I have made some progress, but now I hit another snag. I have a set of extensions for run_at document_start and it always fires before the script loads. Then I add an event listener for the DOMContentLoaded event, and then send a request to my background page (to get the currently selected options so that I know how to change the script on the page).
The problem is that sometimes the event fires before I get my answer from the man page. When I get the answer before DOMContentLoaded , everything works. Since this is asynchronous, I have not found a way to somehow wait for this answer.
Does anyone have any thoughts on how to proceed?
Datin source share