Script to open a chrome extension URL
I want to be able to create a keyboard shortcut to Dewey (a Chrome extension for bookmark management) using BetterTouchTool. BetterTouch tools allow opening urls, but if I try entering the URL "chrome-extension://aahpfefkmihhdabllidnlipghcjgpkdm/app.html#/main", it opens "file:///chrome-extension://aahpfefkmihhdabllidnlipghcjgpkdm/app.html#/main" instead. So I'd like to create a script that will launch this URL. How can I do this?
1 Answer
You can use a little trick. You already know that you can open local files using file: pseudoprotocol, so you can create a HTML file that will instantly redirect to the extension page. Save that file in some unobtrusive location and use it as a target.
Here's the HTML code that will instantly redirect to your URL when opened:
<html> <head> <meta http-equiv="refresh" content="0;URL='chrome-extension://aahpfefkmihhdabllidnlipghcjgpkdm/app.html#/main'"> </head>
</html>Paste it into any text editor and save with .html extension. Code doesn't have to be indented, you could put all that stuff in a single like but I split it to make selecting a bit more convenient.
Now you have to figure out file: URI for your HTML document. To do that, you have to prepend its absolute path with file:///.
For example if you have saved the file as /my/home/folder/chrome-redirect.html, then your URI will be file:///my/home/folder/chrome-redirect.html.
Verify if the URI works by pasting it into Chrome's address bar - you should be instantly redirected to the extension URI. If it works, then you can use it in BetterTouchTool.
(trick tested on Chrome 38 dev on Windows)
1