Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Add a toolbar button context menu checkbox to toggle the number #1097

@tophf

Description

@tophf

Why?

Because 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.

Docs
The manifest should have contextMenus in permissions.
Here's an example:

chrome.contextMenus.create({
    id: "toggleNumber", title: chrome.i18n.getMessage("toggleNumberLabel"),
    type: "checkbox", contexts: ["browser_action"], checked: getPref("toggleNumber")
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
    if (info.menuItemId == "toggleNumber") {
        setPref(info.menuItemId, info.checked);
        updateToolbarButtonNumber();
    }
});
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
    if (request.method == "prefChanged"  && request.prefName == "toggleNumber") {
        chrome.contextMenus.update("toggleNumber", {checked: request.value});
    }
});

The options page should notify the background page:

chrome.extension.sendMessage({method: "prefChanged", prefName : "toggleNumber", value: newValue});

Actually it'd be reasonable to include the other three global behavior options as well!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions