How to make chrome extension's id constant - google-chrome-extension

My problem is the same as this question: How to change chrome packaged app id Or Why do we need key field in the manifest.json?
Our extension isn't going to be published to the web store, I tried creating the crx file using Pack Extension in development mode, and then I uploaded the crx file to https://robwu.nl/crxviewer/ but it said:
Unexpected crx format version number
I tried unzipping the crx file to see the key field in manifest.json but it's not set at all.
I can't find my extension in my user data directory, my extension uses native messaging and I need the ID to be constant on all client devices for allowed_origins to work in the native host manifest.
So how to get the key value for our manifest?

You are getting that error because https://robwu.nl/crxviewer/ might be outdated. Install CRX viewer from the web store instead. After installing, use it on any extension. You will see something like this:
Click Open on the upper-right corner. You will see a page that looks similar to https://robwu.nl/crxviewer/. Now, click Choose File button and select your crx file. Open chrome's console (press F12 and click Console if it isn't selected by default) and you will see the key value for your manifest. Copy that and paste it into your extension's source manifest file.

Related

How to download file to system on click in electron using react frontend

I am building a desktop app using electronjs and frontend using React, I have a table with each column having a download icon that uses the information of that row to build a URL when opened with directly download a file to your PC.
I have tried using <a href=${download_url} download><a> works perfectly on the browser but fails to work through the electron app, it opens a file selector dialog box asking me to save the file.
I have also tried doing a window.open(url) but that just opens an empty window, and does not download contents from the url.
How am I supposed to do download the file sent over from the URL ?
The behavior on download depends on the browser you are using.
Some browsers ask where to save the file to (e.g. Mozilla Firefox), others ask for permission to save the file (e.g. Windows Edge) or just download the file with the given filename (e.g. Google Chrome by default).
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes for more information on the download attribute.
To solve your problem:
There is a electron-way to do it: https://electronjs.org/docs/api/download-item
And a library to make this process easier: https://github.com/sindresorhus/electron-dl

How to modify Chrome Extension, which authenticates every user through Google's OAuth 2?

I am trying to modify a small thing from an extension. All I basically need to edit, is the selector they use. If their selector is $("#firstDiv") I need it to be $("#secondDiv"). It is really that simple.
I downloaded the CRX file, extracted it, made the edit, but when I go and install it in my browser, it asks me to authenticate with Google Authenticator. Just like it's supposed to do, as it uses oAuth 2. HOWEVER, once I log into my Google account, it will not "save" the login. Right after I log in and press Log In, the tab closes and launches the same login page again on another page.
Is it possible to change that somehow? I found a semi-workaround. If I install the extension, authenticate with Google, then go make my edit in the extension folder, it works perfectly. However, I cannot send it to someone else, because the manifest.json includes my authentication key (392 characters long).
How can I modify the extension to my needs? Is there something I need to know about Google OAuth?
EDIT: Okay, I cannot even download the .crx file directly from Google, unzip the file, then move the files into a new folder, and install that script. Exactly like it came from Google. Are their .crx files signed? Is it impossible to do this?
When you download the .crx file, extract it, edit it and install it, its extension id is changed from the original one(this is the reason you are getting login page again and again). Now, client id used in extension is valid for only the original extension id. Thats why when you install it from web store it works fine because it retains its original extension id.
Solution :
You must retain the original extension id to make it work. First download crx viewer(very helpful for extension developers)
After installing crx viewer, navigate to your extension from web store. You will notice a page action(icon at the end of url). Click it , then click view source. New tab will open, then press f12 and check the console, you will find a "key" value. Copy it. Now go to your extension page again and download the extension as zip(from crx). Extract it and open its manifest.json file and paste the "key" along with value.(This step is necessary to retain extension id). Now install the extension from chrome by enabling developer's mode and clicking load unpacked extension and selecting the extracted extension. It should work now

Chrome extension deployment

