One-Click Quickstock/Quickdeposit

Add action buttons to Neopets Quick Stock page

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         One-Click Quickstock/Quickdeposit
// @description  Add action buttons to Neopets Quick Stock page
// @version      2025.06.25
// @license      GNU GPLv3
// @match        https://www.neopets.com/quickstock.phtml*
// @author       Posterboy + credit Max van Doorn for CSS styles
// @namespace    https://youtube.com/@Neo_Posterboy
// @icon         https://images.neopets.com/new_shopkeepers/t_1900.gif
// ==/UserScript==

(() => {
  'use strict';

  // Load external CSS
  document.head.appendChild(Object.assign(document.createElement('link'), {
    rel: 'stylesheet',
    href: 'https://greasyfork.org/scripts/540710-neopets-2020/code/neopets_2020.user.css'
  }));

  const applyButtonStyles = (btn, extraStyles = {}) => {
    btn.style.fontSize = 'x-large';
    btn.style.paddingLeft = '20px';
    btn.style.paddingRight = '20px';
    Object.entries(extraStyles).forEach(([k, v]) => btn.style[k] = v);
  };

  window.addEventListener('load', () => setTimeout(createToolbar, 2000));

  function selectAction(action) {
    document.querySelectorAll(`input[type="radio"][value="${action}"]`).forEach(r => r.checked = true);
    const form = document.querySelector('form[name="quickstock"]');
    if (form) form.submit();
  }

  function createToolbar() {
    if (document.querySelector('#custom-toolbar')) return;

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

    const toolbar = document.createElement('div');
    toolbar.id = 'custom-toolbar';
    toolbar.style.paddingBottom = '10px';
    toolbar.style.textAlign = 'center';

    const stockAllBtn = document.createElement('button');
    stockAllBtn.textContent = 'Stock All';
    stockAllBtn.type = 'button';
    stockAllBtn.classList.add('button-green__2020');
    applyButtonStyles(stockAllBtn, { marginRight: '10px' });
    stockAllBtn.onclick = () => selectAction('stock');

    const depositAllBtn = document.createElement('button');
    depositAllBtn.textContent = 'Deposit All';
    depositAllBtn.type = 'button';
    depositAllBtn.classList.add('button-blue__2020');
    applyButtonStyles(depositAllBtn);
    depositAllBtn.onclick = () => selectAction('deposit');

    toolbar.append(stockAllBtn, depositAllBtn);

    const table = form.querySelector('table');
    if (table) {
      table.parentNode.insertBefore(toolbar, table);
    } else {
      form.insertBefore(toolbar, form.firstChild);
    }
  }
})();