Highlights the correct answer
当前为
// ==UserScript==
// @name Shenkuu Lunar Temple solver
// @namespace neopets
// @version 1.1
// @description Highlights the correct answer
// @author EatWoolooAsMutton
// @match http://www.neopets.com/shenkuu/lunar/?show=puzzle
// @grant none
// ==/UserScript==
var d = document;
var mapImage = d.querySelector("embed").getAttribute("src");
var angle = parseInt(mapImage.match(/(\d+)/g)[2]);
var angleList = [0, 12, 34, 57, 79, 102, 124, 147, 169, 192, 214, 237, 259, 282, 304, 327, 349, 361];
var answer = null;
for (var i = 0; i < angleList.length; i++) {
if (i <= 7) {
if (angle >= angleList[i] && angle < angleList[i + 1]) {
console.log("2nd row, #" + (i + 1) + " from left");
answer = i + 8;
break;
}
} else if (i <= 15) {
if (angle >= angleList[i] && angle < angleList[i + 1]) {
console.log("1st row, #" + (i - 7) + " from left");
answer = i - 8;
break;
}
} else if (i <= 17) {
console.log("2nd row, #1 from left");
answer = 8;
}
}
highlightAnswer(answer);
function highlightAnswer(num) {
let ans = d.querySelectorAll("input[onclick='this.form.submit();']")[num];
let cell = ans.parentElement;
cell.style.backgroundColor = "00ffbf";
cell.style.borderStyle = "solid";
cell.style.borderColor = "red";
}