Created
May 7, 2013 13:35
particular-pinboard for Pinner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){var e=false;var t="pinner://x-callback-url/bookmark?";var r=false;var n={javascript:"javascript",js:"javascript",python:"python",ios:"ios",youtube:"video",vimeo:"video",video:"video",books:"book",book:"book"};var o={"github.com":".entry-title .js-current-repository"};var i={"www.kickstarter.com":".short-blurb"};var a=function(e){return e.toLowerCase()};var c=function(e){return e?e.textContent.trim().replace(/\s+/g," "):null};var u=a(document.title);var l=function(e){if(e){return u.indexOf(a(e))!=-1}else{return false}};var f=function(e,t,r){r=r||window;var n=e.length;var o;for(var i=0;i<n;++i){o=t.call(r,e.item(i));if(o!==null){return o}}return null};var v=function(){var e=location.href;var t=location.hostname;var r;if(t in o){r=document.querySelector(o[t]);if(r){return c(r)}}var n=document.title;var r=document.querySelector("meta[property='og:title']");if(r){n=r.content.trim().replace(/\s+/g," ")}var i,a;if(f(document.getElementsByClassName("hentry"),function(e){return true})){var u=document.querySelector(".hentry .entry-title");if(u){return c(u)}}var v=f(document.getElementsByTagName("A"),function(t){if(t.href==e){v=c(t);if(l(v)){return v}}return null});if(v){return v}var s=["h1","h2","h3","h4","h5","h6"];var m;var d;for(var h=0;h<s.length;++h){f(document.getElementsByTagName(s[h]),function(e){h_text=c(e);if(l(h_text)&&(!d||h_text.length>d.length)){d=h_text}return null})}if(d){return d}return n};var s=function(e){e=a(e);var t=[];var r;for(keyword in n){r=keyword instanceof RegExp?keyword:new RegExp("\\b"+keyword+"\\b","i");if(r.test(e)){t.push(n[keyword])}}return t};var m=function(){var e;e=document.querySelector("meta[name='description']");if(e){return e.content.trim().replace(/\s+/g," ")}e=document.querySelector("meta[property='og:description']");if(e){return e.content.trim().replace(/\s+/g," ")}return""};var d=function(){var e;if(""!==(e=String(document.getSelection()))){if(r){e=e.trim().split("\n").map(function(e){return"> "+e}).join("\n")}}var t=location.hostname;var n;if(t in i){n=document.querySelector(i[t]);if(n){return c(n)}}if(!e){e=m()}return e};var h=location.href;var p=v();var g=d();var y=g.indexOf(p);if(y==0){g=g.substring(p.length).trim()}else if(y==g.length-p.length){g=g.substring(0,y).trim()}var b=["href=",encodeURIComponent(location.href),"&title=",encodeURIComponent(p),"&extended=",encodeURIComponent(g),"&tags=",encodeURIComponent(s(document.title+" "+g+" "+m()).join(" "))];if(e){if(t){b=b.concat(["&toread=","1"])}else{b=b.concat(["&later=","yes","&jump=","close"])}}if(t){b=b.concat(["&x-source=Safari","&x-success=",encodeURIComponent(location.href),"&x-cancel=",encodeURIComponent(location.href)]);window.location=t+b.join("")}else{var w=open("http://pinboard.in/add?"+b.join(""),"Pinboard","toolbar=no,width=610,height=350");if(e){w.blur()}}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment