theonedemon / Tehnomir

// ==UserScript==
// @name         Tehnomir
// @namespace    http://tampermonkey.net/
// @version      2023-12-19
// @description  i
// @author       theonedemon@gmail.com
// @match        https://*.tehnomir.com.ua/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tehnomir.com.ua
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    //console.log(location.search);
    $('.tel-box').remove();

    if (/\bproduct%2Fsearch\b/.test (location.search)) {

        // remove spaces in detail
        let remove_spaces = function (x) {
            $('.detail-number').each(function(i, el) {
                var data = $(el).html();
                var is_edited = $(el).data('edited') || 0;
                if (!is_edited) {
                    data = data.replace(/\s|-/g, '');
                    $(el).data('edited', 1).html(data);
                }
            });
        };
        setInterval(remove_spaces, 1000);

        var stickerTextKey = 'stickerText';
        var typingTimer;
        $(document).on('input', 'input[name="stickerText"]', function () {
            var input = $(this).val();
            clearTimeout(typingTimer);
            typingTimer = setTimeout(function() {
                localStorage.setItem(stickerTextKey, input);
            }, 1000);
        });

        $("#edit-product").on( "dialogopen", function( event, ui ) {
            const value = localStorage.getItem(stickerTextKey);
            if (value) {
                $('input[name="stickerText"]').val(value);
            }
        });
    }

    if (/\bshopping-cart\b/.test (location.search) ) {
        // remove spaces in detail
        let remove_spaces = function (x) {
            $('.product-info > .number').each(function(i, el) {
                var data = $(el).html();
                var is_edited = $(el).data('edited') || 0;
                if (!is_edited) {
                    data = data.replace(/\s|-/g, '');
                    $(el).data('edited', 1).html(data);
                }
            });
        };
        setInterval(remove_spaces, 1000);
    }
})();