I am developing a simple page action extension in google chrome and it has the following purpose.
I saw couple of examples on how to do that on window load and I was able to do a pop-up separately. But I am not able to access the parent html from the pop-up's html.
Any help would be highly appreciated.
Here are the contents of my code.
Manifest.json:
{
"name": "My First Chrome App",
"version": "1.0",
"description": "Auto fill content",
"background": { "scripts": ["background.js"] },
"page_action" :
{
"default_icon" : "icon-19.png",
"default_title" : "Auto Fill",
"default_popup" : "test.html"
},
"permissions" : [
"tabs"
],
"icons" : {
"48" : "icon-48.png",
"128" : "icon-128.png"
},
"manifest_version": 2
}
background.js
function checkForValidUrl(tabId, changeInfo, tab) {
//checks whether the document contains Steve Jobs
if (tab.url.indexOf("gmail")) {
chrome.pageAction.show(tabId);
}
};
chrome.tabs.onUpdated.addListener(checkForValidUrl);
test.html
<html>
<head>
<title> Hi Steve </title>
<script type="text/javascript">
function fill()
{
alert("inside method");
}
</script>
</head>
<body>
<form name="userinfo" id="userinfo">
username :
<input type="text" name="username"/>
password :
<input type="password" name="password"/>
<input type="button" value="Log In" onclick="fill()";/>
</form>
</body>
</html>
Thanks, Shankar
Create a popup window for your login that has the username and password fields.
http://code.google.com/chrome/extensions/browserAction.html#popups
When the popup form is submitted send a message to the background page which then sends a message to your (page's) content script which is then responsible for filling out and submitting the form.
http://code.google.com/chrome/extensions/content_scripts.html
You'll need to understand message passing to do this:
http://code.google.com/chrome/extensions/messaging.html