csdn 论坛技术区平均给分功能
作者:
看论坛里技术区没有平均给分的功能,感觉散分很不方便,就写了一个:IE8,FF3.5下测试ok
1每人平均给分(重复回复的只给一次分):
javascript:var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};var n=function(name){return document.getElementsByName(name)};var total=t("var")[0].innerHTML-0;var scores=n("tb_score");var lz=t("a",t("var")[0].parentNode)[0].innerHTML;var c={};c[lz]=lz;for(var i=0;i<scores.length;i++) { var v=t("a",scores[i].parentNode)[0].innerHTML;if(!c[v]) { c[v]=v;scores[i].value=scores[i].value-0+1;total--;if(total==0)break;}if(i==scores.length-1){i=-1;c={};c[lz]=lz;}};alert("ok");void(0)
源代码:
var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};
var n=function(name){return document.getElementsByName(name)};
var total=t("var")[0].innerHTML-0;
var scores=n("tb_score");
var lz=t("a",t("var")[0].parentNode)[0].innerHTML;
var c={};
c[lz]=lz;
for(var i=0;i<scores.length;i++) {
var v=t("a",scores[i].parentNode)[0].innerHTML;
if(!c[v]) {
c[v]=v;
scores[i].value=scores[i].value-0+1;
total--;
if(total==0)break;
}
if(i==scores.length-1){i=-1;c={};c[lz]=lz;}
};
alert("ok");
2每楼平均给分:
javascript:var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};var n=function(name){return document.getElementsByName(name)};var total=t("var")[0].innerHTML-0;var scores=n("tb_score");var lz=t("a",t("var")[0].parentNode)[0].innerHTML;for(var i=0;i<scores.length;i++) { if(t("a",scores[i].parentNode)[0].innerHTML!=lz) {scores[i].value=scores[i].value-0+1;total--;if(total==0)break;}if(i==scores.length-1)i=-1;};alert("ok");void(0)
源代码:
var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};
var n=function(name){return document.getElementsByName(name)};
var total=t("var")[0].innerHTML-0;
var scores=n("tb_score");
var lz=t("a",t("var")[0].parentNode)[0].innerHTML;
for(var i=0;i<scores.length;i++) {
if(t("a",scores[i].parentNode)[0].innerHTML!=lz) {
scores[i].value=scores[i].value-0+1;
total--;
if(total==0)break;
}
if(i==scores.length-1)i=-1;
};
alert("ok");
说明:将上面的代码放到结帖页面的地址栏里回车就ok了,只用一次,否则会出现负分的情况
javascript:var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};var n=function(name){return document.getElementsByName(name)};var total=t("var")[0].innerHTML-0;var scores=n("tb_score");var lz=t("a",t("var")[0].parentNode)[0].innerHTML;var c={};c[lz]=lz;for(var i=0;i<scores.length;i++) { var v=t("a",scores[i].parentNode)[0].innerHTML;if(!c[v]) { c[v]=v;scores[i].value=scores[i].value-0+1;total--;if(total==0)break;}if(i==scores.length-1){i=-1;c={};c[lz]=lz;}};alert("ok");void(0)
源代码:
复制代码 代码如下:
var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};
var n=function(name){return document.getElementsByName(name)};
var total=t("var")[0].innerHTML-0;
var scores=n("tb_score");
var lz=t("a",t("var")[0].parentNode)[0].innerHTML;
var c={};
c[lz]=lz;
for(var i=0;i<scores.length;i++) {
var v=t("a",scores[i].parentNode)[0].innerHTML;
if(!c[v]) {
c[v]=v;
scores[i].value=scores[i].value-0+1;
total--;
if(total==0)break;
}
if(i==scores.length-1){i=-1;c={};c[lz]=lz;}
};
alert("ok");
2每楼平均给分:
javascript:var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};var n=function(name){return document.getElementsByName(name)};var total=t("var")[0].innerHTML-0;var scores=n("tb_score");var lz=t("a",t("var")[0].parentNode)[0].innerHTML;for(var i=0;i<scores.length;i++) { if(t("a",scores[i].parentNode)[0].innerHTML!=lz) {scores[i].value=scores[i].value-0+1;total--;if(total==0)break;}if(i==scores.length-1)i=-1;};alert("ok");void(0)
源代码:
复制代码 代码如下:
var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};
var n=function(name){return document.getElementsByName(name)};
var total=t("var")[0].innerHTML-0;
var scores=n("tb_score");
var lz=t("a",t("var")[0].parentNode)[0].innerHTML;
for(var i=0;i<scores.length;i++) {
if(t("a",scores[i].parentNode)[0].innerHTML!=lz) {
scores[i].value=scores[i].value-0+1;
total--;
if(total==0)break;
}
if(i==scores.length-1)i=-1;
};
alert("ok");
说明:将上面的代码放到结帖页面的地址栏里回车就ok了,只用一次,否则会出现负分的情况