JavaScript working in Safari and else does not work in DevonAgent

This works:

tell document 1 of application "Safari"	
	set myLinks to do JavaScript "
			var myLinks = new Array();
			for (var i=0; i<document.images.length; i++){
				myLinks.push(document.images[i].src)
			}
			myLinks;
	" 
end tell

This should work, but does not:

tell application "DEVONagent"	
	set myLinks to do JavaScript "
			var myLinks = new Array();
			for (var i=0; i<document.images.length; i++){
				myLinks.push(document.images[i].src)
			}
			myLinks;
	" in browser 1
end tell

Why?
On the surface it looks that I am doing something fundamentally wrong, but I have no idea what it is…

Welcome @pete22

The functionality you appear to be looking for is already provided in DEVONagent’s AppleScript dictionary…

tell application id "DNag"
	tell browser 1
		set src to source of current tab -- Get the source markup of the current page
		set img to (get embedded images of src base URL (URL)) -- Get the image URLs from the source
	end tell
    return img
end tell

Development would have to assess the do JavaScript command’s behavior as it appears to not be functional right now.

Sorry, but I am not looking for a functionality. This is just a trivial example working for almost any URL.
My intention was to point out that DevonAgent’s do javascript is severly flawed.
The more experimenting I do the more I get the impression that the AppleScript implementation is unable to return javascript arrays as AppleScript lists. Even text would do, but all you get is empty results. This would mean that stuff like getElementsByClassName can not be used at all with DevonAgent.
And it’s really annoying that this does not seem to be documented anywhere and you have to rely on experimenting to find out.

OK, here is a workaround which should work:

on string2List(theString)
	set oldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {","}
	set theList to text items of theString as list
	set AppleScript's text item delimiters to oldDelim
	return theList
end string2List

tell application "DEVONagent"
	set myLinks to do JavaScript "
			var myLinks = new Array();
			for (var i=0; i<document.images.length; i++){
				myLinks.push(document.images[i].src)
			}
			myLinks.toString();
	" in browser 1
end tell

set myLinks to string2List(myLinks)

I can only hope for the moment that javascript’s toString() is intelligent enough to escape strings containing commas…
So this should make getElementsByClassName usable, even it’s probably not foolproof or elegant.

Anyway, this seems to prove that DevonAgent’s do javascript implementation is unable to return AppleScript lists.

But, if I can make it work somehow, how much more should Devon Technolgies be able to do it properly…

Could you please edit your post to use code fences like so
```
code goes here
```

Ah, OK. Thanks for the pointer! Done.

DEVONagent actually just returns the value returned by the WebKit and that’s always a string unfortunately.