Neopets: Closet price check

Adds a button to automatically check the prices of that page

// ==UserScript==
// @name         Neopets: Closet price check
// @author       Tombaugh Regio
// @version      1.0
// @description  Adds a button to automatically check the prices of that page
// @namespace    https://greasyfork.org/users/780470
// @match        http://www.neopets.com/closet.phtml*
// @match        https://items.jellyneo.net/tools/closet-price-checker/
// @grant        GM_openInTab
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_xmlhttpRequest
// ==/UserScript==

const URL = document.URL

if (URL.includes("neopets")) {
    const title = document.evaluate("//b[contains(., 'Your Closet')]",
                                    document, null, XPathResult.ANY_TYPE, null ).iterateNext()

    //Add a price checker button
    const itemCheckerButton = document.createElement("button")
    const itemCheckerLink = document.createElement("a")
    itemCheckerButton.innerText = "Check prices on this page"
    itemCheckerButton.style.margin = "0 0.5em"

    //Get the entire HTML of this page
    GM_xmlhttpRequest({
        method: 'GET',
        url: URL,
        headers: {
            'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
            'Accept': 'application/atom+xml,application/xml,text/xml',
        },
        onload: function(responseDetails) {
            return new Promise((resolve, reject) => {
                resolve(GM_setValue("allHTML", responseDetails.responseText))
            })
        }
    })

    //Open the price checker page
    itemCheckerButton.onclick = e => {
        e.preventDefault()
        GM_openInTab("https://items.jellyneo.net/tools/closet-price-checker/")
    }

    //Append button after title
    title.after(itemCheckerButton)
}

if (URL.includes("closet-price-checker")) {
    const inputTextArea = document.querySelector("#price-check-code")
    const priceCheckButton = document.querySelector("#price-check-submit")
    const closetPage = GM_getValue("allHTML")

    inputTextArea.textContent = closetPage

    if (inputTextArea.textContent.length > 0) priceCheckButton.click()
}