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
56
votes
8 answers

Chrome Extension message passing: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist

My chrome extension has the following two javascripts: background.js, running as background script: chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { if (message.data == "takeScreenshot") { var resp =…
Alexander
  • 19,906
  • 19
  • 75
  • 162
55
votes
1 answer

How to retrieve the element where a contextmenu has been executed

I am trying to write a google chrome extension where I use a contextmenu. This contextmenu is available on editable elements only (input texts for example). When the contextmenu is clicked and executed I would like to retrieve in the callback…
Laurent
  • 14,122
  • 13
  • 57
  • 89
55
votes
4 answers

ESLint: 'chrome' is not defined (no-undef)

I added ESLint to my chrome extension project. I am using chrome API which starts with chrome., but obviously eslint points on it as error. I suppose it should be something like: "env": { "browser": true, "chrome": true, "es6": true }, but…
Yuri Tymochko
  • 551
  • 1
  • 4
  • 6
55
votes
9 answers

How to keep Google Chrome Extension popup open?

If I open my extension popup then I open another window or tab following the popup does not stay open if I return to it. Is there a way to force it so the popup stays open?
jprim
  • 1,293
  • 2
  • 16
  • 21
55
votes
4 answers

How to clear chrome.storage.local and chrome.storage.sync?

I've written a Chrome Extension for my library. It uses chrome.storage.local to cache things. Does anyone know how to drop the cache for testing purposes? I can't really test things anymore as all the data is now in cache. I'd like to drop it and…
bodacydo
  • 75,521
  • 93
  • 229
  • 319
55
votes
4 answers

How to modify current url location in chrome via extensions

I want to create an extension that redirects the user to another website if he clicks on the extension button. So far I have only seen extensions which create a new tab for each click. Is it possible to redirect the user to another website using the…
user230054
54
votes
2 answers

What are the differences between page action and browser action?

I made a browser action, but I just tried testing a page action. The button is put in the same place, but the page action button can't be clicked (the icon is greyed-out). I thought page action buttons were located on the address bar, not in the…
punchh
  • 561
  • 1
  • 4
  • 5
53
votes
9 answers

How to delete a database in WebSQL programmatically?

I am new to Web SQL database and I use it to save data in a local database in a web page.  I can create a database by var db = openDatabase('database', '1.0', 'my database', 2 * 1024 * 1024);  and I can create a table by doing…
Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
53
votes
1 answer

Error 403: access_denied The developer hasn’t given you access to this app despite a new project being created

Please note: This is NOT a duplicate as I followed the SO only verified answer by creating a new project yet it didn't work. Also my case is with chrome extension or chrome app client ID from dev console. Error: Error 403: access_denied The…
53
votes
8 answers

Chrome extension in python?

I would like to create a google chrome extension. Specifically, I'd like to make a packaged app, but not a hosted app. Am I correct in thinking this limits me to JavaScript (and HTML/CSS)? My problem is that I need to do some complex math (singular…
Jeff
  • 12,147
  • 10
  • 51
  • 87
52
votes
11 answers

ReactJS chrome extension installed but not showing up

Anyone know why the ReactJS Chrome browser extension isn't showing for mein dev tools? It's installed, at one point it was working. I'm using chrome Version 39.0.2171.65 (64-bit) on Mac OS X v 10.7.5 I read the reviews on this extension, some people…
Giant Elk
  • 5,375
  • 9
  • 43
  • 56
52
votes
3 answers

Injecting iframe into page with restrictive Content Security Policy

I want to create a browser extension which creates a sidebar. Chrome does not have a first-class sidebar, and so we must instead put an iframe in the page. However, this breaks on many pages due to content security policy. E.g. GitHub uses a CSP,…
Ben McCann
  • 18,548
  • 25
  • 83
  • 101
50
votes
4 answers

Updating an extension button dynamically - inspiration required

I am building an extension where I want to be able to add a signifier to the extension button when the extension in the code has been activated. I was hoping I could add text to the extension button (top right) Here is a simple scenario. Let's say…
mozman2
  • 911
  • 1
  • 8
  • 17
50
votes
4 answers

How to inject CSS into webpage through Chrome extension?

I do not know how to inject CSS into a webpage through a Chrome extension. I am trying to inject this into a web page: body { background: #000 !important; } a { color: #777 !important; } Here is my…
timmya
  • 623
  • 1
  • 6
  • 5
50
votes
7 answers

Google Chrome Extensions: How to include jQuery in programmatically injected content script?

I'm injecting my content script from the background page when the user clicks the browser action button, like so: chrome.browserAction.onClicked.addListener(function (tab) { chrome.tabs.executeScript(null, { file: "content.js" }); }); So how…
mpen
  • 272,448
  • 266
  • 850
  • 1,236