用于自动添加Digg This!按钮的JavaScript
var main=document.getelementbyid("main");
var singlepost=false;
var firstpost;
var anchor;
for(var i=0;i<main.childnodes.length;i++)
{
if(main.childnodes[i].classname&&main.childnodes[i].classname=="post")
{
var post=main.childnodes[i];
if(!firstpost)
{
firstpost=post;
}
for(var j=0;j<post.childnodes.length;j++)
{
if(post.childnodes[j].classname&&post.childnodes[j].classname=="posthead")
{
var posthead=post.childnodes[j];
if(posthead.childnodes[1]&&posthead.childnodes[1].tagname&&posthead.childnodes[1].tagname=="h2")
{
if(posthead.childnodes[1].childnodes[1]&&posthead.childnodes[1].childnodes[1].tagname&&posthead.childnodes[1].childnodes[1].tagname=="a")
{
anchor=posthead.childnodes[1].childnodes[1];
}
else
{
anchor=posthead.childnodes[1].childnodes[0];
}
}
else
{
anchor=posthead.childnodes[0].childnodes[0];
}
anchor.style.fontsize="14pt";
if(anchor.classname&&anchor.classname=="singleposttitle")
{
singlepost=true;
}
}
}
}
}
if(singlepost)
{
var postfoot=document.createelement("div");
firstpost.appendchild(postfoot);
postfoot.classname="postfoot";
postfoot.innerhtml="<a href=\"http://del.icio.us/post?v=4&url="+encodeuricomponent(location.href)+"&title="+encodeuricomponent(document.title)+"\"><img src=\http://del.icio.us/favicon.ico\ alt=\"add to del.icio.us\" border=\"0\"/><span>add to del.icio.us</span></a>";
postfoot.innerhtml+="<a href=\"http://digg.com/submit?phase=2&url="+encodeuricomponent(location.href)+"&title="+encodeuricomponent(document.title)+"\"><img src=\http://digg.com/favicon.ico\ alt=\"digg this!\" border=\"0\"/><span>digg this!</span></a>";
postfoot.innerhtml+="<a href=\"http://www.facebook.com/share.php?u="+encodeuricomponent(location.href)+"\"><img src=\http://www.facebook.com/favicon.ico\ alt=\"share on facebook\" border=\"0\"/><span>share on facebook</span></a>";
postfoot.innerhtml+="<a href=\"http://www.google.com/bookmarks/mark?op=edit&bkmk="+encodeuricomponent(location.href)+"&title="+encodeuricomponent(document.title)+"\"><img src=\http://www.google.com/favicon.ico\ alt=\"google bookmark this\" border=\"0\"/><span>google bookmark this</span></a>";
}
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
-
-
-
mock入门学习
mockjs入门学习,自动生成数据官网入口:http://mockjs.com/安装:npm i mockjs ...
[阅读全文]
-
网友评论