public
Last active

CiteThis Bookmarklet (Javascript unencoded and uncompressed)

  • Download Gist
cite-this-uncompressed.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
javascript: (function () {
var h = document.createElement('div');
var t = document.getElementsByTagName('title')[0];
var info = '<p><strong>Title(' + t.innerHTML.length + '):</strong> ' + t.innerHTML + '</p>';
var m = document.getElementsByTagName('meta');
for (var i = 0; i < m.length; i++) {
if (null !== m[i].getAttribute('name')) {
var c = m[i].getAttribute('content');
info += '<p><strong>' + m[i].getAttribute('name') + '(' + c.length + '):</strong> ' + c + '</p>';
}
}
var lm = document.lastModified;
var url = location.href;
var d = new Date();
var dd = d.getDate();
var mm = d.getMonth()+1;
var yyyy = d.getFullYear();
info += '<p><strong>Citation: </strong>"' + t.innerHTML + '." Last modified ' + lm + '. ' + url + ' (accessed ' + mm + '/' + dd + '/' + yyyy + ').</p>';
document.body.insertBefore(h, document.body.firstChild);
h.innerHTML = '<div style="border:1px solid #888;border-radius:5px;-moz-box-shadow:0 0 5px #888;-webkit-box-shadow:0 0 5px#888;box-shadow:0 0 5px #888;background:#eee;text-align:left;padding:1em;"><a href="#" onclick="document.body.removeChild(document.body.firstChild);return false">remove</a>' + info + '</div>';
})();

Out of curiosity, how accurate do you think the document.lastModified property is? With this Gist, for instance, it's always showing the current date (probably because of AJAX) even though I can see that your last update was 17 days ago.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.