Recently, I've started learning how to make Google Chrome extensions. My problem is that I don't know how to make a button in the toolbar so that when I click on it, it show me options for my extension like this example:
I can get the icon of my extension to appear in the toolbar, but nothing happens when I click on it. Here is my manifest.json:
{
"name": "Extension Name",
"version": "0.1.1.2",
"description": "Extension's description",
"manifest_version": 2,
"options_page": "options.html",
"background": {
"page": "index.html"
},
"browser_action": {
"name": "Manipulate DOM",
"icons": {
"128":"icon.png"
},
"default_icon": "icon.png"
},
"content_scripts": [ {
"js": [ "js-resource.js" ],
"matches": [ "http://*/*", "https://*/*"]
}]
}
That's a popup, not an options page. Currently you have two ways to do an options page as such:
Old way: In a separated tab.
New way (Chrome 40 onwards): In a popup in the extensions page.
However, those page are not too special and the only thing you should do to persist the user's preferences is to store them in chrome.storage.sync, as you can read in both links, respectively:
Use the storage.sync API to persist these preferences. These values will then become accessible in any script within your extension, on all your user's devices.
Always use the storage.sync API to persist your options. This will make them accessible from script within your extension, on all of your user's devices.
So as long as you store the preferences in there, you can make an options page in the browser action (or page action) popup. You just need to add the following to your manifest.json and to create the popup.html page:
"browser_action": {
"default_title": "Manipulate DOM",
"default_icon": "icon.png",
"default_popup": "popup.html",
...
}
Related
First of all, I'm trying to use the new manifest 3, but there are no samples out there so it's difficult to understand how develop a chrome extension.
I'm trying to build a basic Hello world app, and i want to have an icon on the toolbar so when the user clicks it, a message "hello" shows up on the page.
This second part is easy as I already know how to inject the code, but the problem is that I cannot seem to see the app icon in my tool bar...
{
"manifest_version": 2,
"name": "My App Name",
"version": "1.0.0",
"description": "do something",
"short_name": "My App Name",
"permissions": ["activeTab", "declarativeContent", "storage", "<all_urls>"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"css": ["src/bg/background.css"],
"js": ["src/bg/background.js", "js/jquery/jquery.min.js"]
}],
"browser_action":
{
"default_title": "My App Name",
"default_icon":
{
"16": "icons/icon16.png",
"32": "icons/icon32.png",
"48": "icons/icon48.png"
}
}
}
not sure what I need to add to see the icon
FYI I'm testing it locally ...i'm not sure if the local version acts differently from a packeged final version...
My Extension is not getting published because of 2 error
A justification for remote code use is required.
The single purpose description is required.
Here's my manifest:
{
"name": "Spotlight",
"icons": {
"128": "icon_128.png",
"96": "icon.png"
},
"description": "Spotlight - Browse open tabs, search history, bookmarks, downloads, and do much more!",
"version": "1.19",
"manifest_version": 2,
"permissions": [],
"update_url": "https://clients2.google.com/service/update2/crx",
"homepage_url": "https://usespotlight.co",
"optional_permissions" : [
"<all_urls>",
"tabs",
"bookmarks",
"history",
"downloads",
"storage"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_icon": "icon.png"
},
"commands": {
"toggle-feature": {
"suggested_key": {
"default": "Ctrl+M",
"mac": "Command+M"
},
"description": "Toggle spotlight"
}
}
}
You have to go to the new developer dashboard and fill out these fields under the Privacy menu.
Go to https://chrome.google.com/webstore/devconsole/ then click on Privacy menu (3th tab on the left) then fill all your purpose description. After that you can release your extension normally
These new requirements are not actually part of the manifest. In the new developer console, click your item and go to the privacy tab. You can find the various requirements there.
ActiveTab - Used to open tabs
Host Permission - Used to load files onto certain websites
"matches": [
"https://www.google.com/"
],
"js": [
"googleHome.js"
]
Single purpose description is an old suggestion and a new requirement. Just now being enforced because extensions are supposed to be small and serve a single purpose.
I want to show a splash page once I enter a URL and search. For example, if I go to https://youtube.com, then my Chrome extension will first show my splashpage.html. I was researching the override pages in the documentation, but it seems that I can only use "chrome_url_overrides" for new tabs, bookmark manager, and history.
My manifest.json has a newtab that opens up my "splashpage.html" when a new tab is entered. I would like to do this same action, but before the initial URL is loaded.
manifest.json
{
"manifest_version": 2,
"name": "Splash",
"version": "1",
"author": "LC",
"browser_action": { "default_title": "Have a good day", "default_popup": "popup.html" },
"chrome_url_overrides" : { "newtab": "splashpage.html"},
"permissions": ["activeTab"]
}
I have problem with my extension. It is working for me unpacked and when I download it from Chrome store.
However, some users reported that after update extension is corrupted. That's happen after they update it to newer version.
Difference between old and new version is background page and some logic.
I was able to replicate that issue, by packing extension and than drop it into extensions tab. After that I saw the same message as extension users. I also tried that with another extensions and everything worked fine, so maybe there is some issue in manifest file.
{
"manifest_version": 2,
"name": "Cryptocurrency Price Tracker",
"description": "This simple extension allows you to track price changes of Bitcoin and other cryptocurrencies.",
"version": "2.5",
"icons": {
"16":"icon16.png",
"48":"icon48.png",
"128":"icon128.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"storage",
"notifications",
"https://api.coinmarketcap.com/v1/*"
]
}
I use background page, not event page. So maybe I should add something in the manifest...
P.S. Packaging doesn't work for older version of extension... One more important thing. Users reported that after clicking on options page they saw that error. It didnt happend in my case, when I drag and drop extension file, I saw error immediately.
You need to put in a link to an update url in the manifest. The problem was mentioned in this forum:
https://productforums.google.com/forum/?hl=en#!topic/chrome/kGgLwnrDKpQ;context-place=forum/chrome
So you add update_url into your manifest. It can be any valid url if you are not making use of the feature. So like this:
"name": "Cryptocurrency Price Tracker",
"description": "This simple extension allows you to track price changes of Bitcoin and other cryptocurrencies.",
"version": "2.5",
"icons": {
"16":"icon16.png",
"48":"icon48.png",
"128":"icon128.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"options_ui": {
"page": "options.html",
"chrome_style": true
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"storage",
"notifications",
"https://api.coinmarketcap.com/v1/*"
],
"update_url": "http://www.example.com/update.xml"
I have just started developing chrome extension ( Using chrome 34).
My aim is to check for a ID attribute in a site by opening it in multiple languages.
For instance, whenever I open that website, and click on my extension link. The extension should open the website in multiple languages in background, and check if a html "ID" exists.
As a start, I want to get the current URL for that site.
manifest.json -
{
"manifest_version": 2,
"name": "Hello World!",
"description": "My extension",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
]
}
My popup.html is
<script type="text/javascript" src="currentUrl.js"/>
and currentUrl.js is
chrome.tabs.query({'active': true, 'windowId': chrome.windows.WINDOW_ID_CURRENT},
function(tabs){
alert(tabs[0].url);
}
);
But it is not working to alert the current URL. Whenever I click extension, just a small blank window appears.