How to test local changes to Chrome Extension - google-chrome

I am trying to fix a bug in a Chrome extension. I installed the extension from the web store. I found the error. I opened the installed files and made changes that may or may not fix the problem locally. I saved the changes. Now Chrome complains and says "This extension may have been corrupted."
I have no idea if the change will work. I do not want to go through the build process and upload the modified extension to the web store just to test a three line change.
How do I get Chrome to just use the modified extension? Or can I just ignore the "This extension may have been corrupted" error?

I think I figured it out. I was seeing the "This extension may have been corrupted" error because I made the changes in place, meaning directly in "${LOCALAPPDATA}\Google\Chrome\User Data\Default\Extensions${extension_dir}". When I instead made the changes to my Perforce workspace directory and used the "Load Unpacked" feature to install the extension from there it worked.

Related

chrome extension reload on file change

I've been searching for-ever!
I`m working on windows and ubuntu, mostly on windows.
I searched the web for lot's of external libraries such as opn, open etc' but none of these could open this URL:
chrome://extensions
I want to put in the the script tag inside package.json
or in my build.js script
so that every time after I run "npm run build"
the chrome://extensions page will reload and also the additional page I`m testing on.
I once was able to do that exactly, but I lost that solution.
part of the problem is that I can't open chrome:
the ':' symbol is not recognized in the OS as valid protocol or something and it is escaped from chrome address bar if executed from command line.
I have tried many solutions.
I am not happy with the different resolutions proposed in the research I've made in Stack.O.
reloader as an extension is out of the question I want a script.
your kind help.
Assaf.
Clerc - for Chrome Live Extension Reloading Client
I built Clerc for exactly this purpose. npm run build won't be enough though. You need to hook up a LiveReload compatible server to watch for file changes, and clerc will listen for the reload messages.
Edit: Oh sorry. I missed the part where you said "reloader is out of the question". I still think this is your best option though.

Extension installed from Chrome Webstore throws error "Package is invalid. Details: 'Cannot load extension with file or directory name _metadata...'

When a CRX is added to the Chrome web store, Google adds a directory _metadata to the crx. Older versions of Chrome do not know about this directory (tested on Chrome 27) and throw this error:
Package is invalid. Details: 'Cannot load extension with file or directory name
_metadata. Filenames starting with "_" are reserved for use by the system.'.
You can see this error if you try to install this extension on an older version of Chrome: https://chrome.google.com/webstore/detail/allcast-receiver/hjbljnpdahefgnopeohlaeohgkiidnoe
A good explanation: https://groups.google.com/a/chromium.org/d/msg/chromium-apps/huDqSeaQx3Q/Z5GOMxA7lQIJ
Is there a workaround for this? This makes it impossible to support older versions of Chrome.
You can try to unzip the CRX (change the suffix name to ".zip" if needed) and then in chrome: Settings -> Extensions check "Developer mode", choose "load unpacked extension.." and select the extracted folder.
P.S.
I had to rename the folders starting with "_" (underscore) and remove the line
"default_locale":"en",
from the manifest JSON in order for that to work
You -as an extension developer- cannot work-around this bug, because the directory is added by the Chrome Web Store (CWS). You could work-around the bug by not using the CWS to distribute the extension, but then the extension cannot be used by the majority of Chrome users, because Google has actively tried to stop users from getting extensions from outside the CWS.
The CWS team are the only ones who can fix the bug. They should serve crx files without a _metadata directory if the user agent does not support the directory (Chrome 30-). This bug is being tracked on https://code.google.com/p/chromium/issues/detail?id=377278. So far, the response is:
We can't fix old versions of Chrome. Webstore side tracked at b/15176392, but extending support back to Chrome 30 is unlikely.
Star the issue to get notified of updates and to signal that you really want the bug to be fixed. If enough users/developers complain, then Google might fix the bug.
This answer applies to CRX files that you:
Downloaded from Chrome Web Store
Are trying to load unpacked
_locales folder should not pose problems. As long as the manifest contains default_locale key, Chrome will load the unpacked extension as expected.
_metadata is the problematic folder. It contains cryptographic hashes of all extension files to protect against tampering with those files, and is automatically added by CWS. This does not make sense in the context of an unpacked extension, and has no other use, so this folder simply needs to be deleted.
Some people found resetting works. Some found emptying the recycle bin works. None worked for me. I re-installed chrome also didn't work.
Instead this worked for me (same as what Xan said): I download the .crx file, unzip it, erase the folder
_metadata
Then install it manually. This worked for me.

