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
47
votes
2 answers

How Can I Expand The Popup Window of My Chrome Extension

I want to expand the popup window which comes from when user click the extension button... (I want to expand the size of pop-up window to red area) Here is the code that I'm using to show pop-up; < style type="text/css" > body { min-width:…
Lost_In_Library
  • 3,265
  • 6
  • 38
  • 70
47
votes
2 answers

Extension manifest must request permission to access this host

I am trying to append a div to page of current active tab. However I am getting this error: Error during tabs.executeScript: Cannot access contents of url .... Extension manifest must request permission to access this host. My Code:…
dev02
  • 1,776
  • 3
  • 24
  • 45
47
votes
4 answers

Redirecting URL in a chrome extension

How can I go about redirecting chrome in an extension when visiting a given URL? For example: when I visit http://yahoo.com/ I want it to redirect to http://google.com/ NOTE: A former version of this question asked whether there is any Google chrome…
user1380936
46
votes
3 answers

Service worker registration failed. Chrome extension

I don't understand how to migrate from manifest v2 to v3 in part of Service Worker. Occurs error Service worker registration failed // manifest.json "background": { "service_worker": "/script/background/background.js" }, //…
Viewed
  • 1,159
  • 3
  • 16
  • 43
46
votes
6 answers

Chrome Extension - Content Security Policy - executing inline code

I am using an external JavaScript lib in my chrome extension. I has inline execution, so I get following kind of error (The error I get on console) Refused to execute JavaScript URL because it violates the following Content Security Policy…
Amit G
  • 2,293
  • 3
  • 24
  • 44
46
votes
4 answers

Recommended size of icon for Google Chrome Extension

This page explain 19*19 and 38*38. http://developer.chrome.com/extensions/browserAction.html#icon But this page explain 16*16 and 48*48, 128*128. http://developer.chrome.com/extensions/manifest/icons.html Which is correct?
hucuhy
  • 809
  • 3
  • 9
  • 15
46
votes
6 answers

How do you integrate Universal Analytics in to Chrome Extensions?

The chrome extension guide has a tutorial for the old analytics install: https://developer.chrome.com/extensions/tut_analytics.html The instructions just say to link to the https version and update the manifest to allow loading scripts from that…
StefanHayden
  • 3,569
  • 1
  • 31
  • 38
46
votes
1 answer

popup window in Chrome extension

I am writing a Chrome extension, and I want a login window to be popped up when users click on the context menu so that user can input username and password. In Chrome extension, I only found chrome.pageAction.setPopup and…
chaohuang
  • 3,965
  • 4
  • 27
  • 35
45
votes
5 answers

How do you use chrome.tabs.getCurrent to get the page object in a Chrome extension?

The code is meant to output the current tab object for the page the user is viewing to the console but it just outputs undefined. It's run from within a browser action page. chrome.tabs.getCurrent( function(tab){ console.log(tab); } ); I've…
45
votes
4 answers

Injecting JS functions into the page from a Greasemonkey script on Chrome

I have a Greasemonkey script that works just fine in Firefox and Opera. I struggle with getting it to work in Chrome, however. The problem is injecting a function into the page that can be invoked by code from the page. Here's what I'm doing so…
45
votes
8 answers

Is there an event for when a Chrome Extension popup is closed?

I've already tried window.unload, window.beforeunload, etc. I'm looking for a way to notify my background page once the popup is closed.
ebi
  • 4,862
  • 6
  • 29
  • 40
45
votes
3 answers

Insert an image in chrome extension

I want to know how to insert an image in a Chrome extension. I'm inserting that html tag correctly into a website, but naturally can't load that logo.png image. Any ideas on how to modify manifest.json?
jacktrades
  • 7,224
  • 13
  • 56
  • 83
44
votes
1 answer

Securing website API keys in Chrome extensions

I'm building a Chrome extension using the Remember the Milk web API. In order to call methods in this API, I need to sign my requests using an API key and a "shared secret" key. My concern is that any user could just crack open the extension and…
Josh Earl
  • 18,151
  • 15
  • 62
  • 91
44
votes
2 answers

How to migrate manifest version 2 to v3 for chrome extension?

I can't get my head around how to upgrade my chrome extension manifest v2 to v3 I checked https://developer.chrome.com/extensions/migrating_to_manifest_v3 but it doesn't talk about the manifest.json any idea what it needs to be changed in my…
user14064043
44
votes
1 answer

How to postMessage into iFrame?

I am developing a Chrome extension to use with my own Web-application, processing Web-pages (including cross-domain ones), loaded into iFrame on my application's main page. So I have to send message, containing the URL of the page to be processed,…