Skip to content Skip to sidebar Skip to footer

Run Custom Javascript Code After Loading Any Website

I am working on taking readings about web browser performance and so need to access the window.performance object of the browser. To collect this data i have written a javascript

Solution 1:

You can create a simple android app with a WebView component. This way you can control which URLs are loaded and also insert your JS code.

http://developer.android.com/guide/tutorials/views/hello-webview.html

EDIT
You can run any javascript like this:

Implement a custom WebView:

public class WebClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageFinished(WebView view, String url) {       
        // Execute your javascript below
        view.loadUrl("javascript:...");       
    }
}

Solution 2:

If you are looking for an automated solution, try PhantomJs this provides an automated headless web browser. Also has access to network traffic


Solution 3:

perhaps you can try "bookmarklet" http://www.bookmarklets.com/

the advantage over greasemonkey script is that it can run on firefox and explorer


Post a Comment for "Run Custom Javascript Code After Loading Any Website"