会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
代码改变世界
Cnblogs
Dashboard
Login
Home
Contact
Gallery
Subscribe
RSS
Cat in dotNET
用于自动添加"Digg This!"按钮的JavaScript
2006-12-16 21:36
Cat Chen
阅读(
632
) 评论(
0
)
编辑
收藏
举报
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>
"
;
}
会员力量,点亮园子希望
刷新页面
返回顶部
About