Всем привет.
Разработал расширение, и как последний штрих хочу вызвать popup.html через горячие клавиши, но выскакивает ошибка.
Погуглил но так и не нашел решение.
Ошибка
service-worker-loader.js:1 Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
manifest
{
"manifest_version": 3,
"name": "Chrome Vite",
"description": "vue in chrome extension",
"version": "1.0",
"author": "serii burduja",
"action": {
"default_popup": "index.html",
"default_icon": "icons/icon-32.png"
},
"permissions": [
"tabs",
"activeTab",
"scripting",
"storage",
"alarms",
"notifications",
"downloads"
],
"content_scripts": [
{
"js": [
"content.js"
],
"matches": [
"<all_urls>"
]
}
],
"host_permissions": [
"<all_urls>"
],
"background": {
"service_worker": "background.js"
},
"commands": {
"openPopup": {
"suggested_key": {
"default": "Ctrl+Comma",
"mac": "Command+Comma"
},
"description": "Open Popup"
}
}
}
background.js
// script start after extension install
chrome.runtime.onInstalled.addListener(async () => {
// alert("extension installed");
console.log("extension installed");
});
chrome.commands.onCommand.addListener((command) => {
chrome.tabs.update({}, async (tab) => {
if (command === "openPopup") {
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
console.log(command, 'command')
chrome.tabs.sendMessage(tabs[0].id, {action: "openPopup"});
});
}
});
});
content.js
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.action === "openPopup") {
chrome.runtime.openPopup();
}
});
При нажатии Ctrl+, выскакивает ошибка.
Заранее благодарен за помощь.