Sunday, 17 April 2011

Javascript Tricks

I have read a few tricks across my travel through the Internets in regards to Javascript.

JavaScript, also known as ECMAScript is a prototype-based, object-oriented scripting language that is dynamic, weakly typed and has first-class functions. - http://en.wikipedia.org/wiki/JavaScript

Now when i say tricks i mean something that manipulates the code of a site in a non harmful way to create personal enjoyment. You can also use these to benefit yourself or show off to friends. What ever order comes first.

All of the code presented can be copied and pasted into the URL bar. Hit enter and enjoy. Also it may help if JavaScript is turned on in your browser. 

Master Editor:

So anyhow here is some code to help you edit your site faster, or pretend to be editing a site in real time.

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

My personal favorite. Takes all images off the site and creates a Ferris wheel with them. 

Image Vortex:


javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);

 If you look carefully in the above code, its rotating the HTML “img” tag. Just replace it with “a” or “p” and watch some links or text rotate instead of images.

 Tremors:

Your screen is going to love this one.

avascript:function flood(n) {if (self.moveBy) {for (i = 200; i > 0;i--){for (j = n; j > 0; j--) {self.moveBy(1,i); self.moveBy(i,0);self.moveBy(0,-i); self.moveBy(-i,0); } } }}flood(6);{ var inp = "D-X !msagro na dah tsuj resworb rouY"; var outp = ""; for (i = 0; i <= inp.length; i++) {outp =inp.charAt (i) + outp ; } alert(outp) ;}; reverse 

 Sketchy Site, Inspect it:

If you find a site that you feel you cannot trust. You want to verify that it is authentic. You can with this.

javascript:alert("The actual URL is:\t\t" + location.protocol + "//" + location.hostname + "/" + "\nThe address URL is:\t\t" + location.href + "\n" + "\nIf the server names do not match, this may be a spoof.");

Roll up your broswer Katamari style:

javascript:var h='http://dl.dropbox.com/u/1881429/Katamari/',i,n,ss=['http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js',h+'Renderables.js',h+'Game.js'];for(i=0;i<ss.length;i++){n=document.createElement("script");n.src=ss[i]+'?'+Date.now();document.head.appendChild(n);}

This code only works for chrome and safari.  Thanks to "mac and me" for posting a comment about this.

Basic Calculator:
 Possibly the most helpful out of these tricks. 

javascript: alert(69696-76543+555);

Change the numbers inside the alert function to create your own equations. You can also not include numbers in the function, but instead write any comment that you want displayed like. Your computer will self destruct in 10 seconds. Freak your friends out. Have fun.





8 comments:

  1. have you seen the one that mimics the katamari damacy game allowing you to scoop up everything on a site into a large ball. good stuff. Imma try yours.

    ReplyDelete
  2. I think I have to enable javascript because I can't get it to work or maybe because I'm a noob lol

    ReplyDelete
  3. Nevermind I got it working, I can move everything :D

    ReplyDelete
  4. very appreciated info indeed

    ReplyDelete
  5. Very useful for websites thanks!

    Please follow my blog!

    katofinance.blogspot.com

    ReplyDelete
  6. I like the ferris wheel one. makes my eyes spin!

    ReplyDelete
  7. i am a javascript wizard myself :3
    checkout http://mac-and-i.blogspot.com/2011/03/how-to-integrate-lightbox-in-your-blog.html
    and
    http://mac-and-i.blogspot.com/2011/03/this-is-how-i-roll-katamari-hack-for.html

    ReplyDelete