Easy Method to Incorporate JavaScript in Shortcuts

Hi there! I discovered a simple method to execute JavaScript code within a shortcut, which can be handy for executing complex tasks. It utilizes the Shortcuts app and is quite concise. Have fun with it! Here’s how you can utilize it, just refer to the example image.

I’ve experimented with integrating JavaScript into Shortcuts for managing daily automation tasks. What I’ve found effective is leveraging the “Run JavaScript on Webpage” action. This allows for direct execution of JS on any web page you’ve loaded in Safari. What’s nice about this is the flexibility—it supports more complex scripts and even handles conditional logic. However, always ensure that the script is secure and that you’re aware of the webpage’s behavior, as interacting with web elements can be quite sensitive.