Код: Выделить всё
Uncaught SyntaxError: Cannot use import statement outside a module
manifest.json:
Код: Выделить всё
{
"manifest_version": 3,
"name": "MyExtension",
"version": "1.0",
"permissions": ["scripting", "activeTab"],
"host_permissions": [""],
"background": {
"service_worker": "background.js"
},
"action": {
"default_popup": "popup.html"
}
}
import {
createMainSection,
createMessageInput,
createNavBar,
createRightContainer,
createSendButton,
createToolBar,
createToolBarButton,
} from "./utils.js";
import ElementSelector from "./element_selector.js";
import SelectorMenu from "./selector_menu.js";
import MessageList from "./message_list.js";
// Rest of content script code...
< /code>
Скрипт содержимого вводится через founal.js: < /p>
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === "complete" && /^https?:/.test(tab.url)) {
chrome.scripting.executeScript({
target: {tabId: tabId},
files: ["content.js"],
});
}
});
< /code>
Я пытаюсь модулизировать свой код с помощью модулей ES6, но получить ошибку выше. Как я могу правильно использовать модули ES6 в сценарии контента для расширения Chrome?
Подробнее здесь: https://stackoverflow.com/questions/794 ... ent-script
Мобильная версия