Select All Items

Select all items when selling to NPCs

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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");
    });
})();