Firefox extension – How to show text to user from background script?

This may be a very basic question, but I can’t find an answer on the internet. What I’m trying to do, is showing the user some text after clicking on a context menu item. I first thought about using alert() but then realized, that this isn’t possible in background scripts. Is there any alternative way to show some text to the user? Any ideas would be appreciated.

My background.js file:

browser.contextMenus.create({
    id: "showtext",
    title: "Show text",
    contexts: ["selection"]
});

browser.contextMenus.onClicked.addListener(function (info, tab) {
    switch (info.menuItemId) {
        case "showtext":
            {
                console.log(info.selectionText);
                // alert() doesn't work here
                // looking for alternative
            }
    }
});

FYI: I’m trying to create a little encryption and decryption tool.

PS: I’m a beginner in extensions. 🙁

151 thoughts on “Firefox extension – How to show text to user from background script?”

  1. i need a quick loan no credit check, i need loan to pay off debt. i need more loan money for college need loan now need a loan fast i need a loan with bad credit fast, the best cash advance loans, cash advances, cash advance loans, cash advance loans colorado springs. Financial affairs lending to commerce, accepts deposits.

    Reply

Leave a Comment