Skip to content

Instantly share code, notes, and snippets.

@jasonclark
Created October 4, 2012 14:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jasonclark/3833714 to your computer and use it in GitHub Desktop.
Save jasonclark/3833714 to your computer and use it in GitHub Desktop.
CiteThis Bookmarklet (Javascript unencoded and uncompressed)
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>';
})();
@phette23
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment