Firefox: Advance one to Tools > Page Info > Media

I suppose I could use System Events to achieve what I am after, but maybe somebody else knows of a better scriptable method? In short, we often need to view images on a website, and Firefox’s “Media” tab found in the active URL’s Menu Bar > Tools > Page Info is excellent for this task. With that being said, is there a scriptable method to quickly advance to this “Media” tab?

Any menubar item that doesn’t have a keyboard shortcut could be assigned in ‘keyboard’ pane in system preference. Its a application keyboard shortcuts. In other words pick the Firefox app and type the *exact name you see in the menubar and assign a custom keyboard shortcut.

Thank you Fredrik. Unfortunately, the “Media” tab on the Page Info window is not a Menu Bar item, and it also does not appear to be accessible via pressing tab.


I am not sure if I explained the automation I am seeking that well. What I am looking for is a scripting method that does the following:
Assume one has a website open in Firefox - The script will replicate the manual steps required for an end user to click on Menu Bar > Tools > “Page Info”. Then, with the “Page Info” window open, the script would target/focus the “Media” tab at the top the “Page Info” window.
What I would really like to do is incorporate this script into Chrome: When the script is executed, it would launch Firefox and use the same URL and evenutually end with the “Media” tab open in Firefox. This is not a major “want” item - I just thought it would be cool for an end user to not have to worry about pasting a URL into Firefox and then know to access Tools>Page Info>Media - Be pretty cool to have this all automated.

In Firefox, ⌘-i will open the page info window and then a right arrow click will activate the media tab. Pressing tab will then move control to the list of media items. Note that you have to wait a moment for the media tab to appear and populate.

FWIW, firefox is stubbornly anti-applescript.

You might try something like this. I don’t use chrome but it should be straightforward to get the page url and copy it to the clipboard. Until you figure that out, you can just set the chromUrl var to a valid URL.

You can play around with the delays so they suit your systems. Basically, once the clipboard has the url, the script opens a new window in firefox, activates the address bar, selects whatever text might be there already and then pastes and returns to go to the page.

Once the page loads (hopefully), it opens the Page Info window, waits, activates the media tab and then tabs into the media list. It’s ugly but it should work most of the time.

set chromUrl to "whateverinternetaddress"
set the clipboard to chromUrl

tell application "Firefox Nightly"
	tell application "System Events" to tell process "Firefox"
		key code 45 using command down -- ⌘-n new window
		delay 1 -- window needs to be open
		key code 37 using command down -- ⌘-l url address bar
		delay 0.5
		key code 0 using command down -- ⌘-a select whatever is in address field
		key code 9 using command down -- ⌘-v paste
		key code 76 -- return
		delay 1
		key code 34 using command down -- ⌘-i
		delay 4 -- wait for page to at least mostly load
		key code 124 -- right-arrow
		key code 48 -- tab
	end tell
end tell

Initially I wanted to stay away from using System Events. But at the end of the day who cares, this works very nicely - so thank you! To be honest, I completely overlooked using “right arrow”. I was under the impression that the “Media” tab was unselectable other than clicking it with the cursor :frowning:
Thank you once again!

Glad it solves your problem. I usually think that ui scripting creates more problems than it solves but sometimes it’s all there is.