2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

糞コードは直すな!ぶっ壊せ! ブックマークレット対応版

Posted at

Javascriptのブックマークレットにしてみました。ご活用ください。

偉大なる本家様:

JS Bookmark
javascript:var%20%24jscomp%3D%24jscomp%7C%7C%7B%7D%3B%24jscomp.scope%3D%7B%7D%3B%24jscomp.createTemplateTagFirstArg%3Dfunction(b)%7Breturn%20b.raw%3Db%7D%3B%24jscomp.createTemplateTagFirstArgWithRaw%3Dfunction(b%2Cc)%7Bb.raw%3Dc%3Breturn%20b%7D%3B%24jscomp.arrayIteratorImpl%3Dfunction(b)%7Bvar%20c%3D0%3Breturn%20function()%7Breturn%20c%3Cb.length%3F%7Bdone%3A!1%2Cvalue%3Ab%5Bc%2B%2B%5D%7D%3A%7Bdone%3A!0%7D%7D%7D%3B%24jscomp.arrayIterator%3Dfunction(b)%7Breturn%7Bnext%3A%24jscomp.arrayIteratorImpl(b)%7D%7D%3B%0A%24jscomp.makeIterator%3Dfunction(b)%7Bvar%20c%3D%22undefined%22!%3Dtypeof%20Symbol%26%26Symbol.iterator%26%26b%5BSymbol.iterator%5D%3Bif(c)return%20c.call(b)%3Bif(%22number%22%3D%3Dtypeof%20b.length)return%20%24jscomp.arrayIterator(b)%3Bthrow%20Error(String(b)%2B%22%20is%20not%20an%20iterable%20or%20ArrayLike%22)%3B%7D%3B%24jscomp.arrayFromIterator%3Dfunction(b)%7Bfor(var%20c%2Ca%3D%5B%5D%3B!(c%3Db.next()).done%3B)a.push(c.value)%3Breturn%20a%7D%3B%24jscomp.arrayFromIterable%3Dfunction(b)%7Breturn%20b%20instanceof%20Array%3Fb%3A%24jscomp.arrayFromIterator(%24jscomp.makeIterator(b))%7D%3B%0Avar%20racket%3Ddocument.createElement(%22div%22)%2CracketWidth%3D100%2CracketX%3D(window.innerWidth-racketWidth)%2F2%3Bracket.style.width%3DracketWidth%2B%22px%22%3Bracket.style.height%3D%2220px%22%3Bracket.style.backgroundColor%3D%22%23FFD700%22%3Bracket.style.position%3D%22fixed%22%3Bracket.style.top%3D%2275%25%22%3Bracket.style.left%3DracketX%2B%22px%22%3Bdocument.body.appendChild(racket)%3Bvar%20animeId%3Dnull%2CcodeFrameSet%3Dnew%20Set%2CracketSpeedX%3D8%2CshotFrameCount%3D0%2CshotFrameMaxCount%3D5%2CisPressed%3D%7Bleft%3A!1%2Cright%3A!1%2Cspace%3A!1%7D%2CisResize%3D!1%3B%0Afunction%20handleKeyDown(b)%7Bif(%22ArrowLeft%22%3D%3D%3Db.code)isPressed.left%3D!0%3Belse%20if(%22ArrowRight%22%3D%3D%3Db.code)isPressed.right%3D!0%3Belse%20if(%22Space%22%3D%3D%3Db.code)b.preventDefault()%2CisPressed.space%7C%7C(shotFrameCount%3D0)%2CisPressed.space%3D!0%3Belse%20if(%22KeyR%22%3D%3D%3Db.code)%7BcancelAnimationFrame(animeId)%3Bb%3D%24jscomp.makeIterator(codeFrameSet)%3Bfor(var%20c%3Db.next()%3B!c.done%3Bc%3Db.next())c%3Dc.value%2Cc.balls.forEach(function(a)%7Ba.parentNode.removeChild(a)%7D)%2Cc.balls%3D%5B%5D%2Cc.codeSpans%3D%5B%5D.concat(%24jscomp.arrayFromIterable(c.querySelectorAll(%22code%20span%22)))%2C%0Ac.codeSpans.forEach(function(a)%7Ba.style.visibility%3D%22%22%7D)%3Bupdate()%7Delse%20if(%22KeyQ%22%3D%3D%3Db.code)%7BcancelAnimationFrame(animeId)%3Bdocument.removeEventListener(%22keydown%22%2ChandleKeyDown)%3Bdocument.removeEventListener(%22keyup%22%2ChandleKeyUp)%3Bdocument.body.removeChild(racket)%3Bb%3D%24jscomp.makeIterator(codeFrameSet)%3Bfor(c%3Db.next()%3B!c.done%3Bc%3Db.next())c%3Dc.value%2Cc.balls.forEach(function(a)%7Ba.parentNode.removeChild(a)%7D)%2Cc.balls%3D%5B%5D%2Cc.querySelectorAll(%22code%20span%22).forEach(function(a)%7Ba.style.visibility%3D%22%22%7D)%2Cc.codeSpans%3D%5B%5D%3BcodeFrameSet%3D%0Anull%7D%7Dfunction%20handleKeyUp(b)%7B%22ArrowLeft%22%3D%3D%3Db.code%3FisPressed.left%3D!1%3A%22ArrowRight%22%3D%3D%3Db.code%3FisPressed.right%3D!1%3A%22Space%22%3D%3D%3Db.code%26%26(isPressed.space%3D!1)%7Ddocument.addEventListener(%22keydown%22%2ChandleKeyDown)%3Bdocument.addEventListener(%22keyup%22%2ChandleKeyUp)%3Bwindow.addEventListener(%22resize%22%2Cfunction()%7BisResize%3D!0%7D)%3B%0Afunction%20createBall(b%2Cc)%7Bvar%20a%3Ddocument.createElement(%22div%22)%3Ba.diameter%3D20%3Ba.x%3Db-a.diameter%2F2%3Ba.y%3Dc-a.diameter%2F2%3Ba.speedX%3DgetRandomSpeed(.5%3EMath.random()%3F-1%3A1)%3Ba.speedY%3DgetRandomSpeed(-1)%3Ba.canHitRacket%3D!1%3Ba.style.width%3Da.diameter%2B%22px%22%3Ba.style.height%3Da.diameter%2B%22px%22%3Ba.style.backgroundColor%3D%22hsl(%22%2B359*Math.random()%2B%22%20100%25%2050%25)%22%3Ba.style.borderRadius%3D%2250%25%22%3Ba.style.position%3D%22absolute%22%3Ba.style.left%3Da.x%2B%22px%22%3Ba.style.top%3Da.y%2B%22px%22%3Breturn%20a%7D%0Afunction%20update()%7B%2B%2BshotFrameCount%3EshotFrameMaxCount%26%26(shotFrameCount%3D1)%3Bif(isResize)%7BisResize%3D!1%3Bfor(var%20b%3D%24jscomp.makeIterator(codeFrameSet)%2Cc%3Db.next()%3B!c.done%3Bc%3Db.next())%7Bvar%20a%3Dc.value%2Ce%3Da.getBoundingClientRect()%3Bc%3D%24jscomp.makeIterator(a.codeSpans)%3Bfor(a%3Dc.next()%3B!a.done%3Ba%3Dc.next())%7Ba%3Da.value%3Bvar%20f%3Da.getBoundingClientRect()%3Ba.x%3Df.x-e.x%3Ba.y%3Df.y-e.y%3Ba.width%3Df.width%3Ba.height%3Df.height%7D%7D%7DisPressed.left%26%26(racketX-%3DracketSpeedX%2Cracket.style.left%3DracketX%2B%22px%22)%3BisPressed.right%26%26(racketX%2B%3DracketSpeedX%2Cracket.style.left%3D%0AracketX%2B%22px%22)%3Bb%3Dracket.getBoundingClientRect()%3Bif(isPressed.space%26%261%3D%3D%3DshotFrameCount)for(a%3Ddocument.elementsFromPoint(b.x%2Bb.width%2F2%2Cb.y%2Bb.height%2F2)%2Ca%3D%24jscomp.makeIterator(a)%2Ce%3Da.next()%3B!e.done%3Be%3Da.next())if(e%3De.value%2Ce.classList.contains(%22code-frame%22))%7Bc%3De.getBoundingClientRect()%3Bif(!codeFrameSet.has(e))for(codeFrameSet.add(e)%2Ce.codeSpans%3D%5B%5D.concat(%24jscomp.arrayFromIterable(e.querySelectorAll(%22code%20span%22)))%2Cf%3D%24jscomp.makeIterator(e.codeSpans)%2Ca%3Df.next()%3B!a.done%3Ba%3Df.next())%7Ba%3Da.value%3Bvar%20g%3Da.getBoundingClientRect()%3B%0Aa.x%3Dg.x-c.x%3Ba.y%3Dg.y-c.y%3Ba.width%3Dg.width%3Ba.height%3Dg.height%7Da%3DcreateBall(b.x-c.x%2Bb.width%2F2%2Cb.y-c.y%2Bb.height%2F2)%3Be.appendChild(a)%3Bvoid%200%3D%3D%3De.balls%26%26(e.balls%3D%5B%5D)%3Be.balls.push(a)%3Bbreak%7Da%3D%24jscomp.makeIterator(codeFrameSet)%3Bc%3Da.next()%3Bfor(e%3D%7B%7D%3B!c.done%3Be%3D%7BcodeFrame%24jscomp%244%3Ae.codeFrame%24jscomp%244%7D%2Cc%3Da.next())%7Be.codeFrame%24jscomp%244%3Dc.value%3Bc%3De.codeFrame%24jscomp%244.getBoundingClientRect()%3Bf%3D%7B%7D%3Bf.x%3Db.x-c.x%3Bf.y%3Db.y-c.y%3Bf.width%3Db.width%3Bf.height%3Db.height%3Bg%3D%5B%5D%3Bfor(var%20k%3D0%3Bk%3Ce.codeFrame%24jscomp%244.balls.length%3Bk%2B%2B)%7Bvar%20d%3D%0Ae.codeFrame%24jscomp%244.balls%5Bk%5D%3BballPrevY%3Dd.y%3Bd.x%2B%3Dd.speedX%3Bd.y%2B%3Dd.speedY%3B0%3E%3Dd.x%3F(d.x%3D0%2Cd.speedX%3D-d.speedX)%3Ad.x%2Bd.diameter%3E%3De.codeFrame%24jscomp%244.clientWidth%26%26(d.x%3De.codeFrame%24jscomp%244.clientWidth-d.diameter%2Cd.speedX%3D-d.speedX)%3Bif(0%3E%3Dd.y)d.y%3D0%2Cd.speedY%3D-d.speedY%3Belse%20if(d.y%3E%3De.codeFrame%24jscomp%244.clientHeight)%7Bg.unshift(k)%3Bd.parentNode.removeChild(d)%3Bcontinue%7Dfor(var%20n%3D%5B%5D%2Cl%3D0%2Ch%3D0%3Bh%3Ce.codeFrame%24jscomp%244.codeSpans.length%3Bh%2B%2B)%7Bvar%20m%3De.codeFrame%24jscomp%244.codeSpans%5Bh%5D%3B0%3D%3D%3Dh%26%26(l%3Dm.getBoundingClientRect().x-%0Ac.x%2Cl%3Dm.x-l)%3BisHit(d%2Cm%2Cl)%26%26(n.unshift(h)%2Cm.style.visibility%3D%22hidden%22)%7D0%3Cn.length%26%26(n.forEach(function(p)%7Breturn%20function(q)%7Breturn%20p.codeFrame%24jscomp%244.codeSpans.splice(q%2C1)%7D%7D(e))%2Cd.speedX%3D-d.speedX%2Cd.speedY%3D-d.speedY)%3BisHit(d%2Cf)%3Fd.canHitRacket%26%26(d.speedX%3DgetRandomSpeed(0%3Cd.speedX%3F1%3A-1)%2Cd.speedY%3DgetRandomSpeed(0%3Cd.speedY%3F-1%3A1)%2Cd.canHitRacket%3D!1)%3Ad.canHitRacket%3D!0%3Bd.style.left%3Dd.x%2B%22px%22%3Bd.style.top%3Dd.y%2B%22px%22%7D0%3Cg.length%26%26g.forEach(function(p)%7Breturn%20function(q)%7Breturn%20p.codeFrame%24jscomp%244.balls.splice(q%2C%0A1)%7D%7D(e))%7DanimeId%3DrequestAnimationFrame(update)%7Dfunction%20getRandomSpeed(b)%7Breturn(5*Math.random()%2B2)*(void%200%3D%3D%3Db%3F1%3Ab)%7Dfunction%20isHit(b%2Cc%2Ca)%7Bvar%20e%3Db.x%2Bb.diameter%2F2%2Cf%3Db.y%2Bb.diameter%2F2%3Ba%3Dc.x-(void%200%3D%3D%3Da%3F0%3Aa)%3Ba%3Dclamp(e%2Ca%2Ca%2Bc.width)%3Bc%3Dclamp(f%2Cc.y%2Cc.y%2Bc.height)%3Breturn%20b.diameter%2F2%3E%3DMath.sqrt(Math.pow(e-a%2C2)%2BMath.pow(f-c%2C2))%7Dfunction%20clamp(b%2Cc%2Ca)%7Breturn%20b%3Cc%3Fc%3Ab%3Ea%3Fa%3Ab%7Dupdate()%3B

変換方法

1.こちらのサイトを参考に圧縮
2.上のサイトでブックマークレットに変換

開発者コンソールが開けないiPadでも使えました(汗)

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?