Skip to content

Instantly share code, notes, and snippets.

@mosaicer
Created August 18, 2020 14:56
Show Gist options
  • Save mosaicer/3b079a0e22434cc2fb00ffcf68f82595 to your computer and use it in GitHub Desktop.
Save mosaicer/3b079a0e22434cc2fb00ffcf68f82595 to your computer and use it in GitHub Desktop.
「夏のきらら検定 in アルティメットクイズ」の正答送信自動化スクリプト
// ==UserScript==
// @name 「夏のきらら検定 in アルティメットクイズ」正答送信自動化
// @namespace https://github.com/mosaicer
// @author mosaicer
// @version 1.0.0
// @description 「夏のきらら検定 in アルティメットクイズ」で正答を送信する操作を自動化します。
// @match https://www.asfes.jp/game/kirarafantasia/quz-1555-q1q/
// @match https://www.asfes.jp/game/kirarafantasia/quz-1555-q1q/quizform/
// @match https://www.asfes.jp/game/kirarafantasia/quz-1555-q1q/quiz/result/*
// @license MIT
// ==/UserScript==
(() => {
'use strict';
const MAX_QUESTION_COUNT = 4;
const NEXT_QUIZ_WAITING_TIME = 10000;
const getAnswer = function getAnswerOfTheSpecifiedQuiz(number) {
QUZ_APP.getAnswer(QUZ_DATA.quz_id, number, {
success: function(response) {
// MAX_QUESTION_COUNTからカウントダウンしているため逆順に格納する(=先頭に追加)
QUZ_ANSWERS.unshift(response.answer);
number--;
// 全正答を取得したらそれを送信する
if (number === 0) {
console.log(`answers: ${QUZ_ANSWERS}`);
// 10pt獲得
QUZ_APP.sendAnswers(QUZ_ANSWERS);
} else {
getAnswer(number);
}
},
error: function(response) {
console.log(`getAnswer error: ${response}`);
}
});
};
// top page
if (location.href === 'https://www.asfes.jp/game/kirarafantasia/quz-1555-q1q/') {
document.getElementById('submitButton').click();
}
// quiz page
else if (location.href === 'https://www.asfes.jp/game/kirarafantasia/quz-1555-q1q/quizform/') {
// すぐに処理を実行するとクイズIDが取得できないため、1秒待ってから処理を行う
setTimeout(function() {
console.log(`quiz id: ${QUZ_DATA.quz_id}`);
getAnswer(MAX_QUESTION_COUNT);
}, 1000);
}
// result page
else {
console.log(`url: ${location.href}`);
// 5pt獲得
share('tweet');
// 指定時間待ってから次のクイズに進む
setTimeout(function() {
document.getElementById('retryButton').click();
}, NEXT_QUIZ_WAITING_TIME);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment