Skip to content

Instantly share code, notes, and snippets.

@sasajib
Forked from Splaktar/Firebug.java
Created June 27, 2016 05:20
Show Gist options
  • Save sasajib/58d31c8cf7b42dc5c3ba4641b832eae0 to your computer and use it in GitHub Desktop.
Save sasajib/58d31c8cf7b42dc5c3ba4641b832eae0 to your computer and use it in GitHub Desktop.
Enable Firebug Lite in a JavaFX WebView.
if (isDebugging())
engine.documentProperty().addListener(new ChangeListener<Document>() {
@Override
public void changed(ObservableValue<? extends Document> prop,
Document oldDoc, Document newDoc) {
enableFirebug(engine);
}
});
/**
* Enables Firebug Lite for debugging a webEngine.
* @param engine the webEngine for which debugging is to be enabled.
*/
private static void enableFirebug(final WebEngine engine) {
engine.executeScript("if (!document.getElementById('FirebugLite')){E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;E = E ? document['createElement' + 'NS'](E, 'script') : document['createElement']('script');E['setAttribute']('id', 'FirebugLite');E['setAttribute']('src', 'https://getfirebug.com/' + 'firebug-lite.js' + '#startOpened');E['setAttribute']('FirebugLite', '4');(document['getElementsByTagName']('head')[0] || document['getElementsByTagName']('body')[0]).appendChild(E);E = new Image;E['setAttribute']('src', 'https://getfirebug.com/' + '#startOpened');}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment