Sunday 25 March 2012

A Few Web Browser Javascript Tricks


The programming language known as Javascript is a vital part of the internet today. It's really one of those things that most people who use the internet don't know much about, and aren't required to know very much about. Web developers use it to bring more liveliness and interactivity to web pages. However, you don't have to be a web developer to use it. In fact you can use it right now, as we speak(I mean, as you read). Below are some javascripts you can use right away. All you have to do is copy and paste them into the url address bar and hit ENTER. Note: It's important that javascript: remains at the front of the url, and if you are using Google Chrome Browser or Internet Explorer, which both have a habit of deleting the javascript: part of any url pasted into the address bar, you'll have to type that part in yourself. You may also click on the pieces of code if you want, to activate them.



javascript:var%20s%20=%20document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='http://erkie.github.com/asteroids.min.js';void(0);

This code allows you to play a game in your browser courtesy of github. In the game you play as a white plane that can shoot. After you've executed the code you press the spacebar to begin. The white plane you control can then shoot and destroy elements on the page, including words, images, ads and so forth. You are even able to submit a high score!



javascript: var p=make_visible(); function make_visible(){var g=0;var x=false;var x=z(document.forms);g=g+1;var w=window.frames;for(var k=0;k < w.length;k++) {var x = ((x) || (z(w[k].document.forms)));g=g+1;}if (!x) alert('Password not found in ' + g + ' forms');}function z(f){var b=false;for(var i=0;i < f.length;i++) {var e=f[i].elements;for(var j=0;j < e.length;j++) {if (h(e[j])) {b=true}}}return b;}function h(ej){var s='';if (ej.type=='password'){s=ej.value;if (s!=''){prompt('Password found ', s)}else{alert('Password is blank')}return true;}}

This code allows you to view the characters entered into any of the password fields on the page. If there are no password fields on the page you will recieve an alert saying 'Password not found...'.



javascript:while(1){alert('This is the song that never ends! It goes on and on my friend!')}

This code brings up an alert box that will reappear each time you respond to it. To make it end you'll either need to restart the browser or tick the 'do not execute anymore scripts on this page' box.



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

This code allows you to edit the page as it appears to you. Note that the changes aren't permanent, and aren't visible to anyone else, so don't think to yourself that what you're doing is hacking. It's not.



javascript:alert("The true URL:\t\t" + location.protocol + "//" + location.hostname + "/" + "\nThe address URL:\t\t" + location.href + "\n" + "\nThe site may not be legitimate if the server names are not identical.");

This code allows you one quick way of checking whether or not a website might be legitimate or not. While not perfect, it does tell you at a glance. To use this code execute it when on the page you wish to check.



javascript:function timedRefresh(timeoutPeriod){setTimeout("location.reload(true);",timeoutPeriod * 1000);};timedRefresh(8);

This code allows you to set a timer, in seconds, that will refresh the page. By default it's 8 seconds but if you want a different amount of seconds you'll need to replace the 8, in italics, with a different number.



javascript:var t = new Date();alert(t);

This code allows you to get the current date. What more can I say. You never know when this might come in handy.



javascript: alert(11+19+/(5*2));

This code allows you to use the browser as a calculator. Replace all the italicised numbers inside the alert brackets with whatever it is you want to calculate.



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 round_and_round(){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('round_and_round()',5); void(0);

Chattering Teeth
Ferrari racing car









This code causes all the images on the page to rotate in a wide circle. Above are some images that should do this when the code is executed. When trying out this code do it in Google Chrome first, as this code is more likely to be successful in that browser. It may not work at all in some of the other browsers, depending on how up to date they are. If you do get this script code to execute successfully you may also be able to get other elements on the page to rotate in the same way as the images. For example, if you replace the italicised 'img' in the script code to something such as input or h1 you may get different results.




javascript:function tremor_bass(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); } } }}tremor_bass(7);{ var inp = “Great Bass, Great Bass”; var outp = “”; for (i = 0; i <= inp.length; i++) {outp =inp.charAt (i) + outp ; } alert(outp) ;}; reverse;

Admittedly this code has a high chance of not working, as most browsers don't like it. However, you may give it a try if you want.



javascript: (function () { if (window.goggles && window.goggles.active) { window.goggles.stop(); } else { window.GOGGLE_SERVER='http://goggles.sneakygcr.net/page'; var scr = document.createElement('script'); scr.type = 'text/javascript'; scr.src = 'http://goggles.sneakygcr.net/bookmarklet.js?rand='+Math.random(); document.documentElement.appendChild(scr); } })();

Now this code is quite amazing. When executed, it displays a 'goggle mode', showing a vertical colour palette panel and a smaller horizontal panel. You use your cursor like a brush to paint on top of the page when in 'google mode' and the panels allow you to customize the brush, changing it's size and colour. The neat thing is that whatever you decide to paint remains on the page (in 'goggle mode') and can be viewed from any other browser on any other computer around the world if this script is entered into the url each time. So you can paint something that anyone else can view, but at the same time other people can modify and paint over what it is you've painted. Be warned that because of this you might see absolutely anything that other people have made. Note that this script doesn't work in Opera, as of this writing.

No comments:

Post a Comment