Skip to content

Instantly share code, notes, and snippets.

@pawlik
Created September 15, 2014 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawlik/93b3d203d9a777916f65 to your computer and use it in GitHub Desktop.
Save pawlik/93b3d203d9a777916f65 to your computer and use it in GitHub Desktop.
Hex color game cheat

http://johnsythinks.com/hex/

Thanks to http://www.javascripter.net/faq/hextorgb.htm

function hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}

this is my quick resolve function:

function resolve(){var hex = $('#alerter')[0].innerHTML; if(window.getComputedStyle($('#rightButton')[0])['background-color'] == "rgb("+hexToR(hex)+", "+hexToG(hex)+", "+hexToB(hex)+")"){$('#rightButton')[0].click()}else{$('#leftButton')[0].click()} }

run this in a loop ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment