Skip to content

Instantly share code, notes, and snippets.

@knsmr
Created May 3, 2014 02:15
Show Gist options
  • Save knsmr/3aa20670e90cc0c6a811 to your computer and use it in GitHub Desktop.
Save knsmr/3aa20670e90cc0c6a811 to your computer and use it in GitHub Desktop.
//
// Bookmarklet
//
// Open up the stat page for WordPress.
// You need to be logged in to WordPress.com, and have permission.
//
//
javascript:(function(){
function getFirstElementByClass(matchClass) {
var elems = document.getElementsByTagName('*'), i;
for (i in elems) {
if ((" "+elems[i].className + " ").indexOf(" " + matchClass + " ") > -1) {
return elems[i];
}
}
};
var editButton, url, postId;
var statsUrl = "http://ja.wordpress.com/my-stats/?view=post&post=";
editButton = getFirstElementByClass("post-edit-link");
url = editButton.href;
postId = url.match(/post=([0-9]+)/)[1];
window.open(statsUrl + postId);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment