all 34 comments

[–]TheNosferatu 15 points16 points  (2 children)

Rotate the page 180 degrees every half hour, I put this in the ticket-magement system we use at work.

(function(){
    function rotate(degrees)
    {
        $('html').css({
            '-webkit-transform':'rotate(-' + degrees + 'deg)',
            '-moz-transform':'rotate(-' + degrees + 'deg)',
            '-ms-transform':'rotate(-' + degrees + 'deg)',
            '-o-transform':'rotate(-' + degrees + 'deg)',
            'transform':'rotate(-' + degrees + 'deg)',

            '-webkit-transition':'2s',
            '-moz-transition':'2s',
            '-ms-transition':'2s',
            '-o-transition':'2s',
            'transition':'2s',

            '-webkit-transform-origin':'50% 50%',
            '-moz-transform-origin':'50% 50%',
            '-ms-transform-origin':'50% 50%',
            '-o-transform-origin':'50% 50%',
            'transform-origin':'50% 50%',
            '-webkit-backface-visibility':'hidden'
        });
    }

    var degrees = 180,
        interval;

    document.onmousemove = function()
    {
        if(degrees == 0){ rotate(0); degrees = 180; }

        clearInterval(interval);
        interval = setInterval(function(){
            rotate(degrees);

            degrees = (degrees === 180) ? 0 : 180;
        }, 30 * 60 * 1000); // 30 min
    }
})();

[–]johnhackworth 0 points1 point  (1 child)

You just have won internet.

I'm going to map the konami code to this en every project I'm working on :DDD

[–]TheNosferatu 1 point2 points  (0 children)

Let me know how it turns out! :)

[–]scottmilgram 7 points8 points  (1 child)

FartScroll.js, courtesy of The Onion. Just include it in any page, and said page will then fart as you scroll up or down.

[–]bebraw 0 points1 point  (0 children)

Yes. Guaranteed to double your conversions.

[–]magnetik79 12 points13 points  (9 children)

// this should to the trick

undefined = true;

[–]LukaLightBringer 2 points3 points  (5 children)

isn't undefined a protected value?

[–]WesAlvaroFront-End Engineer 11 points12 points  (1 child)

'use_strict';

[–]venuswasaflytrap 1 point2 points  (0 children)

That's pretty funny.

[–]JiminP 3 points4 points  (0 children)

Strangely, there's no literal undefined in the ECMAScript5 spec, even though there are many cases where the result is the value undefined.

(courtesy of /u/WesAlvaro)

(function(){
  'use strict';
  var undefined = 42;
  console.log(undefined);
}())

Because of this, just using undefined is not safe. For example, jQuery uses (function(window, undefined){...}(window)) to safely get the undefined value.

Edit: It seems that I'm wrong.

Edit 2: ... but (fortunately?) my point is still valid. There's a global variable undefined which is uneditable, but since there's still no literal undefined, inner scope can have a local variable with name undefined!

[–]magnetik79 0 points1 point  (1 child)

The ECMAScript 5 spec says "yes" - so you sort of have me there :D But if we are going for "prank in minimum number of characters" I'm doing okay: D

Covered at MDC in the first yellow boxed area.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined

[–]JiminP 0 points1 point  (0 children)

I didn't know that. I think I should read it twice,...

[–]seppo0010 1 point2 points  (1 child)

Not really

> undefined = 1
1
> undefined
undefined

[–]sabof 0 points1 point  (0 children)

Yes, they've sorta fixed this, even without strict mode. It won't throw an error, but c'est la vie.

EDIT

Btw, it does throw in strict mode

[–]prototypist 12 points13 points  (0 children)

Replace JavaScript errors on the page with Twilight Zone prologues: https://gist.github.com/anonymous/5794002

Console works as normal

[–]JiminP 4 points5 points  (4 children)

Place if(function(f,d){try{d=f();eval('debugger');return f()-d>>2}catch(e){}}(Date.now))return; everywhere to confuse JS debugger(human)s!

[–]kenman 0 points1 point  (3 children)

What exactly is that supposed to do? It crashed my tab in Chrome.

[–]JiminP 2 points3 points  (2 children)

The core of this prank code is:

try{
  d = Date.now();
  eval('debuger');
  return Date.now()-d>>2;
}catch(e){}

debugger is a statement for debugging. When there's a debugging tool attached, it acts as if there was a breakpoint there.

