DIY · TechIt

Pinboard bookmarklets that work without being logged on

This is about adding bookmarks to your pinboard account (a service where you can store bookmarks, notes, etc)

More specifically, it’s about adding bookmarks to your account without logging on.

Why?

Maybe your clearing your cache/cookies etc and don’t like logging on a lot, or using a work/partners device and don’t want to be fully logged in if others have access to the device.

In that case, one may leverage the Pinboard API in conjunction with a Bookmarklet approach (because the API is nice and resty).

Whats the catch?

  • anybody who has your api key can add bookmarks to your account, tagged as they like.
  • THEY CAN ALSO LIST ALL POST S/NOTES/TAGS And RENAME and DELETE items. If you want a read-only access token, ask @Pinboard
  • rate limiting on the api may cause delays / errors ?
    • if you use the API already via another service beware the impact with rate limiting there

Using the bookmarklets

  • Replace USER_GOES_HERE:TOKEN_GOES_HERE below with username:token from https://pinboard.in/settings/password  ( *not* your Pinboard.in password! )
  • Replace the tag names (“pinboardApiBookmark,test,TAG3“) with tags of your liking.
  • Minify/uglify the javascript (and don’t lose the “javascript:” prefix !)
  • Create a bookmark and paste the code into the URL or location box for your apps bookmark feature*

*On some mobile devices (iOS I’m looking at you) it’s easier perhaps to bookmark some random page and then edit that bookmak to rename it and paste the bookmarklet code to the location field.

Now for the bookmarklets.

Here is a bookmarklet code snippet that will send the bookmark to Pinboard.in (probably in a new window).

javascript: q = location.href;
p = document.title;
open('https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url='
 +encodeURIComponent(q)+
 '&description='
 +encodeURIComponent(p)+
 '&tags=pinboardApiBookmark,test,TAG3,TAG4&replace=no&shared=no&toread=yes','_self');

You should see a response that it’s successfully added, if it doesn’t already exist 🙂

Screen Shot 2015-10-15 at 20.50.30 Screen Shot 2015-10-15 at 21.49.45

Here’s a bookmarklet that will send the request in a new window/tab, and ask that window to close after 9 seconds.

If you have selected any text on the page first, that text will be used as the “Extended Description” for the bookmark in Pinboard.

// 4. new window closing, extended description = your selection , closing after 9 secs
javascript: q = location.href;
// if any text is selected, keep it and use it as the bookmarks extended description
if (document.getSelection) {
 d = document.getSelection();
} else {
 d = '';
};
p = document.title;
void(mw = open('https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url='
 +encodeURIComponent(q)+
 '&description='
 +encodeURIComponent(p)+
 '&extended='
 +encodeURIComponent(d)+
 '&tags=pinboardApiBookmark,test,TAG3,TAG4&replace=no&shared=no&toread=yes'));
// try to close the window after 9 seconds
void(setTimeout(function() {
 mw.close()
}, 9000));

Minified Bookmarklet Samples

just replace the user/token in these and they’re good to go!

0. Opens in the current window, the document title is set as the description:

javascript:q=location.href,p=document.title,open("https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url="+encodeURIComponent(q)+"&description="+encodeURIComponent(p)+"&tags=pinboardApiBookmark,test0,TAG3,TAG4&replace=no&shared=no&toread=yes",'_self');

1. Per 0 & opens in a new window:

javascript:q=location.href,p=document.title,open("https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url="+encodeURIComponent(q)+"&description="+encodeURIComponent(p)+"&tags=pinboardApiBookmark,test1,TAG3,TAG4&replace=no&shared=no&toread=yes");

2. New win, desc=doc.title, & sets the extended description to any text you have selected on the page

javascript:q=location.href,d=document.getSelection?document.getSelection():"",p=document.title,open("https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url="+encodeURIComponent(q)+"&description="+encodeURIComponent(p)+"&extended="+encodeURIComponent(d)+"&tags=pinboardApiBookmark,test2,TAG3,TAG4&replace=no&shared=no&toread=yes");

3. New win, desc=title, & tries to close the window after 9 seconds (so you don’t get feedback if it’s failed for some reason)

javascript:q=location.href,p=document.title,void(mw=open("https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url="+encodeURIComponent(q)+"&description="+encodeURIComponent(p)+"&tags=pinboardApiBookmark,test3,TAG3,TAG4&replace=no&shared=no&toread=yes")),void setTimeout(function(){mw.close()},9e3);

4. New win, desc=doc.title, extendedDescription = any selected text & tries to close the window after 9 seconds.

javascript:q=location.href,d=document.getSelection?document.getSelection():"",p=document.title,void(mw=open("https://api.pinboard.in/v1/posts/add?auth_token=USER_GOES_HERE:TOKEN_GOES_HERE&url="+encodeURIComponent(q)+"&description="+encodeURIComponent(p)+"&extended="+encodeURIComponent(d)+"&tags=pinboardApiBookmark,test4,TAG3,TAG4&replace=no&shared=no&toread=yes")),void setTimeout(function(){mw.close()},9e3);

That’s it!

If you’ve made it this far, you might also like A Inboard sharing button for WordPress

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s