When I try to add some shortcut keyboard for my new extension Chrome, it doesn't work. When I try to check my command with this line :
chrome.commands.getAll(command => { alert(JSON.stringify(command)) })
The description and the name is displaying correctly, but the shortcut property render an empty string. I've tried so many shortcut, delete et re-install my unpackaged extension after that, it doesn't work always.
My manifest.json :
{
"manifest_version": 2,
"name": "myfirstext",
"version": "1.0.0",
"description": "blablabla",
"author": {
"name": "Ben Lmsc",
"url": "https://github.com"
},
"background": {
"scripts": ["js/main.js"]
},
"browser_action": {
"default_popup": "index.html"
},
"commands": {
"handle_my_key": {
"suggested_key": {
"default": "Ctrl+Shift+L"
},
"description": "Description of my shortcut"
}
},
"icons": {
"16": "img/LOGO_16.png",
"32": "img/LOGO_32.png",
"48": "img/LOGO_48.png",
"128": "img/LOGO_128.png"
},
"permissions": [
"http://*/*",
"https://*/*",
"notifications"
]
}
Related
I'm trying to create a extension for Firefox that inserts a predefined text into the textbox by clicking on an option in the contextmenu.
I wrote the following code but it does not work:
function insert(text) {
document.getElementById('textbox').innerHTML = "THE TEXT I WANT";
}
chrome.contextMenus.create({
title: "TITLE", onclick: insert});
The manifest is also as follows:
"manifest_version": 2,
"name": "NAME",
"description": "DESCRIPTION",
"version": "1",
"author": "ME",
"homepage_url": "https://github.com",
"icons": {
"48": "icons/48.png",
"96": "icons/96.png"
},
"permissions": [
"activeTab",
"contextMenus",
"webNavigation"
],
"browser_action": {
"default_icon": {
"48": "icons/48.png",
"96": "icons/96.png"
},
"default_title": "TITLE"
},
"background": {
"scripts": [
"extension.js"
]
}
Thanks for your help.
I've followed some tutorials, but for some reason I'm not able to see the extension I added when I right-click.
manifest.json file
{
"name": "name",
"description": "description",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"contextMenus"
],
"background.service_worker": {
"scripts": ["eventPage.js"],
"persistent": false
},
"action": {
"default_icon": "icon.png"
},
"icons": {
"16" : "icon.png"
}
}
eventPage.js file
var contextMenuItem = {
"id": "id",
"title": "title",
"contexts": ["selection"]
}
chrome.contextMenus.create(contextMenuItem);
"manifest_version": 3,
"background": {
"service_worker": ""eventPage.js"
}
//OTHERWISE
"manifest_version": 2,
"background": {
"persistent": false,
"scripts": ["eventPage.js"]
},
I'm building a chrome extension and I have commands set in my manifest.json file as follows:
{
"manifest_version": 2,
"name": "Project X",
"description": "Quick lanch Project X",
"version": "0.0.1",
"icons": { "128": "icon_128.png" },
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["activeTab"],
"background":
{
"scripts": ["popup.js"],
"persistent": true
},
"commands": {
"execute-browser-action": {
"suggested_key": {
"default": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y"
},
"description": "Toggle feature foo"
}
}
}
My question is: Is it possible to change the default and mac keys (Ctrl+Shift+Y) to something else, during runtime? Specifically decided by the user?
I created a small extension for Microsoft Edge. It offers a right-click context menu item on certain elements. However, I noticed that the extension icon doesn't show up in the context menu if I don't have the browser action icon in the address bar. (The "show next to address bar" option) Not even the default icon is shown, it's just completely blank.
My manifest.json:
{
"name": "",
"author": "",
"version": "1.0",
"description": "",
"browser_action": {
"default_icon": {
"20": "images/icon.svg",
"40": "images/icon.svg"
},
"default_title": "",
"default_popup": "popup.html"
},
"icons": {
"16": "images/icon.svg",
"32": "images/icon.svg",
"64": "images/icon.svg",
"128": "images/icon.svg"
},
"permissions": [
"contextMenus",
"storage"
],
"background": {
"scripts": ["js/background.js"],
"persistent": true
}
}
The relevant code in my background.js:
browser.contextMenus.create({
id: "",
title: "Image",
contexts: ["image"]
});
Windows version: 1809, Build: 17763.1
Edge version: 44.17763.1.0
It would be helpful if you let us know your Win10 and Edge versions.
However, this problem doesn't exist on Win10 build (17763.1).
Here is my manifest.json:
{
"name": "test",
"author": "",
"version": "1.0",
"description": "",
"icons": {
"16": "icons/icon.png",
"32": "icons/icon.png",
"64": "icons/icon.png",
"128": "icons/icon.png"
},
"permissions": [
"contextMenus",
"storage"
],
"background": {
"scripts": ["background.js"],
"persistent": true
}
}
Background Script:
browser.contextMenus.create({
id: "log-selection",
title: "Sample",
contexts: ["selection"]
}, onCreated);
function onCreated() {
console.log("Context Menu item was created");
}
Let us also know your Context Menu item creation code from Background Script.
Try to set explicit sizes in both manifest.json and in every browserAction.setIcon call may help you to solve the issue.
Example:
Manifest.json
{
"manifest_version": 2,
"name": "test",
"version": "0.0.1",
"author": "demo_user",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_icon": {
"19": "icon.png",
"38": "icon2.png"
}
}
}
In JS file
browser.browserAction.setIcon({
path: {
"19": "testimage.png",
"38": "testimage.png"
});
Reference:
Edge: browserAction.setIcon not working when using a default icon with multiple sizes
You can try to make a test on your side and let us know about your testing result.
This my manifest:
{
"name": "Test",
"description": "Appliation",
"manifest_version": 2,
"version": "0.1",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "phone16.png", "256": "phone256.png" },
"browser_action": {
"default_title": "action description",
"default_icon": "phone20.png"
}
}
But when install this extension browser action icon is not shown.
Is there any problem?
Hoe can I show?
You are declairing a Chrome App, not an extension:
"app": {
...
}
Change the above block to:
"background": {
"scripts": ["background.js"]
}
(I.e. remove the wrapping app property, just leave background.)
Try this Manifest:
{
"name": "Test",
"version": "0.1",
"manifest_version": 2,
"description": "Appliation",
"browser_action": {
"default_title": "Test",
"default_icon": "images/phone19.png",
},
"icons": {
"19": "images/phone19.png",
},
"background": {
"scripts": ["background.js"]
}
}