Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- manifest.json:
- {
- "name": "P",
- "version": "1.0",
- "description": "P",
- "permissions": [
- "contextMenus"
- ],
- "background": {
- "scripts": ["background.js"],
- "persistent": false
- },
- "manifest_version": 2
- }
- background.js:
- function genericOnClick(info, tab) {
- console.log("item " + info.menuItemId + " was clicked");
- console.log("info: " + JSON.stringify(info));
- console.log("tab: " + JSON.stringify(tab));
- }
- chrome.runtime.onInstalled.addListener(function() {
- chrome.contextMenus.create({
- "id": "sampleContextMenu",
- "title": "Sample Context Menu",
- "contexts": ["all"]
- });
- console.log("created context menu");
- chrome.contextMenus.onClicked.addListener(function(info, tab) {
- if (info.menuItemId == "sampleContextMenu") {
- alert("bla bla bla");
- console.log("menu item was clicked");
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement