ошибка : Unchecked runtime.lastError: Could not establish connection. Receiving end does…
- User
ошибка : Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. код: html:
js:
const gradient = document.querySelector('.gradient'); const prettyGradient = document.querySelector('.pretty-gradient');
function hexToHSL(hex) { hex = '#' + hex; let r = 0, g = 0, b = 0; if (hex.length == 4) { r = '0x' + hex[1] + hex[1]; g = '0x' + hex[2] + hex[2]; b = '0x' + hex[3] + hex[3]; } else if (hex.length == 7) { r = '0x' + hex[1] + hex[2]; g = '0x' + hex[3] + hex[4]; b = '0x' + hex[5] + hex[6]; } r /= 255; g /= 255; b /= 255; const max = Math.max(r, g, b); const min = Math.min(r, g, b);
let h, s, l = (max + min) / 2; if (max == min) { h = s = 0; } else { const d = max - min; s = l >= 0.5 ? d / (2.0 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6.0 : 0); break; case g: h = (b - r) / d + 2.0; break; case b: h = (r - g) / d + 4.0; break; } h /= 6.0; } h = h * 360; s = s * 100; l = l * 100; r = parseInt(hex.substring(0,2), 16); g = parseInt(hex.substring(2,4), 16); console.log('/////////////////////'); b = parseInt(hex.substring(4,6), 16); return { hsl: 'hsla(' + h + ',' + s + '%,' + l + '%)', h: h, s: s, l: l, rgb: [r,g,b] };}
let startInputValue = 'ffffff'; let finiteInputValue = '000000'; let startInputValue2 = 'ffffff'; let finiteInputValue2 = '000000'; let angle = 90;
const startInputElement = document.getElementById('startInputColor'); const finiteInputElement = document.getElementById('finiteInputColor'); const firstColorIndicator = document.getElementById('firstColorIndicator'); const midColorIndicator = document.getElementById('midColorIndicator'); const finiteColorIndicator = document.getElementById('secondColorIndicator'); const angleInput = document.getElementById('angleInput'); let midCol; function processInput() { requestAnimationFrame(processInput); startInputValue = startInputElement.value; finiteInputValue = finiteInputElement.value; startInputValue2 = startInputValue; finiteInputValue2 = finiteInputValue; // startInputValue.trim(); // finiteInputValue.trim(); // const startFirstArray = startInputValue.split(''); // const finiteFirstArray = startInputValue.split(''); // if (startFirstArray[0] === '#') { // } angleGradient = angleInput.value; if (angleGradient.trim() !== '' && parseFloat(angleGradient) !== NaN) { angle = angleGradient; console.log(angleGradient.trim()); }
firstColorIndicator.style.backgroundColor = hexToHSL(startInputValue).hsl ; finiteColorIndicator.style.backgroundColor = hexToHSL(finiteInputValue).hsl; gradient.style.background = 'linear-gradient(' + angle + 'deg,' + hexToHSL(startInputValue).hsl + ',' + hexToHSL(finiteInputValue).hsl + ')'; prettyGradient.style.background = 'linear-gradient(' + angle + 'deg,' + hexToHSL(startInputValue).hsl + ',' + midColorNew() + '50%,' + hexToHSL(finiteInputValue).hsl + ')'; if (startInputValue.trim() === '' && finiteInputValue.trim() === '') { firstColorIndicator.style.backgroundColor = '#fff'; finiteColorIndicator.style.backgroundColor = '#000'; gradient.style.background = 'linear-gradient(' + angle + 'deg, hsl(0, 0%, 100%), hsl(0, 0%, 0%))'; prettyGradient.style.background = 'linear-gradient(' + angle + 'deg, hsl(0, 0%, 100%), hsl(0, 0%, 0%))'; } else if(startInputValue.trim() === '') { firstColorIndicator.style.backgroundColor = '#fff'; gradient.style.background = 'linear-gradient(' + angle + 'deg, hsl(0, 0%, 100%),' + hexToHSL(finiteInputValue).hsl + ')'; prettyGradient.style.background = 'linear-gradient(' + angle + 'deg, hsl(0, 0%, 100%),' + hexToHSL(finiteInputValue).hsl + ')'; } const color1 = hexToHSL(startInputValue).rgb; const color2 = hexToHSL(finiteInputValue).rgb; // midColorIndicator.style.backgroundColor = findMidColor(color1, color2); - Assistant
Ошибка "Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist." не связана с представленным кодом. Она может возникать в разных ситуациях, связанных с взаимодействием расширения или приложения с Chromium API. Обычно это не критическая ошибка и не влияет на работу расширения или приложения. Если ошибки возникают слишком часто или возникают другие проблемы, стоит обратиться к документации API или поискать решение проблемы на форумах.