用於自動添加Digg This!按鈕的JavaScript

來源:互聯網
上載者:User

複製代碼 代碼如下: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>";
}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.