How do I get rid of the Ellipsis when using '%s' to refer to the selected text?

Viewed 76

Currently beginning with learning some of the basics of making Webextensions for Firefox.

I'm trying to add a simple option to the context menu when the user has some text selected. Nothing fancy, outputting the selection to console works as intended. What doesn't however, is the text in the context menu itself.

When entering this code for the background.js:

browser.contextMenus.create({
  id: "log-selection",
  title: "Log '%s' to the console",
  contexts: ["selection"]
});

browser.contextMenus.onClicked.addListener(function(info, tab) {
  if (info.menuItemId == "log-selection") {
    console.log(info.selectionText);
  }
});

as described in https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/create

it should add

"Log 'selected text bla' to the console"

as an option to the context menu (right click menu).

It however shows as:

"Log 'selected text bla...' to the console"

(That MDN page has now been updated to reflect my findings)

I've already tried truncating by substracting 3 from %s, but it seems the string is evaluated at the very end of the create function. E.g. truncating 3 from %s would give me

""

instead of the desired

selected text bla

Extra info if needed - my manifest.json:

{

  "manifest_version": 2,
  "name": "Selection Logger",
  "version": "1.0",

  "description": "Add selection to context menu to print with console",

  "background": {
    "scripts": [
      "background.js"
    ]
  },

  "permissions": [
    "contextMenus"
  ],

  "applications": {
    "gecko": {
      "id": "myTest@tester.com"
    }
  }

}

Any ideas on how I can get rid of the Ellipses/3 dots? I've tried creating an inline function too, but it didn't work for me either.

title: function(){ return "test"; },

Didn't work, and I'm fairly sure violates some JS rules.

Help for this newbie appreciated!

2 Answers
Related