Select All Items

Select all items when selling to NPCs

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey 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 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.

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

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

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         Select All Items
// @namespace    shade.selectall.cartelempire.online
// @version      1.0
// @description  Select all items when selling to NPCs
// @author       SHADE [4740]
// @match        https://cartelempire.online/Town/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cartelempire.online
// @grant        none
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    $("h2:contains('Sell Items')").html('Sell Items <a id="select_all" class="btn btn-sm btn-primary float-end" href="javascript:void(0);">Select All</a><a id="unselect_all" class="btn btn-sm btn-secondary float-end d-none" href="javascript:void(0);">Unselect All</a>');

    let selectAll = $("a#select_all");
    let unselectAll = $("a#unselect_all");
    let inputs = $(".collapse .itemQuantityInput");
    if ($(window).width() >= 992 ){
        inputs = $("div:visible>.input-group .itemQuantityInput");
    }

    selectAll.on('click', function(){
        let found = false;
        inputs.each(function() {
            if ($(this).attr("cost")) {
                $(this).val($(this).attr('max')).change();
                found = true;
            }
        });

        if(found == true) {
            selectAll.addClass('d-none');
            unselectAll.removeClass("d-none");
        }
    });

    unselectAll.on('click', function(){
        inputs.each(function() {
            if ($(this).attr("cost")) {
                $(this).val($(this).attr('min')).change();
            }
        });

        unselectAll.addClass('d-none');
        selectAll.removeClass("d-none");
    });
})();