News for hackers. Stuff that matters.
Re:The button: social experiment driving Reddit crazy by tom-lord on Monday April 13, 2015 @05:01AM (#9366607)
Umm... What?? If you did this, then surely EVERYONE would be flagged as a cheater! Clicking the button "legitimately" would call the same function!
Re:The button: social experiment driving Reddit crazy by aidos on Monday April 13, 2015 @05:22AM (#9366660)
Monkey patching setTimeout / setInterval would allow you to detect when people were running timers on the page. Use of timers could generally be considered "cheating."

It doesn't do anything to intercept people pushing the button.

    window.setTimeout = function setTimeout(fn, ms) {
        alert("No you don't, cheater!");
        assign_button_color_of_shame();
        original_setTimeout(fn, ms);
    }
Re:The button: social experiment driving Reddit crazy by nkozyra on Monday April 13, 2015 @08:07AM (#9367130)
Which is very, very easily worked around by including another version of the original setTimeout in your console code.

The only real way to detect this is through usage pattern analysis and detection on the web socket side, because if you can write something in JS that catches people, someone can make minor modifications to their code to make it work again.

Re:The button: social experiment driving Reddit crazy by aidos on Monday April 13, 2015 @08:38AM (#9367240)
Just to be clear - this wasn't my original idea and nobody should ever put any security code into a client. Even if you could make this work someone could recompile Chrome to work around it.

I've found a way to get access to the original setTimeout again by embedding an iframe into the page and extracting it from there.

Would be interested in hearing other methods of getting a handle to the original setTimeout again.

I guess you could simulate it by using some other mechanism, say firing off an async request to a server that returns after a certain time and running a callback.

Re:The button: social experiment driving Reddit crazy by MichaelGG on Monday April 13, 2015 @02:49PM (#9369567)
Eh putting security into a client like FB did disabling the console -- it might help against people getting phished. Though I generally agree.
Re:The button: social experiment driving Reddit crazy by tom-lord on Monday April 13, 2015 @06:24AM (#9366811)
Ohh right, so your plan would be to essentially check for third-party javascript things running on the same page?

This would be a really easy "security" measure to circumvent, though - I could literally just delete your monkey patch, for a start!

Re:The button: social experiment driving Reddit crazy by aidos on Monday April 13, 2015 @07:58AM (#9367093)
It wasn't my idea so, no, that was never my plan :)

Though, you do raise a valid point, so let's see how it plays out.

    setTimeout = function(){...}
    delete setTimeout  // true - you've removed the patch

    window.setTimeout = function(){...}
    delete window.setTimeout  // true - you've removed the patch

    window.constructor.prototype.setTimeout = function(){...}
    delete window.constructor.prototype.setTimeout  // false - the patch is still there!
I don't know about the hierarchy of the prototype chain up at this level but it seems to work.

Maybe there's some other way of getting to the built-in setTimeout so you can create your own version to mask the one I added?

EDIT you can embed an iframe and rip the native setTimeout from there.

Re:The button: social experiment driving Reddit crazy by towelguy on Monday April 13, 2015 @05:37PM (#9370668)
They could listen to the DOMSubtreeModified event in the 10s div.
Re:The button: social experiment driving Reddit crazy by aidos on Monday April 13, 2015 @05:50PM (#9370737)
Nice! There are probably clocks all over the place when you start looking around :)
Re:The button: social experiment driving Reddit crazy by zedadex on Monday April 13, 2015 @01:02PM (#9368830)
reddit stops you from embedding it iirc
Re:The button: social experiment driving Reddit crazy by aidos on Monday April 13, 2015 @02:44PM (#9369530)
I tried that too - you can just use any old page that has CORs headers allowing it.