I have developed a chrome extension and i always use developer mode to debug. Now I want to deploy it. Is there a way to install extension per chrome profile? and I wonder how to get the extension id?
1:extension ID can be found at chrome://extensions.like this:
2:I have no idea about your words "install extension per chrome profile". any way, if you want to use your chrome extension without developer mode. just use the"pack extension" button in the chrome extension page. you will get a crx file. to install it, just drag and drop it in you chrome.
you can also publish it to chorme web store. see here. then you and any other could easily install your extension frome chrome web store.
Firstly to deploy your extension on web store you must have google developer account which costs $5.
Secondly the chrome extension id which you see while developing extension in your pc is different from what you will get when you have deployed your extension on chrome store.
Basically when you deploy your extension,chrome store ask you to upload the zip of your extension folder not the crx file.Also note that it will not give you any .pem file like you will get when you pack your extension locally.Chrome store will maintain the same extension id on each updation.
Note that you cannot update the extension with the same version.You must increment the version number on each updation,otherwise chrome will show error on updation.

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 -> Extensions -> clicking on Developer mode -> drop the .crx in there.
I would like to know if there is a way to just have private App Store to privately distribute this app and not have it on Chrome Web Store for anyone to see/download/use.
Thanks for your help in advance ---
You use the Chrome Web Store. 2 options are available:
Share an unlisted Chrome extension from the Chrome Web Store (anyone with the link will be able to install it)
Chrome customers using G Suite or Education can use the Chrome Web Store to host private apps restricted only to their users on the same domain.
See https://support.google.com/chrome/a/answer/2663860
Update 2016-05-20: From https://support.google.com/chrome/a/answer/2663860?hl=en
Chrome customers using Google Apps for Work or Education can use the Chrome Web Store to host private apps restricted only to their users or people who you share a direct link to the app with. Users from the same Chrome domain will see their organization's private apps in a private collection in the Chrome Web Store.
Update 2015-10-27: Google has updated installation policies in attempt to curb malicious extension activity on Windows. On the chrome extension hosting page:
Warning: As of Chrome 33, Windows users can only download extensions
hosted in the Chrome Web store, except for installs via enterprise
policy or developer mode (see Protecting Windows users from malicious
extensions). As of Chrome 44, no external installs are allowed from a
path to a local .crx on Mac (see Continuing to protect Chrome users
from malicious extensions).
With the latest versions of Google Chrome, users are no longer going to be able to just click a download link and have it install with the correct HTTP headers. This leaves you with 4 possible options:
user downloads extension and then drags the file into the extension management page (This no longer works on Windows per update note)
change registry settings on users computers
user downloads extension source folder and loads extension from source in the extension management page
Re-enable extension installs with command-line flag as suggested by Rob W
I have created and distributed several different Google Chrome extensions privately within my company and went with the first option. It is an extra step for the users but it wasn't a big deal. The users did not have to have developer mode enabled in their Chrome browser for this to work.
Yes, you can. You need to create the crx file through the google chrome "Extensions" page (visit: chrome://extensions/ NOTE: You cannot click the link you have to manually copy and paste it, chrome does not allow you to visit the link from href)
On the Extensions page, check the box "developer mode", choose "pack extension".
Now you get the following popup. Click "browse" for the Extension root directory and navigate to the folder containing your extension (the folder containing manifest.json).
The first time you do this, ignore private key file. It will generate one for you automatically and save it to the same folder.
When you release a new version of the extension, use the generated private key file. This way for someone to update the extension, it won't ask for permissions again.
TO INSTALL
To install the extension, just get each user to manually drag the newly created extension crx into the Extensions page (chrome://extensions/).
The first time it will ask for permissions just like when installing from the Chrome Web Store.
For each new version, as long as you used the same private key file for each new version, users just drag the new version into the Extensions page the same way except they won't be asked for permissions again. It will just update the extension.
WARNINGS:
Beware the way you distribute the extension crx file. When user downloads the extension .crx file in Google Chrome, it will think you're trying to install the extension from that page, and come up a warning "couldn't be installed from this site". You need to make sure that users know to ignore the error, and check their downloads folder for the extension to manually install it.
Whenever you download the .crx file, Chrome will give the user a warning saying it might contain a virus. There is no way around this. Even if you zip up the file, Chrome will read the contents and give the same warning. Some users won't install because of this. A workaround is to rename the .crx to something else, like .RENAME_TO_CRX, but this is a hassle and a lot of users either won't want to or won't be able to figure it out.
You can't update the extension automatically. It's just not possible because Chrome manually blocked this capability.
NOTE: Another way would be to release it on the Chrome Store, but only for certain users (not public). Only people with the link could install, OR you could make it only certain people can install and even if you had the link but weren't part of the group, they couldn't view the extension. Only problem here is if you don't want Google to see the extension.
If you use Google Apps, it appears there's now a way to publish apps and extensions to the Chrome Web Store, but only make it visible to users of that domain.
https://support.google.com/chrome/a/answer/2663860?hl=en
Since its internal, could you change registry settings on their computers?
Because if so, you can use them to allow easy install of extensions from outside the web store or force install extensions on their machine.
Look here....
http://www.chromium.org/administrators/policy-templates
http://www.chromium.org/administrators/policy-list-3#ExtensionInstallSources
http://www.chromium.org/administrators/policy-list-3#ExtensionInstallForcelist

Install chrome extension as external extensions

I need install chrome extension as a manual way. So I follow this page https://developer.chrome.com/extensions/external_extensions. I install chrome extension with registry. Everything was fine. But the problem is: that extension cannot "remember anything". Each time I close and open chrome, it was installed again (extension show a welcome page) and everything it save from last session has gone. That problem does not exists if I install it as a normal way. So there are anyway to solve it?
Navigate to "chrome://extensions/" in the url bar...
Click "Developer mode" in the top right hand corner.
Click "Pack extension..."
In the "Extension root directory" field, choose the folder that contains all your extension files.
Leave the "Private key file" blank...
Click OK
Your extension will now be packed into a .crx file wherever your parent extension directory was on your computer... there will also be a .pem file, which is irrelevant really, it just holds your private key in case you won't to update this same extension, in which case you would pack the extension with the private key file...
Open the .crx in chrome... It will give you a message saying extensions and themes may harm your computer... click OK, this message only shows up because the extension has not been tested by google in the extension gallery... Your extension will install and will remember all your data

Resources