From the Web Console, I am able to pull the following information:
window.getSelection().toString() // gets currently selected text
document.title // gets page title
document.URL // gets page URL
I would like to similarly get the selected text from within the Browser Console. From what I'm able to find from other webpages, the expression "gBrowser.selectedTab.linkedBrowser.contentDocument" should get me to the same object in the Browser Console as "document" is in the Web Console. However,
window.getSelection().toString() // returns empty string from Browser Console
gBrowser.selectedTab.linkedBrowser.contentDocument // returns null, so unable to find title or URL in here, and unable to get to window for selection
I've experimented with several permutations, trying to navigate my way to the selected text, but all have failed so far:
gBrowser.ownerDocument.getSelection().toString() // bad
gBrowser.ownerDocument.defaultView.getSelection().toString() // bad
gBrowser.getBrowserForTab(gBrowser.selectedTab).ownerDocument.defaultView.getSelection().toString() // bad
gBrowser.selectedTab.linkedBrowser.contentDocument.getSelection() // bad
document.commandDispatcher.focusedWindow.getSelection().toString() // bad
How do I get the selected text of the selected tab from within the Browser Console? Alternatively, how do I get the "window" and "document" equivalents for the selected tab from the XUL objects we're manipulating in the Browser Console? I'm not sure if this changed at all with the recent restrictions for extensions (so firefox may have changed from the webpages I'm trying to get info from)?
Thanks for any assistance