-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomiil.js
More file actions
1 lines (1 loc) · 12.7 KB
/
domiil.js
File metadata and controls
1 lines (1 loc) · 12.7 KB
1
javascript:window.Dom2=window.Dom2||{},function(a){function b(a,b){this.x=a,this.y=b}function c(a,b){this.position=a,this.direction=b}function d(){function a(){I.dom2.isAccelerating=!0}function d(){I.dom2.isAccelerating=!1}function e(){I.dom2.isRotatingLeft=!0}function f(){I.dom2.isRotatingLeft=!1}function g(){I.dom2.isRotatingRight=!0}function h(){I.dom2.isRotatingRight=!1}function i(a){I.dom2.isShooting=!0,I.dom2.isAtLeastOneShot=!0}function j(){I.dom2.isShooting=!1}function k(a){var c=(new Date).getTime(),d=(c-w)/1e3;w=c,C=d,d=Math.min(.02,d);var e=x=a.gamma,f=y=a.beta;return e=Math.max(Math.min(Math.round(e*z)/z,90),-90),f=Math.max(Math.min(Math.round(f*z)/z,90),-90),x=e,y=f,Math.abs(e)<=.2||Math.abs(f)<=.2?(I.dom2.isRotatingLeft=!1,void(I.dom2.isRotatingRight=!1)):(A=S*Math.min(1,20*Math.abs(e)/90),B=S*Math.min(1,20*Math.abs(f)/90),e*=Math.PI/180,f*=Math.PI/180,v=new%20b(e,f).normalize(),u=new%20b(A*d*v.x,B*d*v.y).add(I.dom2.speed),u.x%3EV?u.x=V:u.x%3C-V&&(u.x=-V),u.y%3EV?u.y=V:u.y%3C-V&&(u.y=-V),I.dom2.direction=v,void(I.dom2.speed=u))}function%20l(a){if(t){if(P=document.elementsFromPoint(a.x,a.y),!P)return%20null;for(var%20b=0;b%3CP.length;b++)if(m(P[b]))return%20P[b]}else{if(N=document.elementFromPoint(a.x,a.y),console.log(N),!N)return%20null;if(N.nodeType===Node.TEXT_NODE&&(N=N.parentElement),m(N))return%20N}return%20null}function%20m(a){return%20a!==document.body&&!a.classList.contains(%22dom2%22)&&a.children.length%3C2&&a!==Node.TEXT_NODE}function%20n(){_=!1,I.parentNode.removeChild(I),q.parentNode.removeChild(q)}function%20o(a){for(var%20c,d=(new%20Date).getTime(),e=0;20%3Ee;e++)c={},c.position=new%20b(a.x,a.y),c.direction=new%20b(1,1).rotate(360*Math.random()),c.speed=X*(1-.2*Math.random()),c.color=e%3==0?%22#E14832%22:e%3==1?%22#ff0000%22:%22#1E1E1E%22,c.time=d,da.push(c)}var%20p=this;console.log(%22Ignite()%22);var%20q=document.createElement(%22div%22);q.className=%22dom2%22;var%20r=!!(%22onorientationchange%22in%20window),s=!r&&!!(%22ontouchstart%22in%20window||navigator.msMaxTouchPoints),t=!!document.elementsFromPoint;console.log(%22supportsFetchingSeveralElements:%22+t);var%20u,v,w=(new%20Date).getTime(),x=%22-%22,y=%22-%22,z=10,A=0,B=0,C=%22-%22,D=document.createElement(%22div%22);if(D.id=%22shipContainer%22,D.className=%22dom2%22,document.body.appendChild(D),s){q.innerHTML='%3Cdiv%20class=%22dom2%22%20style=%22-webkit-touch-callout:%20none;-webkit-user-select:%20none;-khtml-user-select:%20none;-moz-user-select:%20none;-ms-user-select:%20none;user-select:%20none;font-family:Arial,%20Helvetica,%20sans-serif;font-size:%2012px;background:rgba(0,0,0,0.6);width:100%;position:fixed;bottom:0;color:#fff;z-index:1010;text-align:center;%22%3E%3Cdiv%20class=%22dom2%22%20id=%22Dom2.controls.up%22%20style=%22box-sizing:border-box;width:80px;height:80px;;text-align:center;font-size:x-large;border-left:1px%20solid%20#fff;border-top:1px%20solid%20#fff;border-right:1px%20solid%20#fff;padding:20px;display:inline-block;%22%3E↑%3C/div%3E%3Cdiv%20class=%22dom2%22%20style=%22text-align:center;width:100%;%20overflow:%20hidden;margin-left:auto;margin-right:auto;%22%3E%3Cdiv%20class=%22dom2%22%20id=%22Dom2.controls.left%22%20style=%22box-sizing:border-box;width:80px;height:80px;text-align:center;font-size:x-large;border-left:1px%20solid%20#fff;border-top:1px%20solid%20#fff;border-bottom:1px%20solid%20#fff;padding:20px;display:inline-block;%22%3E←%3C/div%3E%3Cdiv%20class=%22dom2%22%20id=%22Dom2.controls.shoot%22%20style=%22box-sizing:border-box;width:80px;height:80px;text-align:center;font-size:x-large;border:1px%20solid%20#fff;padding:20px;display:inline-block;%22%3E⊗%3C/div%3E%3Cdiv%20class=%22dom2%22%20id=%22Dom2.controls.right%22%20style=%22box-sizing:border-box;width:80px;height:80px;text-align:center;font-size:x-large;border-top:1px%20solid%20#fff;border-bottom:1px%20solid%20#fff;border-right:1px%20solid%20#fff;padding:20px;display:inline-block;%22%3E→%3C/div%3E%3C/div%3E%3Cdiv%20class=%22dom2%22%20style=%22width:100%;text-align:center;clear:left;%22%3EControl%20ship%20with%20arrows%20or%20WASD.%20Shoot%20with%20SPACE%20or%20mouse%20click.%20Press%20ESC%20to%20quit.%20%3Ca%20href=%22https://blog.roysolberg.com/2017/10/dom2-bookmarklet%22%3ERead%20more%3C/a%3E%3C/div%3E%3C/div%3E',D.appendChild(q);var%20E=document.getElementById(%22Dom2.controls.up%22),F=document.getElementById(%22Dom2.controls.left%22),G=document.getElementById(%22Dom2.controls.right%22),H=document.getElementById(%22Dom2.controls.shoot%22);E.addEventListener(%22touchstart%22,a),E.addEventListener(%22mousedown%22,a),E.addEventListener(%22touchend%22,d),E.addEventListener(%22mouseup%22,d),F.addEventListener(%22touchstart%22,e),F.addEventListener(%22mousedown%22,e),F.addEventListener(%22touchend%22,f),F.addEventListener(%22mouseup%22,f),G.addEventListener(%22touchstart%22,g),G.addEventListener(%22mousedown%22,g),G.addEventListener(%22touchend%22,h),G.addEventListener(%22mouseup%22,h),H.addEventListener(%22touchstart%22,i),H.addEventListener(%22mousedown%22,i),H.addEventListener(%22touchend%22,j),H.addEventListener(%22mouseup%22,j)}else%20r?(q.innerHTML='%3Cdiv%20class=%22dom2%22%20style=%22font-family:Arial,%20Helvetica,%20sans-serif;font-size:%2012px;background:rgba(0,0,0,0.6);width:100%;position:fixed;bottom:0;color:#fff;z-index:1010;%22%3E%3Cdiv%20class=%22dom2%22%20style=%22width:100%;text-align:center;%22%3EControl%20ship%20tilting%20your%20device.%20Shoot%20by%20touching%20the%20screen.%20%3Ca%20href=%22https://blog.roysolberg.com/2017/10/dom2-bookmarklet%22%3ERead%20more%3C/a%3E%3C/div%3E%3C/div%3E',D.appendChild(q),window.addEventListener(%22deviceorientation%22,k,!0)):(q.innerHTML='%3Cdiv%20class=%22dom2%22%20style=%22font-family:Arial,%20Helvetica,%20sans-serif;font-size:%2012px;background:rgba(0,0,0,0.6);width:100%;position:fixed;bottom:0;color:#fff;z-index:1010;%22%3E%3Cdiv%20class=%22dom2%22%20style=%22width:100%;text-align:center;%22%3EControl%20ship%20with%20arrows%20or%20WASD.%20Shoot%20with%20SPACE%20or%20mouse%20click.%20Press%20ESC%20to%20quit.%20%3Ca%20href=%22https://blog.roysolberg.com/2017/10/dom2-bookmarklet%22%3ERead%20more%3C/a%3E%3C/div%3E%3C/div%3E',D.appendChild(q));var%20I=document.createElement(%22canvas%22);I.className=%22dom2%22,I.addEventListener(%22mousedown%22,i,!1),I.addEventListener(%22mouseup%22,j,!1),I.width=document.clientWidth||window.innerWidth||document.documentElement.clientWidth,I.height=document.clientHeight||window.innerHeight||document.documentElement.clientHeight,I.style.width=I.width+%22px%22,I.style.height=I.height+%22px%22,I.style.zIndex=1e3,I.style.position=%22fixed%22,I.style.top=0,I.style.left=0,I.style.webkitTapHighlightColor=%22rgba(0,0,0,0)%22,I.dom2={},I.dom2.direction=new%20b(0,-1),I.dom2.position=new%20b(I.width/2-40,I.height/2-4.5),I.dom2.speed=new%20b(0,0),I.id=%22Dom2.ship%22,D.appendChild(I),document.onkeydown=function(a){switch(a.keyCode){case%2032:return%20I.dom2.isShooting=!0,I.dom2.isAtLeastOneShot=!0,!1;case%2065:case%2037:return%20I.dom2.isRotatingLeft=!0,!1;case%2087:case%2038:return%20I.dom2.isAccelerating=!0,!1;case%2039:case%2068:return%20I.dom2.isRotatingRight=!0,!1;case%2040:case%2083:return%20I.dom2.isDeaccelerating=!0,!1;case%2027:n()}},document.onkeypress=function(a){},document.onkeyup=function(a){switch(a.keyCode){case%2032:return%20I.dom2.isShooting=!1,!1;case%2065:case%2037:return%20I.dom2.isRotatingLeft=!1,!1;case%2087:case%2038:return%20I.dom2.isAccelerating=!1,!1;case%2068:case%2039:return%20I.dom2.isRotatingRight=!1,!1;case%2040:case%2083:return%20I.dom2.isDeaccelerating=!1,!1}};var%20J,K,L,M,N,O,P,Q=(new%20Date).getTime(),R=400,S=450,T=.95,U=1,V=700,W=750,X=150,Y=10,Z=.6,$=250,_=!0,aa=0,ba=[],ca=0,da=[];return%20p.run=function(){if(_){var%20a=(new%20Date).getTime(),d=(a-Q)/1e3;if(Q=a,I.dom2.isRotatingLeft&&I.dom2.direction.rotate(R*-d),I.dom2.isRotatingRight&&I.dom2.direction.rotate(R*d),I.dom2.isAccelerating?(I.dom2.speed.add(new%20b(S*d*I.dom2.direction.x,S*d*I.dom2.direction.y)),I.dom2.speed.x%3EV?I.dom2.speed.x=V:I.dom2.speed.x%3C-V&&(I.dom2.speed.x=-V),I.dom2.speed.y%3EV?I.dom2.speed.y=V:I.dom2.speed.y%3C-V&&(I.dom2.speed.y=-V)):I.dom2.speed.multiply(1-T*d),I.dom2.isDeaccelerating&&I.dom2.speed.multiply(1-U*d),I.dom2.position.add(new%20b(d*I.dom2.speed.x,d*I.dom2.speed.y)),I.dom2.position.y%3CY?window.pageYOffset%3E0?(L=Math.min(window.pageYOffset,I.height),window.scrollBy(0,-L),I.dom2.position.y+=L,I.dom2.position.y%3EI.height-Y&&(I.dom2.position.y=I.height-Y)):(I.dom2.position.y=Y,I.dom2.speed.y=-I.dom2.speed.y*Z):I.dom2.position.y%3EI.height-Y&&(K=document.body.offsetHeight-(window.innerHeight+window.pageYOffset),K%3E0?(L=Math.min(K,I.height),window.scrollBy(0,L),I.dom2.position.y-=L,I.dom2.position.y%3CY&&(I.dom2.position.y=Y)):(I.dom2.position.y=I.height-Y,I.dom2.speed.y=-I.dom2.speed.y*Z)),I.dom2.position.x%3CY?(I.dom2.position.x=Y,I.dom2.speed.x=-I.dom2.speed.x*Z):I.dom2.position.x%3EI.width-Y&&(I.dom2.position.x=I.width-Y,I.dom2.speed.x=-I.dom2.speed.x*Z),(I.dom2.isAtLeastOneShot||I.dom2.isShooting)&&a%3Eaa+$&&(aa=a,I.dom2.isAtLeastOneShot=!1,ba.push(new%20c(new%20b(I.dom2.position.x+22*I.dom2.direction.x,I.dom2.position.y+22*I.dom2.direction.y),new%20b(I.dom2.direction.x,I.dom2.direction.y)))),J=I.getContext(%222d%22),J.save(),J.clearRect(0,0,I.width,I.height),ba.length%3E0){for(t||(D.style.zIndex=-1e3,I.style.zIndex=-990,q.style.zIndex=-980),M=ba.length,J.fillStyle=%22#000%22,O=l(new%20b(I.dom2.position.x+22*I.dom2.direction.x,I.dom2.position.y+22*I.dom2.direction.y),new%20b(I.dom2.direction.x,I.dom2.direction.y));M--;)ba[M].position.add(new%20b(d*ba[M].direction.x*W,d*ba[M].direction.y*W)),ba[M].position.x%3C0||ba[M].position.x%3EI.width||ba[M].position.y%3C0||ba[M].position.y%3EI.height?ba.splice(M,1):(N=l(ba[M].position),J.fillRect(ba[M].position.x-2,ba[M].position.y-2,4,4),N&&N!=O&&(o(ba[M].position),N.remove?N.remove():N.parentNode.removeChild(N),ba.splice(M,1)));t||(D.style.zIndex=1e3,I.style.zIndex=1005,q.style.zIndex=1010)}if(da.length%3E0)for(M=da.length;M--;)a-da[M].time%3E900?da.splice(M,1):(da[M].position.add(new%20b(d*da[M].direction.x*da[M].speed,d*da[M].direction.y*da[M].speed)),J.globalAlpha=1-(a-da[M].time)/900,J.fillStyle=da[M].color,J.fillRect(da[M].position.x-2,da[M].position.y-2,4,4));J.globalAlpha=1,J.translate(I.dom2.position.x,I.dom2.position.y),J.rotate(I.dom2.direction.getAngle()),J.globalAlpha=ca,1%3Eca&&(ca+=.5*d),J.strokeStyle=%22#000%22,J.fillStyle=%22#558AA1%22,J.lineWidth=2,J.lineCap=%22square%22,J.beginPath(),J.moveTo(-10,12),J.lineTo(20,0),J.lineTo(-10,-12),J.closePath(),J.stroke(),J.fill(),J.restore(),window.requestAnimationFrame&&window.requestAnimationFrame(p.run)}},window.requestAnimationFrame?window.requestAnimationFrame(p.run):setInterval(p.run,1e3/60),p.stop=function(){},!1}b.prototype={RADIANS_FACTOR:Math.PI/180,rotate:function(a){var%20b=a*this.RADIANS_FACTOR,c=this.x,d=this.y;return%20this.x=c*Math.cos(b)-Math.sin(b)*d,this.y=c*Math.sin(b)+Math.cos(b)*d,this},add:function(a){return%20this.x+=a.x,this.y+=a.y,this},multiply:function(a){return%20this.x*=a,this.y*=a,this},getAngle:function(){return%20Math.atan2(this.y,this.x)},length:function(){var%20a=Math.sqrt(this.x*this.x+this.y*this.y);return.005%3Ea&&a%3E-.005?0:a},normalize:function(){var%20a=this.length();return%200!==a?(this.x/=a,this.y/=a):this.x=this.y=0,this}},a.Ignite=d}(window.Dom2),Dom2.Ignite(),console.log(%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22),console.log(%228888888b.%20%20.d88888b.%20888b%20%20%20%20%20d888%20%20%2088888888888888%20%22),console.log('888%20%20%22Y88bd88P%22%20%22Y88b8888b%20%20%20d8888%20%20%20%20%20888%20%20%20%20888%20%20%20'),console.log(%22888%20%20%20%20888888%20%20%20%20%2088888888b.d88888%20%20%20%20%20888%20%20%20%20888%20%20%20%22),console.log(%22888%20%20%20%20888888%20%20%20%20%20888888Y88888P888%20%20%20%20%20888%20%20%20%20888%20%20%20%22),console.log(%22888%20%20%20%20888888%20%20%20%20%20888888%20Y888P%20888%20%20%20%20%20888%20%20%20%20888%20%20%20%22),console.log(%22888%20%20%20%20888888%20%20%20%20%20888888%20%20Y8P%20%20888%20%20%20%20%20888%20%20%20%20888%20%20%20%22),console.log('888%20%20.d88PY88b.%20.d88P888%20%20%20%22%20%20%20888%20%20%20%20%20888%20%20%20%20888%20%20%20'),console.log('8888888P%22%20%20%22Y88888P%22%20888%20%20%20%20%20%20%20888%20%20%2088888888888888%20'),console.log(%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22),console.log(%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20JavaScript%20Hell%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22),console.log(%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22);