I have a bookmark that runs some JavaScript code on the website the user has open at the time of running the bookmark - I'm aware there is a way using AppleScript to execute JavaScript on a Safari page but this requires 'Allow JavaScript from Apple Events' which I'm trying to avoid.
I'd like the script to ask for the user to enter a url, it will then open a new window with this page and then it will click the bookmark which will itself run some JavaScript on the open page.
So far, by looking at existing posts here on StackExchange, I've been able to get it to open bookmarks in different tabs, but I'm struggling to amend it to open a specific named bookmark on the page the script has opened.
Would appreciate any help anyone can give!
EDIT 1: The code that I'm amending from: In Safari, can a set of bookmarks in a folder be opened programmatically (e.g. using AppleScript)?
EDIT 2: Here's my latest code revision:
@user3439894 I've changed my code to
tell application "Safari" to activate
delay 1
tell application "System Events" to ¬
click menu item "Google" of ¬
application process "Safari"
with there being a bookmark titled 'Google' - I wasn't sure whether to keep the line 'application process "Safari"' or not, but whether its kept in or removed I get "Can't get menu item 'Google' of application process 'Safari'"
Open in New Tabs
inclick menu item "Open in New Tabs" of ¬
to the name of the target bookmark, or use the index value, e.g.1
or whatever number it is in the list of thebookmarksFolder
menu to have it click that bookmark.