Created
September 13, 2011 03:25
-
-
Save skoji/1213056 to your computer and use it in GitHub Desktop.
GDD2010JP DevQuiz WebGame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ChromeExtensionSolver", | |
"version": "1.0", | |
"description": "Open the first card and show background color of the card.", | |
"content_scripts": [ | |
{ | |
"matches": [ | |
"http://gdd-2011-quiz-japan.appspot.com/webgame/problem*" | |
], | |
"js": [ | |
"jquery-1.6.2.min.js", | |
"solver.js" | |
] | |
} | |
], | |
"permissions": [ | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = $("td").size(); | |
var dict = {}; | |
var colorbefore = null; | |
var opened = false; | |
for (i = 0; i < n; i ++) { | |
var element = $('#card' + i).get(0); | |
if (element == null) { | |
alert('Card element is not found. Check element id.' + 'card' + i); | |
} else { | |
var myevent = document.createEvent('MouseEvents'); | |
myevent.initEvent('click', false, true); | |
element.dispatchEvent(myevent); | |
var color = element.style.backgroundColor; | |
if (dict[color] >= 0) { | |
matched = $('#card' + dict[color]).get(0); | |
var myevent = document.createEvent('MouseEvents'); | |
myevent.initEvent('click', false, true); | |
matched.dispatchEvent(myevent); | |
if (colorbefore != null) { | |
var myevent = document.createEvent('MouseEvents'); | |
myevent.initEvent('click', false, true); | |
element.dispatchEvent(myevent); | |
} | |
delete dict[color]; | |
colorbefore = null; | |
} else { | |
if (color != colorbefore) { | |
dict[color] = i; | |
colorbefore = color; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment