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
87
votes
22 answers

Port error: Could not establish connection. Receiving end does not exist. In Chromiume

I'm developing an extension in Chrome, and there's a problem. In my inject.js, I make a request like: chrome.extension.sendRequest({command:'skip'},callback) and in my `background.js I simply add a request Listener…
Lanston
  • 11,354
  • 8
  • 32
  • 37
86
votes
1 answer

Difference between two element styles with Google Chrome

I use Google Chrome developer tools and I am constantly inspecting one element against another back and forth to find out what may be causing a particular styling issue. It would be nice to compare the differences in style between element 1 and…
Valamas
  • 24,169
  • 25
  • 107
  • 177
85
votes
4 answers

Start an external application from a Google Chrome Extension?

How to start an external application from a Google Chrome Extension? So basically I have an executable file which does the job when you launch it. I need to be able to start it without a window (it is a console application) and pass the current URL…
Kristina
  • 15,859
  • 29
  • 111
  • 181
84
votes
5 answers

Difference between Chrome Apps and Extensions

What is the difference between Chrome Apps and Extensions? What can you do with apps that you can't do with extensions or vice versa?
frum
  • 883
  • 1
  • 7
  • 6
82
votes
7 answers

How to avoid "Extension context invalidated" errors when messaging AFTER an Extension update?

I am trying to create a smooth experience for users of my Chrome Extension after I release updates. I reinject my content script on an update of the app, and my functionality works even if the user continues to use my Extension on a page that has…
11teenth
  • 1,853
  • 1
  • 15
  • 28
82
votes
4 answers

How can a Chrome extension save many files to a user-specified directory?

I'm working on a Chrome extension to be used as an internal tool. Its required behavior is: As a page action, enable an address bar icon when looking at certain intranet pages. when the user clicks the icon, identify all files of a certain media…
Crashworks
  • 40,496
  • 12
  • 101
  • 170
81
votes
7 answers

Replay HTTP POST in google chrome Developer

Im switching from firebug to Google Chrome developer tools. I like it so far, but one feature that I really missing is replaying a http post. on firebug, I can right click on the request (on the net or console tab), "open in new tab" and replay…
81
votes
9 answers

Chrome extension compiled by Webpack throws `unsafe-eval` error

I get this error when reloading my Chrome Extension after compiling using Webpack: Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
81
votes
2 answers

Accessing `window`/DOM/HTML of the webpage from the extension

I'm writing a Chrome extension and trying to overlay a
over the current webpage as soon as a button is clicked in the popup.html file. When I access the document.body.insertBefore method from within popup.html it overlays the
on the…
Steven
  • 1,231
  • 1
  • 12
  • 11
81
votes
4 answers

Is it possible to create a Chrome Extension for private distribution outside Chrome Web Store?

We have a Chrome Extension application that we have developed and would like to distribute it only a limited number of internal users. This would be a private app, but to install it, users now have to follow the manual steps of going to Settings ->…
Ray Vol
  • 1,001
  • 1
  • 9
  • 8
80
votes
6 answers

Obtaining "this" tab ID from content script in Chrome extension?

From a content script, is it possible to access that tab's id? I want to send a message to the background page from the content script that tells my extension to "do something with this tab" using the chrome.tabs.* API. A tabID is needed, and there…
void.pointer
  • 24,859
  • 31
  • 132
  • 243
79
votes
4 answers

Pass a parameter to a content script injected using chrome.tabs.executeScript()

How can I pass a parameter to the JavaScript in a content script file which is injected using: chrome.tabs.executeScript(tab.id, {file: "content.js"});
user1365732
  • 1,071
  • 2
  • 9
  • 12
78
votes
1 answer

Debug tampermonkey script

I would like to debug a Tampermonkey script with Chrome's console, but I can't find my script in the list.. Am I doing something wrong, or is it just that the Tampermonkey scripts don't appear there? And in that case, how can I debug it?
thestral
  • 971
  • 1
  • 6
  • 12
78
votes
5 answers

How to communicate between popup.js and background.js in chrome extension?

The message from popup.js is being posted twice to background.js, but I get absolutely nothing from background.js. background.js function login(username,password){ console.log(username); var xhr = new XMLHttpRequest(); xhr.open("POST",…
Hick
  • 35,524
  • 46
  • 151
  • 243
77
votes
7 answers

Web Scraping in a Google Chrome Extension (JavaScript + Chrome APIs)

What are the best options for performing Web Scraping of a not currently open tab from within a Google Chrome Extension with JavaScript and whatever more technologies are available. Other JavaScript-libraries are also accepted. The important thing…