I'm trying to write my first OS X script using JavaScript instead of AppleScript, and am running into some issues. The first part of this is to get the URL from a tab in Chrome, so that I can do some more work on it (e.g., create a new reading list item in safari). I've tried the following code:
var safari = Application('Safari');
var chrome = Application('Google Chrome');
chrome.activate();
var url = chrome.windows[0].tabs[0].get('url'); // This returns an ObjectSpecifier
safari.addReadingListItem(url, {andPreviewText: 'Added from Chrome'});
This fails, with error: "Error -1700: Can't convert types." I need a string, but this is still an Object specifier. So I guess I don't get a string back from .get('url')
I haven't had any luck finding examples of pulling values FROM the scripting environment, but I've seen a few about putting new tabs into a browser. Any help with this is appreciated!