This is my first chrome extension. I want to run a console command from the right-click menu, for example a plain hello world. The extension writes to its console. How can I run it on the page where I am? So not in the add-on's console, but on any page where I press the button
manifest.json
{
"name": "Hello",
"description": "Hello world",
"version": "0.1.107",
"permissions": ["contextMenus"],
"host_permissions": ["<all_urls>"],
"background": {
"service_worker": "background.js"
},
"manifest_version": 3
}
background.js
chrome.contextMenus.create({
id: 'hello',
title: 'Hello world',
contexts: ['page']
})
function contextClick(info, tab) {
const { menuItemId } = info
if (menuItemId === 'hello') {
console.log("Hello world");
}
}
chrome.contextMenus.onClicked.addListener(contextClick);