最近在riku的博客上看到他新增加了一个twitter的小插件,位于博客最左侧中部,感觉很不错,今天在博译论看到了twitterFollowBadge这款插件的介绍。自己马上心血来经,到了Go2web20去折腾,不过发现没有默认支持以https方式访问twitter的选项,顿时心灰意冷,要知道自从twitter被封后,我一直是采用修改hosts文件的方式访问twitter的,我相信大部分网友应该和我一样。不过,当我试着打开Go2web20提供的js文件研究一下时,我立刻眼前一亮。

修改twitterFollowBadge的js文件

下面是twitterFollowBadge的js文件:

var tfb={};tfb.allowedLabels=["follow-me","follow-us","follow","my-twitter"];tfb.defaultTop=78;tfb.defaultColor="#35ccff";tfb.isInArray=function(str,ar){if(ar.length<1)return;for(vari=0;i<ar.length;i++){if(ar[i]==str){return true;break;}}
return false;}
tfb.showbadge=function(){if(!window.XMLHttpRequest){return;}
if(document.getElementById('twitterFollowBadge')){document.body.removeChild(document.getElementById('twitterFollowBadge'));}
if(tfb.top<0||tfb.top>1000||isNaN(tfb.top)){tfb.top=tfb.defaultTop;}
if(!tfb.isInArray(tfb.label,tfb.allowedLabels)){tfb.label=tfb.allowedLabels[0];}
varvalidColorPattern=/^#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$/;if(!validColorPattern.test(tfb.color)||(tfb.color.length!=4&&tfb.color.length!=7)){tfb.color=tfb.defaultColor;};if(tfb.side!='l'){tfb.side='r';}
tfb.tabStyleCode='position:fixed;'+'top:'+tfb.top+'px;'+'width:30px;'+'height:119px;'+'z-index:8765;'+'cursor:pointer;'+'background:'+tfb.color+' url(http://files.go2web20.net/twitterbadge/1.0/bg-badge/'+tfb.label+'.png);'+'background-repeat:no-repeat;';tfb.aboutStyleCode='position:absolute;'+'top:'+(parseInt(tfb.top)+107)+'px;'+'width:10px;'+'height:11px;'+'z-index:9876;'+'cursor:pointer;'+'background:url(http://files.go2web20.net/twitterbadge/1.0/icon-about.png);'+'background-repeat:no-repeat;';if(tfb.side=='l'){tfb.tabStyleCode+='left:0; background-position:right top;';tfb.aboutStyleCode+='left:0;';}else{tfb.tabStyleCode+='right:0; background-position:left top;';tfb.aboutStyleCode+='right:0;';}
tfbMainDiv=document.createElement('div');tfbMainDiv.setAttribute('id','twitterFollowBadge');document.body.appendChild(tfbMainDiv);tfbMainDiv.innerHTML='<div id="tfbTab" style="'+tfb.tabStyleCode+'"></div><div id="tfbAbout" style="'+tfb.aboutStyleCode+'"></div>'+'<style>#tfbAbout{visibility:hidden;} #twitterFollowBadge:hover #tfbAbout{visibility:visible;}</style>';document.getElementById('tfbTab').onclick=function(){window.open('http://www.go2web20.net/twitterfollowbadge/redir.htm?'+tfb.account);}
document.getElementById('tfbAbout').onclick=function(){window.open('http://www.go2web20.net/twitterFollowBadge/');}}

通过上面的js代码被划去的一句(‘http://www.go2web20.net/twitterfollowbadge/redir.htm?’+tfb.account),我们可以看出,twitterFollowBadge使用的域名重定向的方式跳转到了twitter页面,那么,我们只需将划去的这句修改为:

‘https://www.twitter.com/’+tfb.account

不过,我不是这么做的,我直接改成了’https://www.twitter.com/shuil’,欢迎大家点击我博客左上角的follow me图片跟随我。之后把js文件上传到WordPress后台就OK啦,其他的照着twitterFollowBadge的说明去做(header区的js路径记得更换为您上传后的js路径)。
当然,你也可以使用这个js文件设计豆瓣、饭否、校内和淘宝等网站帐户链接,就是做个png格式的透明图片应该就行嘛,可惜我没有设计天赋,你要是做好了记得分享给shuil哦。

附:不用翻墙打开twitter的最新IP

把“C:\WINDOWS\system32\drivers\etc”复制粘贴到地址栏,然后回车,然后双击打开的etc文件夹下的hosts文件,选择用记事本打开,然后把下面的几行粘贴到最后,保存关闭即可用https方式访问twitter了:
168.143.161.20 twitter.com 168.143.161.20 www.twitter.com 128.121.146.229 assets0.twitter.com 128.121.146.229 assets1.twitter.com 128.121.146.101 static.twitter.com 128.121.146.229 assets2.twitter.com 128.121.146.229 assets3.twitter.com 65.74.185.41 twitter.zendesk.com 65.74.185.41 help.twitter.com 168.143.162.107 search.twitter.com

人家还要...

发表您的高见

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!:

.