DEV Community

Cover image for console.fun() or how to mess up the DOM
jan paul
jan paul

Posted on

1 2

console.fun() or how to mess up the DOM

I stumbled upon this little gem in the vue-land #random channel and it made me smile. Posted by xan#2554.

Thought maybe it can make you smile too and decided to share it to you. Have fun.

Instructions

  1. copy script
  2. visit your most preferred website -- ..most likely dev.to 😜
  3. open console
  4. paste script and press enter
(function funnyFunction() {
  var screenwidth = window.innerWidth;
  var screenheight = window.innerHeight;
  document.querySelectorAll('body *').forEach(function(node) {
    randT = Math.floor(Math.random() * screenheight);
    randL = Math.floor(Math.random() * screenwidth);
    node.setAttribute('style', 'transition-duration:500ms; transition-property: left, top; position: fixed; top:'+randT+'px; left:'+randL+'px');
  });
  setInterval(funnyFunction, 500);
})();
Enter fullscreen mode Exit fullscreen mode

Be honest to yourself, did you knew what will happen?

cheers

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay