Grumpy Wise King autofill

Includes button for auto selecting the avatar question in Grumpy King

目前為 2020-06-26 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Grumpy Wise King autofill
// @namespace    -
// @version      0.2
// @description  Includes button for auto selecting the avatar question in Grumpy King
// @author       -
// @match        http://www.neopets.com/medieval/wiseking.phtml
// @match        http://www.neopets.com/medieval/grumpyking.phtml
// @grant        none
// ==/UserScript==

var d = document;
var url = window.location.href;
var form = d.getElementsByName("form")[0];

// Default random selection
var select = form.getElementsByTagName("select");
for (let i = 0; i < select.length; i++) {
	let option = select[i].getElementsByTagName("option");
	let answer = option[Math.floor(Math.random() * (option.length - 1)) + 1];
	answer.selected = true;
}

if (url.includes("grumpyking")) {
	
	// Create avatar question button
	var div = d.createElement("div");
	div.setAttribute("align", "center");
	div.setAttribute("id", "avQuestion");
	var button = d.createElement("button");
	button.setAttribute("type", "button");
	var buttonText = d.createTextNode("Avatar question");
	button.appendChild(buttonText);
	div.appendChild(button);
	form.insertBefore(div, form.childNodes[5]);

	//["What", "do", "you do if", "*Leave blank*", "fierce", "Peophins", "*Leave blank*", "has eaten too much", "*Leave blank*", "tin of olives"];
	var avOptions = [3, 8, 6, 1, 39, 118, 1, 32, 1, 143];

	d.getElementById("avQuestion").addEventListener("click", function () {
		for (let i = 0; i < 10; i++) {
			let option = d.getElementById("qp" + (i + 1)).getElementsByTagName("option");
			let answer = option[avOptions[i]];
			answer.selected = true;
		}
	});
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址