Skip to content

Instantly share code, notes, and snippets.

@michimani
Last active March 2, 2018 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michimani/421c5c55329c50d8c7a1dbfdcbf034c2 to your computer and use it in GitHub Desktop.
Save michimani/421c5c55329c50d8c7a1dbfdcbf034c2 to your computer and use it in GitHub Desktop.
Add a specific element before heading in Hatena blog article.
if (location.href.match(/michinoeki-mania\.com\/entry/)) { // Replace this with your blog domain
var j=new Date();
var f=j.getTime();
var g="";
switch (f%5) {
case 0:
g="Something 1";
break;
case 1:
g="Something 2";
break;
case 2:
g="Something 3";
break;
case 3:
g="Something 4";
break;
case 4:
g="Something 5";
break;
}
var h="<div style='text-align:center;'>"+g+"</div>";
var a=document.getElementsByTagName("h1");
if (typeof(a[3]) != "undefined") {
a[3].insertAdjacentHTML("beforebegin",h);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment