Skip to content

Instantly share code, notes, and snippets.

@ataka
Created November 1, 2011 00:52
Show Gist options
  • Save ataka/1329550 to your computer and use it in GitHub Desktop.
Save ataka/1329550 to your computer and use it in GitHub Desktop.
GDD2011 DevQuiz Web Game
GDD2011 DevQuiz Web Game
ルール
シンプルな神経衰弱ゲームです。カードはクリックすることでめくることができます。全 64 セットを解くことで問題クリアとなります。
{
"name": "ChromeExtensionSolverHint",
"version": "1.1",
"description": "Clear Nervous Breakdown Game (GDD2011).",
"content_scripts": [
{
"matches": [
"http://gdd-2011-quiz-japan.appspot.com/webgame/problem*"
],
"js": [
"solver.js"
]
}
],
"permissions": [
]
}
var cards = new Array();
var color = new Array();
var i = 0;
while(1)
{
cards[i] = document.getElementById('card' + i);
if (cards[i] == null) {
break;
} else {
click_card(i);
color[i] = cards[i].style.backgroundColor;
i += 1;
cards[i] = document.getElementById('card' + i);
click_card(i);
color[i] = cards[i].style.backgroundColor;
i += 1;
check_card(i-2);
check_card(i-1);
}
}
function click_card(j)
{
var myevent = document.createEvent('MouseEvents');
myevent.initEvent('click', false, true);
cards[j].dispatchEvent(myevent);
}
function check_card(j)
{
for(var n=j-1; n>=0; n--)
{
if (color[n] === color[j])
{
click_card(n);
click_card(j);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment