Wednesday, March 19, 2014; 1:28:14 AM Eastern
How I did the bookmarklet
- I just posted a link to the test version of Fargo 1.51 which has support for linkblogging, and support for the bookmarklet that we discussed on Scripting News last week.
- Now that it's out there I can show you how I did it.
- #### The intermediate app
- The trick is this -- the bookmarklet calls an app running in a web page on fargo.io.
- This is where the app is: http://fargo.io/misc/bookmarklet/.
- Here's a screen shot of the source of the app.
- Because that app comes from the same domain as the Fargo app, when they're running on your machine they share a local storage namespace.
- The app writes the query string to localStorage.fargoSearchString, and it quits.
- Once a second, Fargo looks for localStorage.fargoSearchString. When it shows up, it copies it, deletes it, and then parses it, and adds the link to the designated linkblog outline.
- #### Why it works
- We just communicated with a running app without having to relaunch it. Which of course with a major piece of software like Fargo is a fairly big deal -- far too much work to do for a single link. But the intermediate app is just a few lines of text. No big deal loading it just to send a message to Fargo.