Answer the question
In order to leave comments, you need to log in
Extension for FF on WebExtexnsion on JS, doesn't see selectedtext?
Good afternoon!
I'm trying to write an extension for FF using the modern method, namely using the WebExtensionsAPI as described here:
the script itself is simple - by pressing the button (Alt + S) a window should open with a Google search for the selected text
, but for some reason this does not happen.
back.js:
browser.commands.onCommand.addListener(function(command) {
if (command == "toggle-feature") {
var selectedText = window.getSelection().toString().trim();
console.log("selectedText:" + selectedText);
browser.tabs.create({
"url": "https://www.google.com/search?q="+selectedText
});
}
});
{
"name": "Sample Commands Extension",
"description": "Press Alt+S to find in Google",
"manifest_version": 2,
"version": "1.0",
"background": {
"scripts": ["back.js"]
},
"commands": {
"toggle-feature": {
"suggested_key": { "default": "Alt+S" },
"description": "Send a 'toggle-feature' event to the extension"
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question