How to get chrome extension ID in dev and production? - google-chrome-extension

I work on a chrome extension.
I do use some messages between my web page and background process.
Problem is: the ID of my application is different when it comes from the google extension page and the one I locally work on and debugging.
Is there a way to make both ID same so debug and production version can communicate ?

Find it in the webstore developer dashboard. Click the more info button. Copy the "Public key". Add a "key" item to manifest.json. Paste the string value to key. Like this: "key": "yourPublicKey"

Related

Is there a way to get extension id in a chrome extension?

I want to get extension id of my chrome extension in extension codes. I know that extension id is a fixed string after being published to web store. But before it is published, the id changes when loaded from local folder. If I can get the id in codes, it will make debugging and testing much easier.
chrome.runtime.id works! Thanks to #Robbi,
More info about propertyId can be found over Chrome Docs

How can I get new chrome extension id before submit it for review?

I have developed one extension which takes session of my site by opening site in new tab and my site is talk with my chrome extension.
For send message from my website to chrome extension. I used my extension's id into my website.
I generate that extension id for development purpose only. Now I want to publish my extension and want to submit for review.
But problem is that , without my website., extension won't work as expected. So I need new extension id that will be generate after publish on Chrome Web Store and then I have to update my website to update id of extension into my website.
So how can I get uploaded extension's id before submit for review. So that I can update my website first before extension going for review.
Does any one have same kind of scenario ?
I don't know how google review our extension. So it needs to be working perfect before submit it in review.
You could upload the Extension to the Chrome Store but without publishing.
Then you could download it from the Chrome Dashboard.
Extract crx file. It is an ZIP File or use an Crx Viewer. (https://robwu.nl/crxviewer/)
the manifest.json should now contain a "Key" entry.
(https://developer.chrome.com/docs/extensions/mv3/manifest/key/)
Ensure that the Key is the same value for your local build. This should result into the same id.
When you Upload the Extension to the Chrome Store again, ensure that the Key entry is removed. Otherwise the Chrome Dashboard will reject the Upload.

Chrome extension: posting to an existing tab

simple question about the ability of chrome extensions.
Is it possible to for example hit an extension button and write the url (or other content of a page) to an endpoint of a open tab. For example, tab 1 is a web application that gathers bookmarks (so not locally stored) and if I hit a button in tab 3 I want to make a POST call to tab 1. Or can something like this be achieved by storing information in the Chrome storage which can then be read by the application in tab 1?
So quite simply:
tab 1 (:web application) - gets POST request -> tab 3 (:just a web page) through the click of a button of an active extension. I know if this would exist it could lead to some security issues, hence the question.

building chrome extension to read selected words from a web page

I would like to build a chrome extension to allow me select any word from any web page and by clicking a menu item to send it to a service of my company for tracking.
for example, if I am now reading some article on a page, I would like to select a specific word and right click on it, then I would like to make an http request to my service and track this word.
Is it possible to do with chrome extension? can you please link me to a tutorial that can be helpful?
Thanks.
Yes, you can use chrome extension to achieve that.
Refer Official Tutorial for more details.
Per your requirements, you may need:
Select a specific word. window.getSelection()
right click on it. You will need to listen to mousedown, mouseup or contextmenu event, the code looks like
document.addEventListener('contextmenu', function(event){...}, false);
make an http request. You can use XMLHttpRequest to transfer data between client and server.

Can Chrome Extension’s new options_ui trigger a page action?

I’ve been placing a page action on the options page of my Chrome extension. options.js calls chrome.runtime.connect({"name":"someName"}), and background.js has
chrome.runtime.onConnect.addListener(function(port) {
chrome.pageAction.show(port.sender.tab.id);
});
Unfortunately, in the new options_ui with the recommended default (and someday mandatory) "open_in_tab":false, the Sender's tab won't be set. Is there a way to get the tab id in order to show the page action?
I could use tabs.query to get the chrome://extensions/ tab, but that requires the tabs permission, which I currently don’t need. Active tab seems like it would work, but it doesn’t provide the tab id and isn’t enabled by opening an option dialog (source).
(Why do I want the page action on my options page? The extension works with a website that is only available ~7-10 weeks per year. I’d like my users to be able to interact with the extension the rest of the time, so that they can get used to the process. But I don’t want to adjust the displayed extension permissions just to do so. I can accomplish this by having the options page pretend to be the website in question.)

Resources