Live data from Hacker News

Show HN: Speedsums

speedsums.com

41–50 of 63 posts

Re: Show HN: Speedsums

#42
The 'motivational' comments were hilarious and refreshing. I strongly disagree with the other advice you've been given here.

Don't 'turn it up to 11' to remove all the subtlety and ram the joke down people's throats. And don't turn it into "Oops, try harder next time!" like every other insipid thing in the world. Please. You made something that made me laugh. As much as I love HN, it's a strange, unrepresentative community and you should be very careful trying to appease the crowd here, which always bristles at anything that breaks character. People here are sometimes too focused on how to churn out templated startups, and not enough on art.

Re: Show HN: Speedsums

#46
post #30
post #15

cheat = function() { text = $('#question').text().substr(0, $('#question').text().length - 3).replace('÷', '/').replace('x', '*') $('#answer').val(eval(text)) }

Noob question: how would you... use that cheat?

https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

Re: Show HN: Speedsums

#47
post #19
post #7

This is cool. I would like to make it multiplayer with websockets. Similar to an old multiplayer math game I made in school. http://get24.jit.su

How do you play? I tried to click on the "Help" button, but it didn't work, so I have no idea what to do.

use basic number operations */ + or - without combining digits to get 24

Re: Show HN: Speedsums

#48
// run in firebug and click & enter input... $('#answer').click(function(e){ var value = eval($('#question').text().replace('=', '').replace('÷', '/').replace('x', '*').replace(/\s/g, '')); console.log($('#question').text() + value); this.value = value; })

Re: Show HN: Speedsums

#49
I went all the way, simulated keydowns and all. (Thanks, http://stackoverflow.com/questions/4158847/is-there-a-way-to...)

var element = document.getElementById('answer');var y = document.getElementById('question');var dispatchKeyboardEvent = function(target, initKeyboradEvent_args) {var e = document.createEvent("KeyboardEvents");e.initKeyboardEvent.apply(e, Array.prototype.slice.call(arguments, 1));target.dispatchEvent(e);};var dispatchTextEvent = function(target, initTextEvent_args) {var e = document.createEvent("TextEvent");e.initTextEvent.apply(e, Array.prototype.slice.call(arguments, 1));target.dispatchEvent(e);};var dispatchSimpleEvent = function(target, type, canBubble, cancelable) {var e = document.createEvent("Event");e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));target.dispatchEvent(e);};var send_key = function (key) {var canceled = !dispatchKeyboardEvent(element,'keydown', true, true, null, key, 0, '');dispatchKeyboardEvent(element, 'keypress', true, true, null, key, 0, '');if (!canceled) {if (dispatchTextEvent(element, 'textInput', true, true, null, key, 0)) {element.value += key;dispatchSimpleEvent(element, 'input', false, false);dispatchSimpleEvent(element, 'change', false, false);}}dispatchKeyboardEvent(element, 'keyup', true, true, null, key, 0, '');}; y.addEventListener('DOMNodeInserted', function(e){var z = eval(y.innerHTML.replace(/[=\s]/g,'').replace(/x/ig, '*').replace(/÷/g, '/')).toString(); for(var i in z){send_key(z[i]); element.value+=z[i];}});

Re: Show HN: Speedsums

#50
post #49

I went all the way, simulated keydowns and all. (Thanks, http://stackoverflow.com/questions/4158847/is-there-a-way-to... ) var element = document.getElementById('answer');var y = document.getElementById('question');var dispatchKeyboardEvent = function(target, initKeyboradEvent_args) {var e = document.createEvent("KeyboardEvents");e.initKeyboardEvent.apply(e, Array.prototype.slice.call(arguments, 1));target.dispatchEv…

You beat by a few minutes. I wrote a Chromium extension for it:

cs.js:

    (function(){var b;var a=function(){if(b!==undefined){var e=document.querySelector("input#answer");
    e.value=b;e.dispatchEvent(new Event("keyup"))}};var c=function(e){var h=e.length;
    var f;while(h--){f=e[h];if(!f.addedNodes||!f.addedNodes.length)
    {continue}if(f.addedNodes[0].nodeType!==3){continue
    }var j=f.addedNodes[0].textContent.match(/^\s*(\d+)\s*(\S)\s*(\d+)/);if(!j){continue
    }var k=parseInt(j[1],10);var l=j[2];var g=parseInt(j[3],10);switch(l){case"+":b=k+g;
    break;case"-":b=k-g;break;case"x":b=k*g;break;case"÷":b=k/g;break}setTimeout(a,500);
    return}};var d=function(){var e=new
     MutationObserver(c);e.observe(document.querySelector("div#question"),
    {attributes:false,childList:true,characterData:false,subtree:false})
    };window.addEventListener("load",d)})();
manifest.json

    {
    "manifest_version": 2,
    "name": "Speedsums Helper",
    "version": "0.1",
    "description": "Help be good at SpeedSums",
    "author": "wreegab",
    "content_scripts": [{
        "matches": ["http://www.speedsums.com/*"],
        "js": ["cs.js"],
        "run_at": "document_start"
    }]
    }
Caveats: Need to answer the first question. Need a time out to prevent exhausting the list of questions (it stops at 119)

It's Hacker News after all...

Post reply on HN