Pradeep Bhutare
Pradeep Bhutare

Reputation: 45

Add right click option to chrome extension's on web page

I have created a chrome extension. I would like to know if it is possible to add a right-click option to a Chrome extension's icon.

When I click right on-page in right-click menulist it should show chrome extension icon and its name.

How do I do that using Chrome Web Developer?

Upvotes: 2

Views: 2695

Answers (1)

Vishal Kumar
Vishal Kumar

Reputation: 1378

I think you are looking for Contextmenus.

Update extension's menifest.json with

                  "background": {  
                      "scripts": ["menus.js"],  //menu.js will include the code to crate the context  
                      "persistent": false  
                   },  
                   "permissions": ["contextMenus"],  
                   "icons":{  
                           "128": "contexticon.png"
                   }

Write code in menu.js

             var contextMenuItem = {
                    "id": "iconid",
                    "title": "iconTitle",
                    "contexts": ["all"]  // type of context
             };
             chrome.contextMenus.create(contextMenuItem);  

Note: The options for context menus are: "all", "page", "frame", "selection", "link", "editable", "image", "video", "audio", "launcher", "browser_action", or "page_action"

Upvotes: 4

Related Questions