{"action":"closed","issue":{"url":"https://api.github.com/repos/gorhill/uBlock/issues/1097","labels_url":"https://api.github.com/repos/gorhill/uBlock/issues/1097/labels{/name}","comments_url":"https://api.github.com/repos/gorhill/uBlock/issues/1097/comments","events_url":"https://api.github.com/repos/gorhill/uBlock/issues/1097/events","html_url":"https://github.com/gorhill/uBlock/issues/1097","id":64546273,"number":1097,"title":"Add a toolbar button context menu checkbox to toggle the number","user":{"login":"tophf","id":1310400,"avatar_url":"https://avatars.githubusercontent.com/u/1310400?v=3","gravatar_id":"","url":"https://api.github.com/users/tophf","html_url":"https://github.com/tophf","followers_url":"https://api.github.com/users/tophf/followers","following_url":"https://api.github.com/users/tophf/following{/other_user}","gists_url":"https://api.github.com/users/tophf/gists{/gist_id}","starred_url":"https://api.github.com/users/tophf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tophf/subscriptions","organizations_url":"https://api.github.com/users/tophf/orgs","repos_url":"https://api.github.com/users/tophf/repos","events_url":"https://api.github.com/users/tophf/events{/privacy}","received_events_url":"https://api.github.com/users/tophf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-26T14:54:03Z","updated_at":"2015-03-26T15:24:07Z","closed_at":"2015-03-26T15:24:07Z","body":"Why?\r\n\r\nBecause as a user I see a button and I want to customize its appearance so what do I do? I right-click it and immediately see the related checkbox. Easy.\r\n\r\n[Docs](https://developer.chrome.com/extensions/contextMenus)\r\nThe manifest should have `contextMenus` in `permissions`.\r\nHere's an example:\r\n```js\r\nchrome.contextMenus.create({\r\n\tid: \"toggleNumber\", title: chrome.i18n.getMessage(\"toggleNumberLabel\"),\r\n\ttype: \"checkbox\", contexts: [\"browser_action\"], checked: getPref(\"toggleNumber\")\r\n});\r\nchrome.contextMenus.onClicked.addListener(function(info, tab) {\r\n\tif (info.menuItemId == \"toggleNumber\") {\r\n\t\tsetPref(info.menuItemId, info.checked);\r\n\t\tupdateToolbarButtonNumber();\r\n\t}\r\n});\r\nchrome.extension.onMessage.addListener(function(request, sender, sendResponse) {\r\n\tif (request.method == \"prefChanged\"  && request.prefName == \"toggleNumber\") {\r\n\t\tchrome.contextMenus.update(\"toggleNumber\", {checked: request.value});\r\n\t}\r\n});\r\n```\r\nThe options page should notify the background page:\r\n```js\r\nchrome.extension.sendMessage({method: \"prefChanged\", prefName : \"toggleNumber\", value: newValue});\r\n```\r\n\r\nActually it'd be reasonable to include the other three global behavior options as well!"}}