7 ms·
Some code you can write in the console to click the button at a certain time: sec10s = document.getElementById("thebutton-s-10s"); sec1s = documen
by PaulJulius 11y ago
Some code you can write in the console to click the button at a certain time:
sec10s = document.getElementById("thebutton-s-10s");
sec1s = document.getElementById("thebutton-s-1s");
sec10ms = document.getElementById("thebutton-s-10ms");
sec100ms = document.getElementById("thebutton-s-100ms");
button = document.getElementById("thebutton");
time = function() {
return sec10s.innerHTML +
sec1s.innerHTML; // +
//sec10ms.innerHTML +
//sec100ms.innerHTML;
};
pressAt = function(timeStr) {
return function() {
if (time() == timeStr) {
button.click();
}
};
};
setInterval(pressAt("00"), 100);
But even with setInterval set to 1, this won't get called every millisecond, so you can't get accuracy to the second decimal point, not that there's really any need to. (It turns out setInterval has a minimum delay. setTimeout's minimum delay is 4ms and likely setInterval's minimum delay is the same.) Just set this up and leave your computer running for the next few months and you ought to get it eventually.
- deleted 11y ago[deleted]
- pests 11y agoHint, check the global variable r.thebutton as alluded to elsewhere in thread.
- zephiro309 11y agoSo, you created code to repeatedly press a button you can only press once?
- TheDong 11y agoNo, to repeatedly check the time the button has and press it once at that time :) The fact that it'll press it again if it hits that time again and do nothing is beside the point; there's no need to add complexity of exiting.
- oh_sigh 11y agoWhat's the benefit of pressing it when it is near 0 seconds? You really want to be the last person to press it before the full 60 seconds expires.
- RockyMcNuts 11y agoyou get nice reddit flair the later your press it :) no way to program it to guarantee you are the last person to ever press it.
- pests 11y agoHow do you know what they really want? Take a closer look at the subreddit and things like an entire class system has developed over which number you get (if you've pressed at all.) Plus, who says the goal is to be the last person who clicks? Maybe the goal is to not click at all!
- oh_sigh 11y agoIt's only relevant because the button is still active. The sub will probably die once the button is deactivated.
- ThrustVectoring 11y agoThat's not the correct strategy for keeping the timer alive as long as possible. If everyone did that, then everyone would simultaneously press it the first time it almost-expires, and nobody would remain for the next time it nearly expires. A better strategy is to pick a random time number that you wait until, biased towards the lower part of the range.
- raldi 11y agoOkay, now if you really want to impress me, pretend you work for reddit and write some code that would catch this kind of script and give it "cheater" flair.
- natrius 11y agoMonkeypatch setInterval/setTimeout to mark people as cheaters. The more dedicated cheaters will hit the button API outside of the browser, which is pretty hard to stop.
- Kurtz79 11y agoFor someone with only limited HTTP/Javascript knowledge: "The more dedicated cheaters will hit the button API outside of the browser, which is pretty hard to stop" How this would be accomplished, I guess from the command line ? EDIT: found what Monkeypatch means.
- tokenizerrr 11y agoThe button presses are communicated over a websocket. You could make your own websocket client and communicate however you want to, such as listening to time updates and sending a click when it reaches a certain treshold.
- tom-lord 11y agoUmm... What?? If you did this, then surely EVERYONE would be flagged as a cheater! Clicking the button "legitimately" would call the same function!
- aidos 11y agoMonkey 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); }
- humanarity 11y agoWhatever your interval duration is you'll get a "reflex speed" of average double that: Shannon-Nyquist sampling theorem. So if you want to play at a 100ms reaction speed sample every 50ms or less. 4ms caps your max reflex time at, say, 10ms. Or about 16x faster than your average human [https://www.biology.usu.edu/files/uploads/Courses/Biology%205610/reflexes.pptx https://www.biology.usu.edu/files/uploads/Courses/Biology%20...] I'm no expert in sampling. Any bona fide experts want to weigh in? That works ! :)
- 3pt14159 11y agoYou will lose as soon as your web socket breaks.
- pharke 11y agoYou can also just listen to the websocket that they are using to update the button (this is without being logged in): var buttonSocket = new WebSocket("wss://wss.redditmedia.com/thebutton?h=3b85664277e270cfd024faee2cc021a359a8af73&e=1429012932"); buttonSocket.onmessage = function (event) { console.log(event.data); } data is just plain json in the form {"type": "ticking", "payload": {"participants_text": "715,197", "tick_mac": "e2dc885fe4836cad86f9cd7670645871e11401f4", "seconds_left": 50.0, "now_str": "2015-04-13-12-33-44"}} That lets you know what the seconds are on the server and you can calculate your own ms (it looks like they do it client side too), just remember that timeouts are not guaranteed to fire exactly at the time you set since it's a single thread. Maybe a webworker could come in handy here but the event triggerd by a message would still be subject to delay if something else wanted to run. requestAnimationFrame is another place you could look or if you can scrape together the details you need to send the button press you could run something in node with more accurate timing.
- deleted 11y ago[deleted]
- ultimape 11y agoProtip, you can hijack jsperf's java ns timer by loading the code in via a data://field to avoid cross-site script loading flags.