One-Click Quickstock/Quickdeposit

Add action buttons to Neopets Quick Stock page

Version vom 31.01.2025. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         One-Click Quickstock/Quickdeposit
// @description  Add action buttons to Neopets Quick Stock page
// @version      2025.01.31
// @license      GNU GPLv3
// @match        https://www.neopets.com/quickstock.phtml*
// @author       Posterboy
// @namespace    https://youtube.com/@Neo_Posterboy
// @icon         https://images.neopets.com/new_shopkeepers/t_1900.gif
// @grant        none
// ==/UserScript==

// Main function to handle Stock and Deposit actions
function selectAction(action) {
    console.log(`selectAction called with action: ${action}`);

    // Find all radio buttons on the page
    let radios = document.querySelectorAll(`input[type="radio"][value="${action}"]`);

    // Loop through each radio button and select it
    radios.forEach(radio => {
        radio.checked = true;
    });

    // Submit the form
    let form = document.querySelector('form[name="quickstock"]');
    if (form) {
        console.log("Submitting form");
        form.submit();
    } else {
        console.log("Form not found when submitting");
    }
}

// Create toolbar with "Stock All" and "Deposit All" buttons
function createToolbar() {
    let existingToolbar = document.querySelector('#custom-toolbar');
    if (existingToolbar) return;

    let form = document.querySelector('form[name="quickstock"]');
    if (!form) return;

    // Create toolbar div
    let toolbar = document.createElement('div');
    toolbar.id = 'custom-toolbar';
    toolbar.style.marginBottom = '15px';
    toolbar.style.padding = '10px';
    toolbar.style.backgroundColor = '#f4f4f4';
    toolbar.style.border = '1px solid #ddd';
    toolbar.style.borderRadius = '5px';
    toolbar.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.1)';
    toolbar.style.textAlign = 'center';

    // Create Stock All button
    let stockAllBtn = document.createElement('button');
    stockAllBtn.textContent = 'Stock All';
    stockAllBtn.style.padding = '10px 20px';
    stockAllBtn.style.marginRight = '10px';
    stockAllBtn.style.backgroundColor = '#4CAF50';
    stockAllBtn.style.color = 'white';
    stockAllBtn.style.border = 'none';
    stockAllBtn.style.borderRadius = '4px';
    stockAllBtn.style.cursor = 'pointer';
    stockAllBtn.type = 'button';
    stockAllBtn.onclick = () => selectAction('stock');

    // Create Deposit All button
    let depositAllBtn = document.createElement('button');
    depositAllBtn.textContent = 'Deposit All';
    depositAllBtn.style.padding = '10px 20px';
    depositAllBtn.style.backgroundColor = '#2196F3';
    depositAllBtn.style.color = 'white';
    depositAllBtn.style.border = 'none';
    depositAllBtn.style.borderRadius = '4px';
    depositAllBtn.style.cursor = 'pointer';
    depositAllBtn.type = 'button';
    depositAllBtn.onclick = () => selectAction('deposit');

    // Append buttons to toolbar
    toolbar.appendChild(stockAllBtn);
    toolbar.appendChild(depositAllBtn);

    // Insert the toolbar above the table
    let table = form.querySelector('table');
    table.parentNode.insertBefore(toolbar, table);
}

// Initialize toolbar after window load
window.addEventListener('load', createToolbar);