I am playing around with building some browser extensions with Crossrider. I need some code to execute before pageload, before any DOM elements are rendered. Is this possible with Crossrider?
I have tried using appAPI.dom.onDocumentStart.addJS
in the background scope but with no luck. I still see the page partially display before my code executes.
Thanks
UPDATE with More Details
An example of what I'm trying to do is an extension that redirects bad websites to good ones. Basically if a user hits a website that is bad on our list it will redirect them to a good alternative and give them a message. I am working on the redirect part and here is some sample code.
Inside my background.js
appAPI.ready(function($) {
appAPI.dom.onDocumentStart.addJS({resourcePath:'main.js'});
});
Then I have a main.js file in my Resources
if(window.location.href == "http://www.bing.com/"){
console.log("You are at Bing... That's bad m'kay.");
window.location = "http://www.google.com";
}
In this case if a user goes to bing they get redirected to google and then would get some kinda funny message about it. They will also get warnings for sites like 4chan, torrent sites etc.
So currently if I implement this code, and go to bing it flashes the DOM and then redirects. I am trying to prevent this. Thanks!
I am testing on Win 7 and Chrome
Thanks!