Chrome : Install extension(crx) manually doesn't work anymore

We built a chrome extension to be used only inside our company by selective people. We do not want to publish this on chrome web store. We could do this before by just drag & drop the crx file in the extensions page.
But in the latest version of chrome(i use 35.x), we are not able to do this anymore. Whenever we try to install the crx file, chrome automatically disables it and shows a message
"This extension is not listed in the Chrome Web Store and may have been added without your knowledge"
with a link to https://support.google.com/chrome/answer/2811969 where it says
"You're seeing this notification because one or more of your Chrome extensions has been turned off to make Chrome safer. The extensions didn't come from the Chrome Web Store or were installed without your permission."
So, Does this mean we can never install crx file from now on? No workaround?
I know we can install using Group Policy method, but is that the only way we can do this?
Thanks in advance.
Yes, this has been disabled as a protection against malware.
The only workarounds I'm aware of are:
turn on Developer Mode and have users install as an unpacked extension after unzipping the CRX
publish unlisted or to a Google Group: https://support.google.com/chrome/a/answer/2663860?hl=en

Google Chrome extension development environment

As the title suggests I'm looking for a better Chrome extension development environment. I'm using Sublime Text 2 for my IDE, which is fine. The problem lies with testing the extension. Right now, when I need to test the code I've written I first have to launch Chrome with the –enable-easy-off-store-extension-install parameter. Then I need to package it through Chrome as an .crx file. Finally I have to drag and drop the file into Chrome and manually install it. Obviously this can get very time consuming very quickly.
I know I can test an extension as an unpacked extension, but this causes permission errors which is a problem since I need to perform CORs. Is there a better way to test extensions in Chrome?

Re-enabling extension installs

I found the new change that you can't install Chrome extensions/userscripts without saving them and dragging them into Chrome quite annoying. As such I have set forth to revert this to the old way it was.
I read the documentation here: http://www.chromium.org/administrators/policy-list-3#ExtensionInstallSources that says to add a registry key and so I have done, as shown below. However when attempting to install an extension I still get an error that they can only be installed from the Chrome webstore. Did I add the registry entries wrong or something?
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallSources]
"1"="http://*"
"2"="https://*"
This answer is obsolete as of Chrome 36
Instead of editing the registry, you can also make Chrome to behave in the old way via the --enable-easy-off-store-extension-install flag.
Under Windows, create a shortcut to your Chrome executable. Then edit the shortcut, and append --enable-easy-off-store-extension-install to "Target". See the screenshot below:
Some observations:
I've added the --enable-easy-off-store-extension-install flag after chrome.exe.
After starting Chrome, I visited a website that links to a .crx file that is not hosted in the Chrome web store.
Because of the flag, Chrome 20 doesn't show the "Extensions, apps, and user scripts can only be added from the Chrome Web Store" message any more. Instead (see bottom), Chrome asks me whether it's OK to install the extension - exactely as before.
This command line switch also works for Chromium/Chrome, under Linux and OSX.
If you ever find yourself in the situation where the --enable-easy-off-store-extension-install flag doesn't work (e.g. future version?) or you don't want to use it, then there is an alternative method.
You can install extensions with a plain vanilla install of Chrome by dragging .CRX extension files onto the Extensions panel in Settings.