Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Last active February 27, 2023 17:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palaniraja/11321563 to your computer and use it in GitHub Desktop.
Save palaniraja/11321563 to your computer and use it in GitHub Desktop.
Tinderizer - Send to kindle bookmarklet
javascript: (function () {
var setupDiv = function () {
var id = 'Tinderizer';
var div = document.getElementById(id);
var body = document.getElementsByTagName('body')[0];
if (null != div) {
body.removeChild(div);
}
div = document.createElement('div');
div.id = id;
div.style.width = 'auto';
div.style.height = '30px';
div.style.fontSize = '14px';
div.setAttribute('data-email', 'YOUR_KINDLE_ID@kindle.com');
div.style.position = 'fixed';
div.style.top = '10px';
div.style.left = '10px';
div.style.background = 'white';
div.style.color = 'black';
div.style.borderColor = 'black';
div.style.borderStyle = 'solid';
div.style.borderWidth = '2px';
div.style.zIndex = '99999999';
div.style.padding = '16px';
div.style.textAlign = 'center';
div.innerHTML = 'Working...';
body.appendChild(div);
};
setupDiv();
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '//tinderizer.com/static/bookmarklet.js?t=' + (new Date()).getTime();
document.getElementsByTagName('head')[0].appendChild(script);
})();
(function () {
var a, b, c, d, e, f, g, h, i = function (a, b) {
return function () {
return a.apply(b, arguments)
}
},
j = {}.hasOwnProperty;
e = function (a, b) {
return setInterval(b, a)
}, f = function (a, b) {
return setTimeout(b, a)
}, d = function (a) {
return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
}, a = "XDomainRequest" in window ? function (a, b, c, d) {
var e;
return e = new XDomainRequest, e.onload = function () {
return d(JSON.parse(e.responseText))
}, e.open(b, a), e.send(c)
} : function (a, b, c, d) {
var e;
return e = new XMLHttpRequest, e.onreadystatechange = function () {
if (e.readyState === 4) return d(JSON.parse(e.responseText))
}, e.open(b, a, !0), c != null && e.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), e.setRequestHeader("Accept", "application/json"), e.send(c)
}, b = function () {
function b(a, b) {
this.div = a, this.url = b, this.onSubmit = i(this.onSubmit, this), this.to = this.div.getAttribute("data-email"), this.body = document.getElementsByTagName("body")[0], this.redirect = !1, this.submitEndpoint = "http://" + this.host + "/ajax/submit.json"
}
return b.name = "Tinderizer", b.prototype.paywallHosts = /arstechnica|nytimes|theatlantic|guardian|wsj|thetimes/, b.prototype.css = "#Tinderizer{padding:16px !important;min-width:300px !important;width:auto !important;height:30px !important;font-size:14px !important;line-height:28px !important;font-family:monospace !important;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}\n", b.prototype.host = "tinderizer.com", b.prototype.validHost = /tinderizer\.com/i, b.prototype.checks = {
"This doesn't work on local files.": /^file:/,
"You need to run this on an article page! Main or home pages don't work very well.": new RegExp(d(window.location.protocol + ("//" + window.location.host + "/")) + "$"),
"There is nothing to do on about:blank!": /about:blank/,
"You need to run this on a publicly accessible HTML page!": /\.(pdf|jpg)$/i,
"Run this on the raw page, not a Readability page!": /^https?:\/\/www.readability.com\/articles\//i
}, b.prototype.okay = function () {
var a, b, c;
c = this.checks;
for (a in c) {
if (!j.call(c, a)) continue;
b = c[a];
if (b.test(this.url)) return alert(a), this.body.removeChild(this.div), !1
}
return !0
}, b.prototype.notify = function (a) {
return this.div.innerHTML = a, this.div.appendChild(document.createTextNode(" "))
}, b.prototype.appendStyleSheet = function () {
var a, b;
a = document.getElementsByTagName("head")[0];
if (a != null) return b = document.createElement("style"), b.type = "text/css", a.appendChild(b), "styleSheet" in b ? b.styleSheet.cssText = this.css : b.appendChild(document.createTextNode(this.css))
}, b.prototype.checkHost = function () {
if (!this.validHost.test(this.host) && confirm("Kindlebility has been renamed to Tinderizer. Please remake your bookmark to ensure it continues to work after the domain completely changes!\n\nPlease click OK to visit the new website and remake your bookmarklet when we're done here.")) return this.redirect = !0
}, b.prototype.onSubmit = function (b) {
var c, d, g, h = this;
this.notify(b.message);
if (b.limited || b.id == null) {
f(2500, function () {
return this.body.removeChild(this.div)
});
return
}
return this.done = !1, c = f(3e4, function () {
return h.done = !0, alert("Okay, this is getting out of hand, something must have broken, I'm going to stop trying."), h.body.removeChild(h.div)
}), d = b.id, g = e(500, function () {
return h.done && clearInterval(g), a("http://" + h.host + "/ajax/status/" + d + ".json?t=" + (new Date).getTime(), "GET", null, function (a) {
h.notify(a.message);
if (a.done) return h.done = !0, clearTimeout(c), clearInterval(g), f(2500, function () {
h.body.removeChild(h.div);
if (h.redirect) return window.location = "https://tinderizer.com/"
})
})
})
}, b.prototype.sendHTML = function () {
return this.paywallHosts.test(document.location.host)
}, b.prototype.run = function () {
var b;
if (this.okay()) return this.appendStyleSheet(), this.checkHost(), b = {
url: this.url,
email: this.to
}, this.sendHTML() && (b.content = document.documentElement.outerHTML), a(this.submitEndpoint, "POST", JSON.stringify(b), this.onSubmit)
}, b
}(), c = document.getElementById("Tinderizer") || document.getElementById("kindlebility"), h = document.location.href, g = new b(c, h), g.run()
}).call(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment