Unpacking and Editing a Chrome Extension
I've been having an issue with one of my chrome extensions recently - the keyboard navigation extension that I blogged about previously. This is a huge problem for me because without this extension, I can't "click" on anything on the internet! It was working on some pages, but on others it was drawing elements but not styling them correctly. The extension doesn't seem to be actively maintained, so I realised I was going to have to dive into the extension itself to understand the problems and have any chance of fixing it. Hurrah for open source software (not that I really write any js but I figured if I could understand the problem, maybe I could ask more intelligent questions)
Unpacking a Chrome Extension
Actually this didn't take much unpacking once I found it. For me on ubuntu, all my files were in
~/.config/google-chrome/Default/Extensions/. The key is to visit chrome://extensions, and turn on "Developer mode" which is a tickbox in the top right corner. Then copy the ID of the extension you're going to be working with.
In the extensions directory, there are directories named in a garbledy way, but the directory names match the IDs of the extensions you see in chrome, so copy whichever extension you need to another location. You can then click the "Load unpacked extension" button to use your version of the extension instead of the existing one (I didn't uninstall the previous version and it didn't seem to cause a problem).
(I did find that I needed to add
"version": 2 to the manifest file, but I think that was just because this is an older extension. If you need to do this, chrome gives you a very clear error and link to more info when you try to load the extension)
At this point, you can edit to your heart's content, and then when you're ready to try out your changes in Chrome, save the files and click on the Reload link for your extension.
Fixing the Keyboard Navigation Extension
I'm not sure exactly what was causing the problem with the keyboard navigation extension, I observed all the little labels being created at the end of the page, but not styled or moved correctly ... critically the stylesheet includes a "position: absolute" which is how you know which label is for which page element! To fix the problem, I applied all the style properties programmatically in the code, bit of a hacky solution but it works for me.
I may also have taken the opportunity to de-orange the little labels too!
If you'd like the hacked version of the extension, you can find it on bitbucket: https://bitbucket.org/lornajane/keyboard-navigation-for-chrome/overview
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)