[Neopets] Select Last X Items (Quick Stock Helper)

Adds options to quickly-er batch select items in quick stock. Goes from the last item because that's how I roll. ONLY SELECTS. DOUBLE CHECK YOUR OWN INPUTS BEFORE HITTING SUBMIT!

目前為 2022-07-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name         [Neopets] Select Last X Items (Quick Stock Helper)
// @namespace    https://gf.qytechs.cn/en/scripts/447331
// @version      0.4
// @description  Adds options to quickly-er batch select items in quick stock. Goes from the last item because that's how I roll. ONLY SELECTS. DOUBLE CHECK YOUR OWN INPUTS BEFORE HITTING SUBMIT!
// @author       Piotr Kardovsky
// @match        http*://www.neopets.com/quickstock.phtml*
// @icon         https://www.neopets.com//favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const actions = ["Stock", "Deposit", "Donate", "Discard", "Gallery", "Closet", "Shed"];

    // Default amount. Simple enuff.
    const DEFAULT_AMOUNT = 10;

    // Default action. You can either use actions[x] where x = a number from 0 to 6, OR:
    // Choose 1 of the following. Make sure they're still in the quotes.
    // "Stock", "Deposit", "Donate", "Discard", "Gallery", "Closet", "Shed"
    const DEFAULT_ACTION = actions[1];

    window.addEventListener('load', () => {
        let qs = document.querySelector('form[name="quickstock"] table');
        // 3 is "magic", the header + check all + submit count as rows
        let rws = qs.rows.length - 3;
        let items = (rws - Math.floor(rws/20) + 1) % 20 === 0 ? rws - Math.floor(rws/20) + 1 : rws - Math.floor(rws/20);

        // Amount
        let num = document.createElement('input');
        num.type = 'number';
        num.min = 0;
        num.max = items;
        num.value = DEFAULT_AMOUNT;
        num.style.width = '38px';
        num.style.height = '22px';

        // Action
        let sty = document.createElement('select');
        sty.style.height = '28px';
        actions.forEach((i) => {
            let o = document.createElement('option');
            o.text = i;
            sty.add(o);
        });
        sty.value = DEFAULT_ACTION;

        // Button
        let dpb = document.createElement('button');
        dpb.innerText = 'Select!';
        dpb.style.height = '28px';
        dpb.addEventListener('click', (e) => {
            e.preventDefault();
            document.querySelector('form[name="quickstock"]').reset();
            if (parseInt(num.value) > parseInt(num.max)) num.value = num.max;
            for (let i = items; i > items - num.value; i--) {
                let itm = document.querySelector(`input[name^="radio_arr[${i}]"][value="${sty.value.toLowerCase()}"]`);
                if (itm != null && itm != undefined) {
                    if (itm.checked == false) itm.checked = true;
                }
            }
        });

        let container = document.createElement('div');
        let ic = document.createElement('span');
        ic.innerText = `${items} items.`

        container.classList.add('qsdc');
        container.innerHTML = "<strong>Select last: </strong>"
        container.append(num, sty, dpb, document.createElement('br'), ic);
        document.querySelector('.content').append(container);
    });
})();

QingJ © 2025

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