Questions tagged [google-chrome-extension]

Extension development for the Google Chrome web browser. You write them using web technologies such as HTML, JavaScript, and CSS.

This tag is dedicated to questions about extension development for the Google Chrome web browser.

The Chrome extension API is documented here.

Absolute beginners should start here.

A good tutorial video by official Google Developers is available on YouTube

Overview of extension architecture can be read here.

The What's New page lists some of the recent changes to the extension APIs, while the Official Chrome Releases Blog announces new releases of Chrome and Chrome OS. For general updates on the browser, visit the Official Chrome Blog.

Troubleshooting

Before posting a question, make sure that you've read the API documentation. If some methods are not documented, it may be because they are deprecated.

If necessary, include relevant parts of your manifest.json file in the question.

A common source of errors is the misunderstanding of manifest version 2 and Content Security policy (CSP). Read the documentation for the CSP to see if it answers to your question.

For anything not related to development of Chrome extensions, such as issues with publishing in the Chrome Web Store, browse the Chromium-extensions Google group (now read-only). Extension authors with questions about the Chrome Web Store can contact the cws-developer-support team at https://support.google.com/chrome_webstore/contact/developer_support/.

Migration to Manifest Version 3

Manifest version 3 is now in support since chrome 88, and will be allowed on the chrome webstore on January 2021. It is recommended to read how to migrate from v2 to v3 and an overview of the new features are found here.

29271 questions
69
votes
7 answers

Cannot read property 'onClicked' of undefined when using chrome.action or chrome.browserAction

I'm writing a Chrome extension that will redirect me to a URL when clicking on the browser action icon. I'm trying to use: chrome.browserAction.onClicked.addListener but I get Uncaught TypeError: Cannot read property 'onClicked' of undefined This…
Alon Mahl
  • 693
  • 1
  • 5
  • 4
68
votes
2 answers

Extension refuses to load the script due to Content Security Policy directive

Following is my code of HTML Scripts: HTML:

and…
67
votes
1 answer

How do I import scripts into a service worker using Chrome extension manifest version 3?

I am trying to migrate my chrome extension from manifest version 2 to 3. Now that background scripts are replaced by service workers in manifest v3, I can no longer use a html file and refer js files in script tags. Is there any way I can import my…
67
votes
3 answers

Google Chrome Extension Numbers on the Icon

I've been experimenting with a Chrome Extension, and I want to make one similar to my Google Voice Extension where the icon shows a little blue "1" next to the icon when I receive an event, Is this a whole separate icon? and then they just use the…
Doug Molineux
  • 12,283
  • 25
  • 92
  • 144
67
votes
5 answers

Read the version from manifest.json

Is there a way for a Chrome extension to read properties from manifest.json? I'd like to be able to read the version number and use it in the extension.
Ben McCann
  • 18,548
  • 25
  • 83
  • 101
66
votes
6 answers

Chrome Console SameSite Cookie Attribute Warning

Is anybody else getting this Chrome console warning? A cookie associated with a cross-site resource at was set without the SameSite attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with …
66
votes
7 answers

Can I modify outgoing request headers with a Chrome Extension?

I can't see an answer to this in the Developer's Guide, though maybe I'm not looking in the right place. I want to intercept HTTP requests with a Chrome Extension, and then forward it on, potentially with new/different HTTP headers - how can I do…
Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
66
votes
5 answers

chrome.storage.sync undefined?

I'm trying to use chrome storage in an extension, via a content_script, but I keep failing on Uncaught TypeError: Cannot read property 'sync' of undefined This is my code: testChromeStorage(); function testChromeStorage() { …
Yossale
  • 14,165
  • 22
  • 82
  • 109
66
votes
6 answers

Inject CSS stylesheet as string using Javascript

I'm developing a Chrome extension, and I'd like users to be able to add their own CSS styles to change the appearance of the extension's pages (not web pages). I've looked into using document.stylesheets, but it seems like it wants the rules to be…
Dan Hlavenka
  • 3,697
  • 8
  • 42
  • 60
66
votes
7 answers

Chrome extension content script re-injection after upgrade or install

After the Chrome extension I'm working on is installed, or upgraded, the content scripts (specified in the manifest) are not re-injected so a page refresh is required to make the extension work. Is there a way to force the scripts to be injected…
65
votes
4 answers

Sqlite in chrome

Is it possible to make chrome extension that interacts with sqlite database similarly as firefox extension? Could you give me some advise or link where is more info about developing chrome extension interacting with sqlite? thank you
xralf
  • 3,312
  • 45
  • 129
  • 200
65
votes
3 answers

How to develop Chrome extension for Gmail?

I'm thinking about developing Chrome extension for Gmail and I want to know what are the current best practices. For instance: attaching a GPG signature by default to every email adding an extra button that does something (I have it…
Mars Robertson
  • 12,673
  • 11
  • 68
  • 89
65
votes
3 answers

How to change chrome packaged app id Or Why do we need key field in the manifest.json?

I'm developing packaged app for chrome store using one-time chrome wallet payments. For my app I need to check during the runtime if user bought the app or not to decide should it be demo functionality or full functionality. According to the chrome…
65
votes
4 answers

Chrome showing error as: Refused to execute inline script because of Content-Security-Policy

I am working on creating a Chrome Extension of an Image Cropping Widget. The code of my popup.html is as follows:
V15HM4Y
  • 1,757
  • 4
  • 26
  • 40
65
votes
4 answers

"Cannot read property of undefined" when using chrome.tabs or other chrome API in content script

chrome.tabs returns undefined despite the fact I set tabs in the permissions block. "permissions": [ "tabs", "http://*/*", "https://*/*" ], "content_scripts": [ { "matches": [ "http://*/*", …
Guy Korland
  • 9,139
  • 14
  • 59
  • 106