Selects the Neotoken machine values that you want
当前为
// ==UserScript==
// @name Neopets: Neocola machine selector
// @author Tombaugh Regio
// @version 1.0
// @description Selects the Neotoken machine values that you want
// @namespace https://greasyfork.org/users/780470
// @match http://www.neopets.com/moon/neocola2.phtml
//@grant none
// ==/UserScript==
//==============================
const VALUE = {
//Which Token do you use?
token: "rEd",
//Which NeoCola flavor would you like?
flavor: "dehydrated H20",
//How many times do you press the red button?
press: 3
}
//==============================
function getToken(){
const images = Array.from(document.querySelector(".content").querySelectorAll("img")).slice(1)
const yourTokens = new Array()
let selected = VALUE.token.toUpperCase()
let token = ""
//Get all the neotokens in your inventory
for (const image of images) {
yourTokens.push(image.src.toUpperCase())
}
//Check if selected color is in your inventory
let match = false
for (const inventory of yourTokens) {
if (inventory.includes("BLUE") && selected.includes("BLUE")
|| inventory.includes("GREEN") && selected.includes("GREEN")
|| inventory.includes("RED") && selected.includes("RED")) {
match = true
}
}
//If there are no matches, selected is now the first token in your inventory
if (!match) {
if (yourTokens[0].includes("BLUE")) selected = "BLUE"
if (yourTokens[0].includes("GREEN")) selected = "GREEN"
if (yourTokens[0].includes("RED")) selected = "RED"
}
//Select the color option
if (selected.includes("BLUE")) token = 24538
if (selected.includes("GREEN")) token = 24539
if (selected.includes("RED")) token = 24540
return {name: "token_id", value:token}
}
function getFlavor(){
const selected = VALUE.flavor.toUpperCase()
let flavor = ""
//Dr. Slother
if (selected.includes("SL")) flavor = 0
//Diet Doom
if (selected.includes("ET")) flavor = 1
//Na'cho Cola
if (selected.includes("CH")) flavor = 2
//Smite
if (selected.includes("SM")) flavor = 3
//Alt-Tab
if (selected.includes("LT")) flavor = 4
//Minion Maid
if (selected.includes("MA")) flavor = 5
//Mountain Poo
if (selected.includes("NT")) flavor = 6
//Dehydrated H20
if (selected.includes("H2")) flavor = 7
return {name: "neocola_flavor", value: flavor}
}
function getPress() {
const selected = parseInt(VALUE.press)
let times = 0
if (selected > 0) times = 1
if (selected > 1) times = 2
if (selected > 2) times = 3
if (selected > 3) times = 10
if (selected > 10) times = 42
return {name: "red_button", value: times}
}
function selectOption(option) {
const {name, value} = option
const neocolaMachine = document.querySelector(".content").querySelector("form")
neocolaMachine.querySelector(`select[name="${name}"]`).value = value
}
if (!document.querySelector(".content").innerHTML.includes("You don't have any NeoCola Tokens")) {
const TOKEN = getToken()
const FLAVOR = getFlavor()
const PRESS = getPress()
selectOption(TOKEN)
selectOption(FLAVOR)
selectOption(PRESS)
}