Shenkuu Lunar Temple solver

Highlights the correct answer

当前为 2020-07-12 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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";
}