On Sunday, I posted about my geeky solution to my non-functional Stocks Dashboard widget in Mojave. Then earlier today, I crafted a way to view one of the tracked stock's charts with a mouse click.
A commenter asked if there were any way to view the charts using a built-in tool, as purchasing Keyboard Maestro for just this one task is expensive (and a waste of Keyboard Maestro's capabilities). And in reality, when I first started working on my solution, I started in Automator…but quickly grew frustrated by its inability to do even basic text manipulation.
But then today, I remembered I can use AppleScript in Automator to work with the text, and the solution came together quickly after that: A new Service that appears when you right-click on text in a Terminal window:
To use this, download the action, unzip it, and then double-click the unzipped file. You should be prompted to install the workflow:
And if you want to use e-Trade to display your charts, that's all you'll need to do. If you'd rather use another service, though, you'll have to edit the action. Open Automator, find the action in your user's Library > Services folder, and then drag it onto Automator's Dock icon.
The workflow should open, and it will look like this:
You'll need to edit the AppleScript line that begins set theURL to. Start by visiting your charting site in a browser, and loading any stock's chart. Now copy the URL, and put it in TextEdit or some other text editor. Here's an example of a URL from barchart.com:
You need to convert this into a combination of string and variables that AppleScript will recognize—any reference to the ticker symbol needs to be replaced with (input as text), but that cannot appear with "normal" text, so you need to structure it like this:
"https://www.barchart.com/stocks/quotes/" & (input as text) & "/overview"
Once you've edited the URL as above, copy it, and then paste it into the workflow, replacing everything after "set the URL to " (leave the trailing space). The final line would look like this:
set theURL to "https://www.barchart.com/stocks/quotes/" & (input as text) & "/overview"
Save the script, and now you should see charts from the site you put into the workflow.
This is a bit more time consuming to use than the Keyboard Maestro version, but it works well, and doesn't rely on any non-bundled apps.