using 'do Javascript' in an applescript for osx Fluid App

242 Views Asked by At

I'm running fluid app 1.8.5 on El capitan, and I have it running a very simple web page. I'm trying to pull the contents of a div on the page using an applescript, but can't seem to get it working. the fluidapp changelog specifically states that they have applescript support, including 'do Javascript'

If I open the same page in a safari window, this works as expected:

if application "Safari" is running then
    tell application "Safari"
        tell document 1
            set song to do JavaScript "document.getElementById('now-playing-title').innerHTML"
            return song
        end tell
    end tell
end if

However, If I change the application to the name of my fluid app (testApp, for our purposes,) it does not work. I know it is correctly targeting the app, because if I do the following, it correctly brings the fluid app to focus.

if application "testApp" is running then
    tell application "testApp"
        activate
    end tell
end if

I understand that maybe fluidapp does not have the notion of a document like safari does, so I've also tried this to no avail:

if application "104.9" is running then
    tell application "104.9"
        set song to do JavaScript "document.getElementById('now-playing-title').innerHTML"
        return song
    end tell
end if
0

There are 0 best solutions below