Due to problems with Delicious extension I recently migrated to Pinboard. The app (used via bookmarklets) is fairly nice, but I really missed ability to bookmark via Ctrl-D keyboard shortcut.
It turns out, there is a way.
First, I installed Keyconfig extension available from here.
Keyconfig allows one to map keyboard shortcuts to snippets of JavaScript code.
So I added new key for Pinboard bookmark.
The code I used is very similar to bookmarklet code, although it
needed some twist: the code runs in extension context and
location.href
is chrome://browser/content/browser.xul
, not quite a
thing I want to bookmark. Replacing it with
content.document.location
does the trick. Similarly
content.getSelection()
must be used to extract the selected text.
Here is the complete code (to be pasted in keyconfig code editor):
q=content.document.location;
if(content.getSelection) {
d=content.getSelection();
} else{
d='';
}
p=document.title;
void(open(
'https://pinboard.in/add?url='
+encodeURIComponent(q)
+'&description='
+encodeURIComponent(d)
+'&title='
+encodeURIComponent(p),
'Pinboard',
'toolbar=no,width=700,height=350'));
After saving it, I mapped Ctrl-D
as shortcut for the newly defined action
(just clicked the field left to Apply button and pressed Ctrl-D
):
That's all. Since then pressing Ctrl-D brings pinboard bookmarking window.