I run jQuery snippets to interact with web pages. I believe updating to El Capitan has caused my scripts to fail. Here’s the message I’m getting in the Chrome console.
Uncaught ReferenceError: $ is not defined
Of course if I type the same command in the Chrome console, everything works fine. jQuery is included on the page. I restarted my computer and it still prints this error. I also tried including jquery from KM, but it’s not having any of that. Sending pure JS commands still works though.
JavaScript in the browsers is executed via AppleScript, similarly in both Safari and Chrome. For Chrome, the AppleScript looks like this:
tell application "Google Chrome"
if it is running then
tell window 1
set r to execute active tab javascript "$('h1').css('color','red')"
if r is missing value then
set r to ""
end if
end tell
else
set r to "Not Running"
end if
end tell
r
If you run that in Script Editor you get the Uncaught ReferenceError. based on comments, it seems this is new. I checked in both Yosemite and El Capitan and got the same results (no exception is noted in Yosemite, but it doesn’t work), so I suspect this is a new behaviour in Chrome. Whether this is some sort of security feature or some sort of bug, I don’t know. That is a question the Google Chrome folks would have to answer. But until the AppleScript code above works, or there is some sort of alternative, I’m afraid accessing jQuery this way is not going to work. As to what other workarounds there might be, I’m afraid I don’t know of any.
Then have KM target Arc. Using the run JavaScript action. It works, the JS gets run in Arc, it just doesn’t work because of scope or something. My point above was just that the same thing happens if I don’t use KM, so it seems to be a browser issue.