I have to write an extension for saving user credentials to my database server (like in LastPass). How can I catch submit action from authentication form on active tab to grab entered login and password for saving using my extension and show dialog to a user, if he wants to save credentials or not?
Share
Add a content script in your manifest and set it to run on some webpage:
Also add permissions:
In this content script listen to event “onsubmit” on forms, then contact with your extension using chrome.extension.sendRequest():
In your background script add listener to these calls:
****Edited.****
You could also execute JavaScript directly on current active Tab and add form submit listeners:
First get the current window and active tab:
http://code.google.com/chrome/extensions/windows.html#method-getCurrent
http://code.google.com/chrome/extensions/tabs.html#method-getSelected
Then execute JavaScript in it:
http://code.google.com/chrome/extensions/tabs.html#method-executeScript
A comprehensive Google Chrome extensions API is here:
http://code.google.com/chrome/extensions/getstarted.html