// Робот-Ишак
let robotToggleState = false;

function saveRobotState(state) {
    localStorage.setItem('ishakRobotEnabled', state ? 'true' : 'false');
}

function loadRobotState() {
    return localStorage.getItem('ishakRobotEnabled') === 'true';
}

function enableRobotIshak() {
    const robotElements = document.querySelectorAll('._1g1lmT0l3fuVc8E_g0ULwx--sprite._U-E9AgxL4ygTXb8SnfKd--robot-body');
    robotElements.forEach(robot => {
        robot.style.backgroundImage = `url('${chrome.runtime.getURL('logos/Ishak.png')}')`;
        robot.style.backgroundSize = 'contain';
        robot.style.backgroundRepeat = 'no-repeat';
        robot.style.backgroundPosition = 'center';
    });
}

function disableRobotIshak() {
    const robotElements = document.querySelectorAll('._1g1lmT0l3fuVc8E_g0ULwx--sprite._U-E9AgxL4ygTXb8SnfKd--robot-body');
    robotElements.forEach(robot => {
        robot.style.backgroundImage = '';
        robot.style.backgroundSize = '';
        robot.style.backgroundRepeat = '';
        robot.style.backgroundPosition = '';
    });
}

function applyRobotReplacement() {
    if (robotToggleState) {
        enableRobotIshak();
    } else {
        disableRobotIshak();
    }
}

// Инициализация состояния при загрузке модуля
robotToggleState = loadRobotState();