Jump to content

zuchmir

Member
  • Content Count

    6
  • Joined

  • Last visited

  1. Bingo! Worked perfect! I didn't see that console.log had been making problems whenever had worked. What I didn't know was that: Even though in the dictionary the name property is explicitly defined as "title", byName() still works; that parentheses are required to access the URL - bookmark.url( ) . Why should parentheses be necessary? Anyways, regardless of the "why", works like a charm. Thanks!
  2. Do you mean to say that the code you posted before did in fact work by you? JXA does work, before executing Javascript from an Applescript (or JXA for that matter) I had to authorize it (View > Developer > Allow JavaScript from Apple Events), only the bookmarks makes problems. If that exact code worked for you, that would be truly interesting. This is the closest I've gotten to anything. Invoking the app object's bookmarkFolders.title() yields an array with the names of both top-level bookmark folders. What to make of that, I'm not sure...
  3. So a couple things. Firstly, even if this had worked, wouldn't be of much help - I'd need to be working on identifying the ID of individual folders and bookmarks. At that point, I may as well hardcode the URL right into the script. In any event, even this didn't work. Because the AppleScript does work, swimmingly, I could easily find the id of the particular bookmark I am working with, and tried it out in JXA. Didn't get me far: Same when I tried var BMI = BMF.bookmarkItem.byId(457) It's definitely a Chrome issue. Possibly because the name of the bookmark is implemented not as name but as title, which gets no special treatment in JXA as name and id do?
  4. @CJK I don't know of having more than one Google Chrome. I just ran the code you suggested, and the result appears to be substantially identical.
  5. Yep, tried that, doesn't work. Here's what I get: Splitting the action into 2 - first getting the folder, then the bookmark item - changed little: Finally, trying to log the title (or id) of either the folder or the item, yielded the same error: A couple of observations: 1. The script doesn't go off track until the object is accessed, either with console.log or when trying to use the URL property. 2. Changing the name of the folder to gibberish changed nothing. Thanks all again!
  6. Hi all! First post here. A workflow of mine involves having a script launch a bookmarklet in Google Chrome. I can, it is true, put the JS code to be executed directly into my script, but that means changing my code in 2 places every time I change something. So with Applescript, opening a bookmark in Chrome is trivial: tell application "Google Chrome" if not (exists window 1) then reopen set coef to URL of bookmark item "Coef" of bookmark folder "Bookmarks Bar" open location coef end tell But when trying this in JXA, everything goes to hell. I've tried countless variations on the following code, var app = Application('com.google.Chrome') var frontWindow = app.windows[0] var myBM = app.bookmarkFolders.whose({title: "Bookmarks Bar"}) var myBM = app.bookmarkFolders["Bookmarks Bar"] var myBM = app.bookmarkFolders.title("Bookmarks Bar") //etc ad nauseam and cannot for the life of me get a handle on a bookmark folder, let alone a bookmark item. bookmarkFolder vs. bookmarkFolders, nothing helped. The last line actually got me an array with the names of the two top-level folders, but that's the closest I got to anything. Anybody has an idea how this gets done? Thanks!
×
×
  • Create New...