-
-
Save jhjwind/c25be1993fc2e17c48c5e51aa341b6be to your computer and use it in GitHub Desktop.
Get Pocket Bookmarklet
This file contains 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
// The Bookmarklet | |
javascript: (function() % | |
7BISRIL_H = '8e7a'; | |
PKT_D = 'getpocket.com'; | |
ISRIL_SCRIPT = document.createElement('SCRIPT'); | |
ISRIL_SCRIPT.type = 'text/javascript'; | |
ISRIL_SCRIPT.src = 'http://' + PKT_D + '/b/r.js'; | |
document.getElementsByTagName('head') % 5B0 % 5D.appendChild(ISRIL_SCRIPT) % 7D)(); | |
if (thePKT_BM) thePKT_BM.save(); | |
else { | |
try { | |
if (ISRIL_H) {}; | |
} catch(e) { | |
ISRIL_H = 0 | |
} | |
try { | |
if (ISRIL_TEST) {}; | |
} catch(e) { | |
ISRIL_TEST = false | |
} | |
try { | |
if (PKT_D) {}; | |
} catch(e) { | |
PKT_D = "getpocket.com" | |
} | |
var PKT_BM_OVERLAY = function(a) { | |
this.inited = false; | |
this.saveTagsCallback = a.saveTagsCallback | |
}; | |
PKT_BM_OVERLAY.prototype = { | |
create: function() { | |
var a = document.getElementById("PKT_BM_STYLE"); | |
if (a) a.parentNode.removeChild(a); | |
var b = document.getElementById("PKT_BM_OVERLAY"); | |
if (b) b.parentNode.removeChild(b); | |
var c = window.innerWidth / screen.availWidth; | |
if (c < 1) c = 1; | |
var d = window.navigator.userAgent; | |
this.isMobile = d.match(/iPad/i) || d.match(/iPhone/i); | |
var e = (this.isMobile ? 60: 80) * c; | |
var f = (this.isMobile ? 18: 20) * c; | |
var g = this.isMobile ? e * .95: e; | |
var h = this.isMobile ? "normal": "bold"; | |
var i = 6 * c; | |
var j = 80 * c; | |
var k = 30 * c; | |
var l = 30 * c; | |
var m = 1 * c; | |
if (m < 1) m = 1; | |
var n = 17 * c; | |
var o = 25 * c; | |
var p = 15 * c; | |
this.shadowHeight = 20; | |
var q = "\n\t\t\t#PKT_BM_OVERLAY\n\t\t\t{\n\t\t\t\tvisibility:hidden;\n\t\t\t\tposition:fixed;\n\t\t\t\ttop:0px;\n\t\t\t\tleft:0px;\n\t\t\t\twidth:100%;\n\t\t\t\theight:" + e + "px;\n\t\t\t\t-webkit-box-shadow:0px 0px " + this.shadowHeight + "px rgba(0,0,0,0.4);\n\t\t\t\t-moz-box-shadow:0px 0px " + this.shadowHeight + "px rgba(0,0,0,0.4);\n\t\t\t\t-o-box-shadow:0px 0px " + this.shadowHeight + "px rgba(0,0,0,0.4);\n\t\t\t\tbox-shadow:0px 0px " + this.shadowHeight + "px rgba(0,0,0,0.4);\n\t\t\t\tz-index:999999999;\n\t\t\t\tbackground: rgb(239,239,239);\n\t\t\t\tbackground: -moz-linear-gradient(top, rgba(239,239,239,0.98) 0%, rgba(253,253,253,0.98) 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(239,239,239,0.98)), color-stop(100%,rgba(253,253,253,0.98)));\n\t\t\t\tbackground: -webkit-linear-gradient(top, rgba(239,239,239,0.98) 0%,rgba(253,253,253,0.98) 100%);\n\t\t\t\tbackground: -o-linear-gradient(top, rgba(239,239,239,0.98) 0%,rgba(253,253,253,0.98) 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top, rgba(239,239,239,0.98) 0%,rgba(253,253,253,0.98) 100%);\n\t\t\t\tbackground: linear-gradient(top, rgba(239,239,239,0.98) 0%,rgba(253,253,253,0.98) 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efefef', endColorstr='#fdfdfd',GradientType=0 );\n\t\t\t\tborder-bottom:1px solid white;\n\t\t\t\tfont-size:" + f + "px !important;\n\t\t\t\tfont-family:HelveticaNeue,Helvetica,Arial !important;\n\t\t\t\tline-height:" + g + "px !important;\n\t\t\t\ttext-align: left;\n\t\t\t\tcolor: #4b4b4b !important;\n\t\t\t\t-webkit-transform:translate3d(0px,0px,0px);\n\t\t\t}\n\t\t\t\n\t\t\t#PKT_BM_RAINBOWDASH\n\t\t\t{\n\t\t\t\twidth: 100%;\n\t\t\t\theight: 6%;\n\t\t\t}\n\t\t\t\n\t\t\t#PKT_BM_RAINBOWDASH div\n\t\t\t{\n\t\t\t\tfloat: left;\n\t\t\t\twidth: 25%;\n\t\t\t\theight: 100%;\n\t\t\t}\n\t\t\t\n\t\t\t#PKT_BM_OVERLAY_LOGO\n\t\t\t{\n\t\t\t\tdisplay: block;\n\t\t\t\twidth: 200px;\n\t\t\t\theight: 100%;\n\t\t\t\ttext-indent: -789em;\n\t\t\t\tbackground: url(http://" + PKT_D + "/i/v3/pocket_logo.png) left center no-repeat;\n\t\t\t}\n\t\t\t.PKT_mobile #PKT_BM_OVERLAY_LOGO\n\t\t\t{\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t\t.PKT_desktop #PKT_BM_OVERLAY_LABEL\n\t\t\t{\n\t\t\t\tposition: absolute;\n\t\t\t\ttop: 0px;\n\t\t\t\tleft: 0px;\n\t\t\t\ttext-align:center;\n\t\t\t\twidth: 100%;\n\t\t\t\tpadding: 0px;\n\t\t\t\tfont-weight: " + h + ";\n\t\t\t}\n\t\t\t\n\t\t\t#PKT_BM_OVERLAY_WRAPPER\n\t\t\t{\n\t\t\t\tpadding-left:7%;\n\t\t\t}\n\t\t\t\n\t\t\t.PKT_BM_BTN\n\t\t\t{\n\t\t\t\tposition:absolute;\n\t\t\t\ttop:" + (this.isMobile ? "25%": "30%;") + ";\n\t\t\t\tright:7%;\n\t\t\t\twidth: " + j + "px;\n\t\t\t\theight: " + k + "px;\n\t\t\t\tline-height: " + l + "px;\n\t\t\t\tvisibility:hidden;\n\t\t\t\tborder:" + m + "px solid #a4a4a4;\n\t\t\t\ttext-shadow: 0px " + m + "px 0px rgba(255, 255, 255, 0.7);\n\t\t\t\t-webkit-box-shadow: 0px " + m + "px 0px white;\n\t\t\t\t-moz-box-shadow: 0px " + m + "px 0px white;\n\t\t\t\t-o-box-shadow: 0px " + m + "px 0px white;\n\t\t\t\tbox-shadow: 0px " + m + "px 0px white;\n\t\t\t\t-webkit-border-radius: " + i + "px;\n\t\t\t\t-moz-border-radius: " + i + "px;\n\t\t\t\t-o-border-radius: " + i + "px;\n\t\t\t\tborder-radius: " + i + "px;\n\t\t\t\ttext-align:center !important;\n\t\t\t\tfont-size:0.7em !important;\n\t\t\t\tcolor:black !important;\n\t\t\t\tfont-weight:bold !important;\n\t\t\t\tbackground: rgb(250,213,64);\n\t\t\t\tbackground: -moz-linear-gradient(top, rgba(250,213,64,1) 0%, rgba(251,182,74,1) 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(250,213,64,1)), color-stop(100%,rgba(251,182,74,1)));\n\t\t\t\tbackground: -webkit-linear-gradient(top, rgba(250,213,64,1) 0%,rgba(251,182,74,1) 100%);\n\t\t\t\tbackground: -o-linear-gradient(top, rgba(250,213,64,1) 0%,rgba(251,182,74,1) 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top, rgba(250,213,64,1) 0%,rgba(251,182,74,1) 100%);\n\t\t\t\tbackground: linear-gradient(top, rgba(250,213,64,1) 0%,rgba(251,182,74,1) 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fad540', endColorstr='#fbb64a',GradientType=0 );\n\t\t\t\ttext-decoration: none !important;\n\t\t\t\t-moz-transform:translate3d(0px,0px,0px);\n\t\t\t\t-o-transform:translate3d(0px,0px,0px);\n\t\t\t\t-webkit-transform:translate3d(0px,0px,0px);\n\t\t\t}\n\t\t\t.PKT_BM_BTN:hover\n\t\t\t{\n\t\t\t\tbackground: rgb(251,182,74);\n\t\t\t\tbackground: -moz-linear-gradient(top, rgba(251,182,74,1) 0%, rgba(250,213,64,1) 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(251,182,74,1)), color-stop(100%,rgba(250,213,64,1)));\n\t\t\t\tbackground: -webkit-linear-gradient(top, rgba(251,182,74,1) 0%,rgba(250,213,64,1) 100%);\n\t\t\t\tbackground: -o-linear-gradient(top, rgba(251,182,74,1) 0%,rgba(250,213,64,1) 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top, rgba(251,182,74,1) 0%,rgba(250,213,64,1) 100%);\n\t\t\t\tbackground: linear-gradient(top, rgba(251,182,74,1) 0%,rgba(250,213,64,1) 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fbb64a', endColorstr='#fad540',GradientType=0 );\n\t\t\t}\n\t\t\t.PKT_BM_BTN.gray\n\t\t\t{\n\t\t\t\tbackground: #f9f9f9;\n\t\t\t\tbackground: -moz-linear-gradient(top, #f9f9f9 0%, #ebecec 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f9f9f9), color-stop(100%,#ebecec));\n\t\t\t\tbackground: -webkit-linear-gradient(top, #f9f9f9 0%,#ebecec 100%);\n\t\t\t\tbackground: -o-linear-gradient(top, #f9f9f9 0%,#ebecec 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top, #f9f9f9 0%,#ebecec 100%);\n\t\t\t\tbackground: linear-gradient(top, #f9f9f9 0%,#ebecec 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f9f9f9', endColorstr='#ebecec',GradientType=0 );\n\t\t\t}\n\t\t\t.PKT_BM_BTN div\n\t\t\t{\n\t\t\t\tdisplay: block;\n\t\t\t}\n\t\t\t#PKT_FORM\n\t\t\t{\n\t\t\t\tposition: static !important;\n\t\t\t\tdisplay: block !important;\n\t\t\t\tvisibility: visible !important;\n\t\t\t\tmargin: 0px !important;\n\t\t\t\tpadding: 0px !important;\n\t\t\t}\n\t\t\t#PKT_BM_OVERLAY_INPUT\n\t\t\t{\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t\t.PKT_SHOW_INPUT #PKT_BM_OVERLAY_INPUT\n\t\t\t{\n\t\t\t\tposition: absolute !important;\n\t\t\t\tdisplay: block !important;\n\t\t\t\ttop: " + n + "px !important;\n\t\t\t\tleft: 7% !important;\n\t\t\t\twidth: 50% !important;\n\t\t\t\theight: " + o + "px !important;\n\t\t\t\tborder: " + m + "px solid #c9c9c9 !important;\n\t\t\t\tmargin: 0px !important;\n\t\t\t\tpadding: 0px 0px 0px 5px !important;\n\t\t\t\tfont-size: " + p + "px !important;\n\t\t\t\tcolor: #666666 !important;\n\t\t\t\tbackground: white !important;\n\t\t\t\t\n\t\t\t\t/* overrides */\n\t\t\t\tfont-family: Arial !important;\n\t\t\t\t-webkit-box-shadow: none !important;\n\t\t\t\t-moz-box-shadow: none !important;\n\t\t\t\tbox-shadow: none !important;\n\t\t\t\t-webkit-border-radius: 0px !important;\n\t\t\t\t-moz-border-radius: 0px !important;\n\t\t\t\tborder-radius: 0px !important;\n\t\t\t}\n\t\t\t.PKT_desktop #PKT_BM_OVERLAY_INPUT\n\t\t\t{\n\t\t\t\ttop: 27px !important;\n\t\t\t\tleft: auto !important;\n\t\t\t\tright: 7% !important;\n\t\t\t\twidth: 300px !important;\n\t\t\t\tmargin-right: 100px !important;\n\t\t\t}\n\t\t\t.PKT_SHOW_INPUT #PKT_BM_OVERLAY_LABEL\n\t\t\t{\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t\t"; | |
var r = '\n\t\t\t<div id="PKT_BM_OVERLAY">\n\t\t\t\t<div id="PKT_BM_RAINBOWDASH">\n\t\t\t\t\t<div style="background-color: #83EDB8;"></div>\n\t\t\t\t\t<div style="background-color: #50BCB6;"></div>\n\t\t\t\t\t<div style="background-color: #EE4256;"></div>\n\t\t\t\t\t<div style="background-color: #FCB64B;"></div>\n\t\t\t\t</div>\n\t\t\t\t<div id="PKT_BM_OVERLAY_WRAPPER" class="PKT_' + (this.isMobile ? "mobile": "desktop") + '">\n\t\t\t\t\t<a id="PKT_BM_OVERLAY_LOGO" href="http://' + PKT_D + '" target="_blank">Pocket</a>\n\t\t\t\t\t<div id="PKT_BM_OVERLAY_LABEL"></div>\n\t\t\t\t\t<form id="PKT_FORM"><input type="text" id="PKT_BM_OVERLAY_INPUT" /><input type="submit" value="Submit" name="submit" style="position:absolute !important;left:-789em !important;"/></form>\n\t\t\t\t\t<a id="PKT_BM_BTN" class="PKT_BM_BTN" target="_blank" href=""></a>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t'; | |
var s = document.createElement("div"); | |
s.innerHTML = '<style id="PKT_BM_STYLE">' + q + "</style>" + r; | |
document.body.appendChild(s); | |
try { | |
if (document.location.host.match("twitter.")) document.getElementsByClassName("topbar")[0].style.position = "absolute" | |
} catch(t) {} | |
var u = this; | |
setTimeout(function() { | |
u.show() | |
}, | |
30) | |
}, | |
displayMessage: function(a) { | |
this.toggleClass(document.getElementById("PKT_BM_OVERLAY_WRAPPER"), "PKT_SHOW_INPUT", false); | |
document.getElementById("PKT_BM_OVERLAY_LABEL").innerHTML = a | |
}, | |
showButton: function(a, b, c, d) { | |
var e = document.getElementById("PKT_BM_BTN"); | |
e.style.visibility = a ? "visible": "hidden"; | |
if (a) { | |
e.innerHTML = a; | |
if (!b) e.removeAttribute("href"); | |
else e.href = b; | |
e.onclick = function() { | |
c() | |
}; | |
this.toggleClass(e, "gray", d) | |
} | |
}, | |
getReadyToHide: function() { | |
var a = this; | |
clearTimeout(this.hideTO); | |
this.hideTO = setTimeout(function() { | |
a.hide() | |
}, | |
3e3) | |
}, | |
cancelPendingHide: function() { | |
clearTimeout(this.hideTO); | |
this.hideTO = undefined | |
}, | |
show: function() { | |
this.hidesOnClick = false; | |
this.cancelPendingHide(); | |
var a = document.getElementById("PKT_BM_OVERLAY"); | |
a.style[this.browserPrefix() + "Transform"] = "translate3d(0px," + (0 - a.offsetHeight - this.shadowHeight) + "px,0px)"; | |
a.style.visibility = "visible"; | |
var b = this; | |
a.onclick = function() { | |
if (b.hidesOnClick) b.hide() | |
}; | |
setTimeout(function() { | |
var c = b.browserPrefix(); | |
a.style[c + "Transition"] = "-" + c + "-transform 0.3s ease-out"; | |
a.style[c + "Transform"] = "translate3d(0px,0px,0px)" | |
}, | |
100) | |
}, | |
hide: function() { | |
var a = document.getElementById("PKT_BM_OVERLAY"); | |
a.style[this.browserPrefix() + "Transform"] = "translate3d(0px," + (0 - a.offsetHeight - this.shadowHeight) + "px,0px)"; | |
setTimeout(function() { | |
a.style.visibility = "hidden"; | |
a.parentNode.removeChild(a) | |
}, | |
300) | |
}, | |
wasSaved: function() { | |
var a = this; | |
this.displayMessage("Page Saved!"); | |
this.showButton("Add Tags", null, | |
function() { | |
a.openTagsEditor() | |
}, | |
true); | |
this.getReadyToHide() | |
}, | |
openTagsEditor: function() { | |
this.cancelPendingHide(); | |
var a = this; | |
var b = this.isMobile ? "Add tags (tag1, tag2)": "Add Tags (separated by commas)"; | |
this.showTextField(b); | |
var c = function() { | |
if (a.textField.value.length > 0) a.showButton("Save", null, | |
function() { | |
a.saveTags() | |
}); | |
else a.showButton("Close", null, | |
function() { | |
a.hide() | |
}, | |
true) | |
}; | |
c(); | |
var d = document.getElementById("PKT_FORM"); | |
d.onsubmit = function() { | |
a.saveTags(); | |
return false | |
}; | |
this.textField.onkeyup = c | |
}, | |
saveTags: function() { | |
var a = []; | |
var b = {}; | |
var c; | |
var d = this.trim(document.getElementById("PKT_BM_OVERLAY_INPUT").value); | |
if (d && d.length) { | |
var e = d.split(","); | |
for (var f = 0; f < e.length; f++) { | |
c = this.trim(e[f]).toLowerCase(); | |
if (c.length && !b[c]) { | |
a.push(c); | |
b[c] = c | |
} | |
} | |
} | |
if (!a || !a.length) { | |
alert("Please enter at least one tag"); | |
return | |
} | |
this.saveTagsCallback(a) | |
}, | |
showTextField: function(a) { | |
this.toggleClass(document.getElementById("PKT_BM_OVERLAY_WRAPPER"), "PKT_SHOW_INPUT", true); | |
this.textField = document.getElementById("PKT_BM_OVERLAY_INPUT"); | |
this.textField.placeholder = a | |
}, | |
toggleClass: function(a, b, c) { | |
if (!a) return; | |
if (c && !a.className.match(b)) a.className += " " + b; | |
else if (!c && a.className.match(b)) a.className = a.className.replace(b, "") | |
}, | |
browserPrefix: function() { | |
if (this._prefix) return this._prefix; | |
var a = document.createElement("div"); | |
var b = ["Webkit", "Moz", "MS", "O"]; | |
for (var c in b) { | |
if (a.style[b[c] + "Transition"] !== undefined) { | |
this._prefix = b[c]; | |
return this._prefix | |
} | |
} | |
}, | |
trim: function(a) { | |
var a = a.replace(/^\s\s*/, ""), | |
b = /\s/, | |
c = a.length; | |
while (b.test(a.charAt(--c))); | |
return a.slice(0, c + 1) | |
} | |
}; | |
var PKT_BM = function() {}; | |
PKT_BM.prototype = { | |
init: function() { | |
if (this.inited) return; | |
var a = this; | |
this.overlay = new PKT_BM_OVERLAY({ | |
saveTagsCallback: function(b) { | |
a.saveTags(b) | |
} | |
}); | |
this.inited = true | |
}, | |
save: function() { | |
var a = this; | |
this.overlay.create(); | |
if (ISRIL_TEST) { | |
this.overlay.displayMessage("Test successful!"); | |
this.overlay.getReadyToHide() | |
} else { | |
if (!ISRIL_H) { | |
this.edit() | |
} else { | |
this.overlay.displayMessage("Saving to Pocket..."); | |
this.sendRequest({ | |
u: document.location.href, | |
t: document.title.replace(/^\s\s*/, "").replace(/\s\s*$/, "") | |
}, | |
function() { | |
a.overlay.wasSaved() | |
}) | |
} | |
} | |
}, | |
saveTags: function(a) { | |
var b = this; | |
this.overlay.displayMessage("Saving Tags…"); | |
this.overlay.showButton(false); | |
this.sendRequest({ | |
u: document.location.href, | |
tags: JSON.stringify(a) | |
}, | |
function() { | |
b.overlay.displayMessage("Tags Saved!"); | |
b.overlay.getReadyToHide() | |
}) | |
}, | |
sendRequest: function(a, b) { | |
var c = function() { | |
if (f.checkImage() && b) b() | |
}; | |
var d = ""; | |
if (a) { | |
for (var e in a) { | |
d += "&" + e + "=" + encodeURIComponent(a[e]) | |
} | |
} | |
this.img = new Image; | |
this.img.onload = c; | |
this.img.src = "http://" + PKT_D + "/v2/r.gif?v=1&h=" + ISRIL_H + "&rand=" + Math.random() + d; | |
document.body.appendChild(this.img); | |
var f = this; | |
this.imageInt = setInterval(c, 250) | |
}, | |
checkImage: function() { | |
if (this.img && this.img.complete) { | |
clearInterval(this.imageInt); | |
this.complete = true; | |
var a = this.img.width; | |
var b = a == 1; | |
if (!b) { | |
if (a == 2) { | |
this.overlay.hidesOnClick = true; | |
this.overlay.displayMessage("Please login."); | |
this.overlay.showButton("Login", this.overlay.isMobile ? "http://" + PKT_D + "/bl/login/?url=http://" + PKT_D + "/bloggedin": "http://" + PKT_D + "/l") | |
} else if (a == 3) { | |
this.overlay.displayMessage("Error saving"); | |
this.overlay.showButton("Get Help", "http://help.getpocket.com/customer/portal/articles/480486-bookmarklet-error---wrong-account") | |
} | |
} | |
this.img.style.display = "none"; | |
return b | |
} | |
} | |
}; | |
var thePKT_BM = new PKT_BM; | |
thePKT_BM.init(); | |
thePKT_BM.save() | |
} | |
void(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment