彩蛋娱乐 🎊
- 新建 Chrome 书签,地址栏填入以下代码
javascript:const row=32,col=60,wallWidth=1,padding=1,boxSize=25,wallColor=[233,84,32,255];function index2Pixel(t){return padding+t*(boxSize+wallWidth)/2}function isWall(t,e,n){const o=index2Pixel(e),l=index2Pixel(n),a=(t,e,n)=>{const o=4*(e*t.width+n);return t.data[o]==wallColor[0]&&t.data[o+1]==wallColor[1]&&t.data[o+2]==wallColor[2]&&t.data[o+3]==wallColor[3]};return a(t,o,l)||a(t,o-1,l)||a(t,o+1,l)||a(t,o,l-1)||a(t,o,l+1)}function binaryMap(t){const e=[];for(let n=0;n<2*row+1;n++){const o=[];for(let e=0;e<2*col+1;e++)o.push(isWall(t,n,e)?1:0);e.push(o)}return e}function logMap(t){let e="";for(let n=0;n<t.length;n++){for(let o=0;o<t[n].length;o++)e+=t[n][o];e+="|||\n"}console.log(e)}function findPath(t,e,n){const o=[],l=(e,a)=>!(e<0||e>=t.length||a<0||a>=t[e].length)&&(0==t[e][a]&&(o.push([e,a]),t[e][a]=-1,e==n[0]&&a==n[1]||(!!(l(e-1,a)||l(e+1,a)||l(e,a-1)||l(e,a+1))||void o.splice(o.length-1,1))));return l(e[0],e[1]),o}function drawPath(t,e){t.lineWidth=1,t.strokeStyle="green",t.setLineDash([8,8]);for(let n=0;n<e.length;n++){const o=index2Pixel(e[n][1]),l=index2Pixel(e[n][0]);0==n?t.moveTo(o,l):t.lineTo(o,l)}t.stroke(),t.setLineDash([])}function cheat(){const t=document.getElementsByClassName("maze-content")[0],e=t.getContext("2d"),n=e.getImageData(0,0,t.width,t.height);console.assert(n.width==2*padding+(col+1)*wallWidth+col*boxSize),console.assert(n.height==2*padding+(row+1)*wallWidth+row*boxSize);const o=binaryMap(n);logMap(o);const l=findPath(o,[1,1],[2*row-1,2*col-1]);console.log(l),drawPath(e,l),CanvasRenderingContext2D.prototype._clearRect||(CanvasRenderingContext2D.prototype._clearRect=CanvasRenderingContext2D.prototype.clearRect,CanvasRenderingContext2D.prototype.clearRect=function(){this._clearRect.apply(this,arguments),drawPath(e,l)})}cheat();
- 打开
https://tech.meituan.com/404.html
- 点击书签,加载 JS 代码
快乐玩耍 🤣
This is amazing 😱, well done mate, thank u for your work! 👍