Run JavaScript on Web Page Help

I found an amazing shortcut the other day and I can’t remember if it was on here or somewhere else. The shortcut used the “Run JavaScript on Web Page” to pull some recipe information and then “Get Dictionary from Input” and “Get Dictionary Value” to translate into the Notes app and Reminders. It was really cool and motivated to pull other information from sites, but I eventually got stuck.

I have been working on a similar one but the information I am trying to grab is not in a script with all the JSON we need. The information is located in a <input type=“hidden” id=“helpme” value="{this is the stuff I am trying to grab}

I understand this is my total lack of understanding javascript but am proud that I found the specific data on the site using web inspector :slight_smile:

Would love a link to the shortcut you found if you have it.

Try this

var element_value = document.getElementById("helpme").value
completion({ value: element_value })

Minimalist Baker Recipe Shortcut Thingymajig

All I got was a link in a note when I tried creating a new note to see what I got. Do I have to define it more with the specific div or class or text I’m looking for?

Yes, you have to define what you want to put in there. Shortcut Input is basically a URL, not the whole page.

Gotcha. So the dictionary value should be named the specific thing I want to grab?

well if you just need the recipes and instructions, both of those are already in the RecipeJson. You can grab those and insert to your note.

For some context, this was the original topic I think you’re looking for:

1 Like

The information I’m trying to get I believe is not in a script or JSON. It is under this value in “<input type= “hidden” id=“helpme” value={this is what I’m trying to grab}

In that case the earlier answer should work. Use the code @supermamon gave you :slight_smile:

Have you tried it? If so, did it give an error, or somehow failed? It seems correct to me…

Here’s a very simple example you can use to test as an actual shortcut. (Just replace the “helpme” id)

It worked!!! You guys are amazing. Now all I need to do is use the dictionary commands to get the specific information I need correct? In all seriousness this forum is the most amazing thing ever.

Since you only asked about one value, my example doesn’t use a dictionary. It just returns the value and you can use it.

Unless we know the rest of your shortcut, I can’t say if you need dictionary actions.

I’m happy to help out with automation where I can.

Two things:

  1. In general I’d rather do this in public so that A) we can all learn from it and B) other people can suggest things I can do better (which, believe me, is most of 'em)
  2. “Work with you” is a bit vague in this context. Well, feel free to PM me to expand on that, but keep #1 in mind for why I’ll probably decide to keep things in public :wink:

Totally understand. After I get the quick view now I can see what “key:values” I need to get. So I am trying to figure out how to grab that information and put it into a calendar event.