take the contents of the clipboard (usually a single word)
query an online dictionary to grab the definitions of the word
run JavaScript code on the result of the Get Contents of URL GET request to parse the JSON result for certain values.
Display the parsed values.
When I get to the step of running the JS code on the webpage results, I get an error message, “run JavaScript on Active Safari Tab failed because Shortcuts couldn’t convert from Text to Safari web page.” I am not sure why - the result returned from the web page looks like plain text in JSON format. Any suggestions on what I need to do?
I’m not great with javascript, but I think you are using the wrong action. The “Run JavaScript on Active Safari Tab” is expecting a safari web page as the input. You are probably wanting the action “Run JavaScript for Mac Automation.” If your script doesn’t work becuase it is JXA, there are third party apps that can run javascript. Actions app (free), BetterTouchTool, Keyboard Maestro are just a few. Hope that helps!
Thank you for pointing that out. I have tried to implement this one as a test, but it doesn’t seem to work for me. What am I doing wrong? I think the part that generates the URL with JavaScript isn’t working properly, or isn’t grabbing my JSON properly.
However, I’m trying to take it one step further and grab values what is a very complex nested JSON. I am trying to grab values under the “items” array of “WORD” below. However, some of the values are in nested arrays. I have managed to grab what I want under items, but can’t grab the values under nested.
What I want is:
rank
expEntry
meansCollector.means.value
meansCollector.expAliasEntryAlwaysList.originLanguageValue