It’s bookmarklet week y’all. I said so, in case you’re wondering why.
I EFFING SAID SO.
Recently, Tumblr added the ability to “pin” posts to the top of user dashboards for more exposure.

They’re not too intrusive and, if you follow cool people, you probably won’t get any uncool posts pinned to the top of your dashboard. If there are a dozen pinned posts, though, it does kind of annoying having to click each of those little red pins.
~*I wonder if I can make a bookmarklet that unpins all of them at once*~
Why yes, dream sequence Jenn, you can. Here is how:
There are two steps to the algorithm:
1. Get all items that have “pins”.
2. Automagically “click” them so they become unpinned.
If you investigate the source code of your dashboard, either through your browser or developer tools, you will see that the “pins” to click class of “pin”. We can use JavaScript to grab all of document objects with the class name “pin” and then use the click() function to trigger a click event on these objects – which, in this case, make them disappear.
Here is the code:
Edit: (7/20/2012) The day after I published this, the code stopped working. Hmmmm. Anyway, I’ve updated the code now to include MouseEvents that should make this cross-browser friendly. xoxo j
// create array and fill it with all "pin" posts var pinArray = document.getElementsByClassName("pin"); // create a click event var pinClick = document.createEvent("MouseEvents"); pinClick.initMouseEvent("click"); // for each pin post, trigger that click event for(var i=0; i<pinArray.length; i++) { pinArray[i].dispatchEvent(pinClick); } |
So now, I will put this code in my base bookmarklet code:
javascript:(function(){ // create array and fill it with all "pin" posts var pinArray = document.getElementsByClassName("pin"); // create a click event var pinClick = document.createEvent("MouseEvents"); pinClick.initMouseEvent("click"); // for each pin post, trigger that click event for(var i=0; i<pinArray.length; i++) { pinArray[i].dispatchEvent(pinClick); } })(); |
Then I shall minify this code – remove the comments (lines that begin with //) and remove extra whitespace – and this is the code I pop into the bookmark I add to my browser:
javascript:(function(){var pinArray = document.getElementsByClassName("pin");var pinClick = document.createEvent("MouseEvents");pinClick.initMouseEvent("click");for(var i=0; i<pinArray.length; i++) {pinArray[i].dispatchEvent(pinClick);}})(); |
Now whenever there are a gazillion pinned Tumblr posts, you can unpin them all at once with one click of the bookmarklet.
Boom shakalaka.








