Found: Work Around to Generate Color Picker

I’ve been having a problem getting the native color picker/color wheel for FF to launch from a context menu, because it runs into the popup blocker, which is a problem, since the interface is supposed to be entirely context menu based.

I have found a work-around.

More detailed code, at the Github for this project.

You can invoke a color picker by using the popup capabilities of a web-extension.

There are still some bits that I need to develop, but basically, my popup.html file is a table with the cells having different background colors:

color-pallet-2

When I click on the menu, (still working on the logic to limit it to certain menus only) a listener in the context menu invokes this:

browser.menus.onClicked.addListener(() => {
  browser.browserAction.openPopup(); //need if statement here
});

And then I use a listener to determine which cell is clicked, and then get the color, and pass it to the program.

It’s not optimal, I would prefer to use the native color picker, but it is good enough.

See my Github for more details.

1 Like

Just an update, I have the layout of the popup set up:
cp2

A quick question, as it will simplify the programming and improve the user experience: Is there a way to prevent the extension popup from closing when clicking outside of the focus?

No, use a sidebar if you want it to stay open. Or inject it into the page (though you already tried to do that, I gather)

It figures.

Hopefully, at some later date, there will be something added to the APIs to allow for the injection method at a later date.

Should I submit this as a bug?