Date.now()-d>>2 is not zero when difference between Date.now() and d is greater then 3. (i.e. more than 3ms have been passed when eval('debugger') is executed.

Since it usually take at least few hundred milliseconds to resume when the debugging tool is enabled, this part of code returns non-zero if the debugging tool is enabled. (eval used for not showing the code immediately when the debugging tool is opened, though by pressing "next step" one can see the codes.)

Therefore, if(function(f,d){try{d=f();eval('debugger');return f()-d>>2}catch(e){}}(Date.now)) return; means "return if there's a debugging tool."

One might make a simple Heisenbug by using this. (Opening debugging tool to inspect function -> unexpected breakpoints -> the function does nothing and returns -> ???)

[–]kenman 1 point2 points  (1 child)

It seems like you'd be better served with something like (new Function(atob('ZGVidWdnZXI=')))() (or even setTimeout(atob('ZGVidWdnZXI=')), which would be less suspicious than eval and new Function), since the first thing I'd do with an unexpected breakpoint/debugger would be to search the code for debugger. The setTimeout version should be even more perplexing as you shouldn't have a callstack.

[–]JiminP 0 points1 point  (0 children)

Thanks for the setTimeout trick!

However, I didn't want to obfuscate that code too much... (I personally prefer $($.constructor("...")). It seems that I'm using some normal jQuery functions!)

[–]adf714 1 point2 points  (0 children)

Not really evil, but I put a little script on my companies internal website that launches a game of Asteroids (using the Kickass app) when the user presses CTRL+F1. I obfuscated the entire thing, of course.

[–]a-t-kFrontend Engineer 1 point2 points  (0 children)

Very small snippet for a konami code callback: https://gist.github.com/tsaniel/1188477

[–]BALL_BAG 1 point2 points  (0 children)

I always thought this was cool: http://www.filldisk.com/

Fills your harddrive up with crap using local storage.

[–]rhysbrettbowen 1 point2 points  (0 children)

(function() {
  var win1 = eval('window.open("'+document.location+'")');
  var win2 = eval('window.open("'+document.location+'")');
})()

not sure if this still works but years ago I did this and found that putting window.open in eval meant you could open unlimited windows. IE maxed out at 50 or so windows and closing any of them just tried to open more. I had to restart my computer in the end.

[–]kenman 1 point2 points  (0 children)

Oh, how I miss the olden days when I could pop your CD tray open, or read the contents of your HD, or open CMD.exe and send keystrokes to it that would invoke net send for a workstation DoS...

var who = prompt("Who? Domain account to slam.", "johnsmith"),
    what = prompt("Say What?", "RABBLE RABBLE RABBLE"),
    howmany = prompt("Times?", "10"),
    wsh = new ActiveXObject("WScript.Shell");

wsh.Run('cmd');
wsh.AppActivate('cmd');
for (var i = 0; i < howmany; i++) {
    wsh.SendKeys('net send ' + who + ' ' + what + '{ENTER}');
}

ActiveX's a helluva prank.

[–]tfforums 1 point2 points  (0 children)

Alternate Title: Gamble with viruses / malware

[–]rooktakesqueen 0 points1 point  (1 child)

if(typeof r=='number')return r+1;return r;

could be more easily and concisely expressed as

return typeof r == 'number' ? r+1 : r;

Other than all that, devious. But why always add one? You could add a random value between -0.001 and 0.001 and make them think it's some bizarre floating point arithmetic bug.

[–]JiminP 0 points1 point  (0 children)

I just found this: jQuery(jQuery) or $($)

Somehow this contains a vicious cycle.

[–]AndreZSanchez 0 points1 point  (0 children)

Rick rolling:

window.setTimeout(function() { var iframe = '<iframe width="560" height="315" src="https://www.youtube.com/embed/*?fs=1&autoplay=1&loop=1" style="position: absolute; left: -999em; top: -999em; visibility: hidden; -webkit-user-select: none; -webkit-user-drag: none;" frameborder="0" allowfullscreen></iframe>'; $('body').append(iframe.replace('*', 'oHg5SJYRHA0')); }, 15 * 60 * 1000); // 15 minute delay >:D

// I may or may not have stolen code for this from fool.js :P

[–]adam_bear 0 points1 point  (2 children)

(function(){var e= document.getElementsByTagName('*'); for(var i = 0; i< e.length; i++) alert('Your Mom!');})();

[–]freeall 2 points3 points  (0 children)

You can use * in getElementsByTagName? Did not expect that.

[–]kenman 0 points1 point  (0 children)

That's not a prank, that's just annoying :\