如何玩坏M67博客首页
摘要:我好无聊啊。。。。
众所周知,M67大神的博客首页有一个400个方块组成的16×25的版面。而且是实时刷新的。于是,长期以来,这块分辨率只有16×25的场所就成了众Geek的娱乐之地。
但是,我每次浏览M67博客主页的时候,这些方块不能组成规则的图形。这绝对不是我这种强迫症的风格。 如何快速在M67博客主页的16×25的方块阵上建立一个图形呢?
我查看了M67主页源码。发现所有的方块变色操作只有一个函数inverse控制,这个函数接受一个1~400的整型参数,表示位置。执行后该位置上颜色会反转。在此基础上,我们可以用一段代码控制,判断图形中哪些块需要反转并只对这些需要反转的块执行inverse函数。
以下是一些图案:
全黑(填上数组形成黑底图案):
1 | (function(){img=[];for(i=1;i<=400;i++){var iru=0;var x=document.getElementById("td"+i);len=img.length;for(j=0;j<len;j++){if(img[j]==i)iru=1}if((iru==0)&&(x.bgColor=="#FFFFFF"))inverse(i);else if((iru==1)&&(x.bgColor=="#404040"))inverse(i)}})(); |
全白(填上数组形成白底图案):
1 | (function(){img=[];for(i=1;i<=400;i++){var iru=0;var x=document.getElementById("td"+i);len=img.length;for(j=0;j<len;j++){if(img[j]==i)iru=1}if((iru==0)&&(x.bgColor=="#404040"))inverse(i);else if((iru==1)&&(x.bgColor=="#FFFFFF"))inverse(i)}})(); |
全部反转:
(我记得这个功能以前直接有按钮来着,现在M67怎么去掉了?)
1 | (function(){for(i=1;i<=400;i++)inverse(i);})(); |
心形:
1 | (function(){img=[84,85,90,91,108,109,110,111,114,115,116,117,132,133,134,135,136,139,140,141,142,143,157,158,159,160,161,162,163,164,165,166,167,168,182,183,184,185,186,187,188,189,190,191,192,193,208,209,210,211,212,213,214,215,216,217,233,234,235,236,237,238,239,240,241,242,259,260,261,262,263,264,265,266,285,286,287,288,289,290,311,312,313,314,337,338];for(i=1;i<=400;i++){var iru=0;var x=document.getElementById("td"+i);len=img.length;for(j=0;j<len;j++){if(img[j]==i)iru=1}if((iru==0)&&(x.bgColor=="#FFFFFF"))inverse(i);else if((iru==1)&&(x.bgColor=="#404040"))inverse(i)}})(); |
下面我只发数字咯:
π:
1 | 108,109,110,111,112,113,114,115,116,133,134,135,136,137,138,139,140,141,161,163,186,188,210,211,213,235,239,258,259,260,264,283,284,290,291 |
游戏机手柄:
1 | 55,56,80,81,103,104,105,106,107,108,128,129,130,131,132,133,155,156,180,181,210,211,214,215,117,118,120,121,142,143,145,146 |
马里奥:
1 | 10,11,12,13,14,34,40,41,42,58,68,83,84,85,88,90,91,92,107,110,111,113,118,132,135,136,139,143,158,159,163,164,165,166,167,183,184,185,191,206,207,211,212,215,216,217,230,237,238,241,243,255,261,262,263,264,265,266,269,281,284,285,286,287,289,290,292,294,307,308,309,310,311,312,313,314,315,316,318,331,334,335,336,337,338,339,340,343,356,360,363,367,382,383,384,389,390,391 |
猫咪:
1 | 33,43,57,59,67,69,81,83,85,91,93,95,105,106,108,110,111,112,113,114,115,116,118,120,121,129,147,153,173,178,180,181,182,183,193,194,195,196,198,203,223,228,231,232,244,245,248,253,256,257,269,270,273,278,288,298,303,309,312,314,317,323,329,335,336,340,341,347,355,356,371,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395 |
史努比:
1 | 11,12,13,14,15,35,41,42,59,67,68,82,83,84,85,88,93,94,105,106,107,110,113,119,120,130,145,155,157,158,170,180,182,183,195,205,220,230,231,233,238,245,257,258,259,260,261,262,266,267,268,269,270,284,285,286,289,290,291,293,294,311,314,317,318,335,336,339,360,364,365,384,390,391 |
黑白格:
1 | (function(){img=[];for(i=1;i<=400;i++){var iru=0;var x=document.getElementById("td"+i);len=img.length;if(i%2==0)iru=1;if((iru==0)&&(x.bgColor=="#404040"))inverse(i);else if((iru==1)&&(x.bgColor=="#FFFFFF"))inverse(i)}})(); |
图案转img数组:(在控制台中执行)
1 | (function(){var result="";for(i=1;i<=400;i++){var x=document.getElementById("td"+i);if(x.bgColor=="#404040")result=result+i+",";}console.log(result);})(); |
代码是直接复制到浏览器地址栏执行即可。。。有些浏览器可能吞“javascript:”,自己手动加上就好。