1

I'm trying to display the extension when I rigth click on the custom item menu is there any way to make it , here is the code that I'm trying to pop up the popup.html. the manifest.json look like this:

"background": {
      "scripts": ["eventPage.js"],
      "persistent": false
    },  
    "web_accessible_resources": [
      "popup.html"
    ],
    "permissions": [
            "storage",
            "notifications",
            "contextMenus",
            "identity.email",
            "identity"
          ],
  
    "options_page": "options.html"

the rigth click on the eventPage.js is the follow:

var menuItem = {
    "id": "HashTag",
    "title": "Create HashTag",
    "contexts": ["selection"]
};

chrome.contextMenus.create(menuItem);
//On click on the menu Item to get the function
chrome.contextMenus.onClicked.addListener(function (clickData) {
    copyToClipboard(clickData.selectionText);
    if (clickData.menuItemId == "HashTag" && clickData.selectionText) {

    }
});

enter image description here

Rafa
  • 23
  • 6
  • The API doesn't provide a way to handle a right-click. You'll have to add a second menu item to provide additional functionality. – wOxxOm Jul 20 '21 at 03:25
  • oh, ok but when you want to open a new tab you using this: chrome.tabs.create({'url': chrome.runtime.getURL('popup.html')}, function(tab) { // Tab opened. }); Do you know how to display the windows on the same page? shoulde be something like chrome something.. – Rafa Jul 20 '21 at 03:32
  • I didn't understand "display the windows on the same page". Could you elaborate or show a sketch? – wOxxOm Jul 20 '21 at 06:15
  • sorry, ok when you click on here item this will display a little html named popup.html as the picture show is there any code that when you rigth click do the same as the "click on the top item"? dont know if I explain well – Rafa Jul 20 '21 at 13:59
  • 1
    1) open a new small window, see chrome.windows.create and use `type: 'popup'`. 2) alternatively add an iframe into the page ([example](https://stackoverflow.com/a/25100953)) and make it look like the popup using CSS. – wOxxOm Jul 20 '21 at 14:41
  • oh that create a new pop up but I just want it to open on the same page for example emulate a click on the item in the toolbar when I do a rigth click. "browser_action": { "default_icon": "img/icon16.png", "default_popup": "popup.html" } in this case the popup is showing when you click on the toolbar, sorry to bother you but that is the last thing to close the sprint tks for the help! – Rafa Jul 20 '21 at 22:47
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/235119/discussion-between-rafa-and-woxxom). – Rafa Jul 20 '21 at 23:32

0 Answers0