how to debug chrome extension downloaded from chrome store - google-chrome-extension

I want to debug a chrome extension downloaded from chrome store. is it possible and how.
I have readium chrome extension and it is not working properly. I want to know why.
Thanks

If the extension run front-end scripts: right click on the page, Inspect > Sources tab > Content scripts tab. Then you can select the Chrome extension that not work correctly and add a breakpoint for example.
If the extension run back-end scripts: Go to this url: chrome://extensions then scroll to your extension and click on background page button. A popup will be opened and you can go to the sources tab and debug the script.

Related

How can I reload my Chrome extension when it is not possible to do so from chrome://extensions because of my extension?

I'm testing out Chrome Extension development and was testing how to do a page redirect through Chrome Extension.
Well it works, but now because of that I can't access the extension settings page.
How do I manually reload/disable the extension? Or do that from the Mac terminal?
My Chrome is pretty much unusable now thanks to my own code.
Thank you!
Tee
Your question seems to be "How can I reload my Chrome extension when it is not possible to do so from chrome://extensions because of my extension?"
A possible answer is:
Press Shift + Esc to open the task manager (or click on the hamburger menu -> More tools -> Task manager).
Select your extension.
Click on the "End process" button.
Now you can visit chrome://extensions and reload your extension in the usual way.
The previous only works if there is an extension process, not if your extension is purely a content script extension. If you still want to use the above method, you can force an extension process to become visible by opening chrome-extension://[extension id here]/manifest.json in a new tab.

launch chrome extension from command line

I have created a chrome extension which opens a new tab window,plays youtube videos and collects the network statistics.
What I currently do is to launch the chrome and then click the extension icon to run the extension. Now I want to automate the process of launching chrome and the extension simultaneously from command line.
Please guide me how I can open and run the extension on chrome from command line.
I have tried --load-and-launch-app and --load-extension.
You can move the logic of your extension in your background.js page. In this way when chrome starts, it will run your code in background.js without clicking extension icon.
For starting chrome use -
start chrome

Opening a Chrome extension as a pop-up using a link

I have a chrome extension installed in my browser. When I click the extension's icon in the menu bar the extension opens as a floating pop-up, as expected.
What I am trying to do is to open the extension in Chrome via a link/shortcut/whatever from another program. As a first step I've tried opening the extension from the command line, ex:
chrome "chrome-extension://abcdefghijklmnopqrstuvwxyz/index.html"
This works but the extension opens as a new tab and takes up a full broswer page instead of a just being a pop-up. Is there a way to open the extension as a pop-up on top of any open tabs?
Sadly, it's completely impossible.
There is an API in the works, but it would require at a minimum a user gesture, at a maximum explicit invocation of the extension.
So opening a link would not be enough, nor would a Native Message be.
you cant make the native extension popup to show programatically but you could use a content script that displays the popup (using the new for example) on the tab that you want.

is there any way to debug a chrome extension without setting a browser_action and a page_action?

I am learning to write chrome extensions. Sometimes ,i do want to learn from the examples given on the chrome developer site. As the instruction says, i need a browser_action or a page_action, then right click ,then inspect popup. I am wondering whether there is other ways to debug the chrome extension.
And the other thing is , i have to write "window.reload(true)" in the debug console to reload the popup page, is there a better or more convenient way to do it?
Of course it's not needed. Your extension either has a popup of some sorts, a background script of some sorts, or a content script of some sorts.
You already know how to debug a popup.
To debug a background page, you can go to chrome://extensions/ with Developer mode enabled. Then you'll see a "background page" link next to extensions that have them - you can click that link to bring up Dev Tools for the extension.
To debug a content script, you should look into the page's own Dev Tools. The console output will be displayed alongside normal console. To type code in the console to execute in the extension's context, you need to change the the context from <top frame> to the extension in the UI:
Depends on what you want to debug.
Chrome extensions also have background page and content-scripts.
Background page console you can find here: open chrome://extensions/ and under extension you'll see "Inspect views".
Content-scripts print messages to the page console.
Popup and other pages you can open in normal tab and inspect in its console. They are accessible by the url: "chrome-extension://YOUR_EXTENSION_ID/path/to/popup.html"

Chrome extension - inspect views don't show up

I'm new to Chrome extension development. I tried to follow the "hello world" debugging tutorial at http://developer.chrome.com/extensions/tut_debugging.html, but I couldn't find the inspect popup menu or inspect views link to open the debugger when I right-click on the "hello world" icon.
I noticed that in my chrome extension tab: chrome://chrome/extensions/, there is an "inspect views" link which enabled me to open a debugger for Google translate extension that I've installed before. However, the "inspect views" link didn't show up for "hello world" extension (source code: http://developer.chrome.com/extensions/examples/tutorials/getstarted.zip).
I have tried to search if someone has a similar problem but I couldn't find one. I'm using Google chrome 21.0.1180.60 for Windows XP.
Thanks in advance for any suggestions to open the debugger!
You are right... Try this:
Open the ext popup window by clicking on it
Right-click inside the displayed popup and choose the "Inspect Element" option
This will launch a dev tools instance for the popup.
For more details: http://samdutton.wordpress.com/2010/12/16/debugging-google-chrome-extensions/

Resources