View this post on Hive: Keychainify on direct access to a SteemConnect URL
Repository & PR
Last week I described Keychainify, a feature I added to Steem Keychain to trigger a Keychain operation on click on a Steem Connect link on a page. But that would not work if the user copied and pasted the Steem Connect URL and loaded it directly in a browser tab or in cases such as the page using some programmatic way to redirect the user. Well, today's PR should solve the issue.
Previously, the Keychain extension was injecting what we call a
content script into the source code of loaded page. That content script is what parses the source for Steem Connect anchor tags. For a direct access to be detected, I needed to modify the
background script which is always running during the lifetime of a browser.
As the content script and background scripts are going to share common logic, I ended up creating a Keychainify library to avoid code duplication.
In the background script, the core of the changes is this block of code:
What is does is create an event handler to be triggered every time a browser tab is getting update (change of URL). It would then grab the new URL and Keychainify it if it is a supported Steem Connect URL.
All the rest in the PR is just code refactor and re-organisation.