This sendRequest and onRequest seems a bit unwieldy, is there any
decent way to debug this? I tried to debug in chrome-extension:// but
of course my manifest doesn't have permissions for that protocol so it
gets to executeScript and stops. Tried adding chrome-extension://*/*
to my manifest but that protocol isn't allowed to be added.
Console.log doesn't seem to actually log stuff when you're inside a
browser action popup, and all I get is unhelpful error messages like:
"Uncaught SyntaxError: Unexpected end of input" which I understand is
an issue with my syntax and I've screwed it up somewhere, but its a
frustrating mess just to /try/ to get a browseraction popup to see a
password!
Any help with this would be appreciated, I don't want to go and dump
code here and wait for it to be fixed, but pointers/tips would be
appreciated definitiley:
console.log('Gonna set up the listener');
chrome.extension.onRequest.addListener(
function(request,sender,sendResponse) {
alert('We got a response of
'+request.Passwd)
pass=request.Passwd;
sendResponse({});
});
console.log('Gonna set up the tab query');
chrome.tabs.getSelected(null,
function(tab) {
document.getElementById('Domain').value=tab.url;
console.log('Setting up
the query code');
var codestr=
'var forms,i,form,n;'+
'forms =
document.forms;'+
'for(n=0;
n<forms.length; ++n) {'+
'form =
forms[n];for (i=0; i<form.length; ++i) {'+
'if (form[i].type.toLowerCase() == \'password\' && '+
'form[i].value.length>1) {'+
'console.log(\'Pass is\'+form[i].value);'
'chrome.extension.sendRequest({Passwd:form[i].value});'
'}'+
'}'+
'}';
console.log('Executing query code');
chrome.tabs.executeScript(tab.id,{code:codestr},function(){
console.log('Got callback');
if(pass &&
pass!='') {
console.log('Pass is not empty');
document.getElementById('Passwd').value=pass;
SGPLocal();
console.log('Done');
}
});
});
On Nov 24, 11:37 pm, Aaron Boodman <[email protected]> wrote:
> Keith, we don't have the feature to get a result from executeScript()
> yet, but you can workaround by having the script you execute send a
> message back to the extension. For details, see:
>
> http://code.google.com/chrome/extensions/messaging.html
>
> - a
>
>
>
> On Tue, Nov 24, 2009 at 3:34 PM, Nick Baum <[email protected]> wrote:
> > +chromium-extensions
>
> > On Tue, Nov 24, 2009 at 3:28 PM, Keith Cirkel <[email protected]> wrote:
>
> >> It wasn't for me at least... which is why I came to here.
> >> On a similar note to my first problem, how I can I get a variable from the
> >> executed script to the callback function? What I want to do is something
> >> like execudeScript(tab.id,{code:'var i=10;'},function(i){console.log(i));
> >> and it be 10. Is that possible?
>
> >> On Tue, Nov 24, 2009 at 11:23 PM, Nick Baum <[email protected]> wrote:
>
> >>> Is there any way we can make these errors point to the actual file & line
> >>> where the error occurred?
> >>> chrome/ExtensionProcessBindings:54 isn't very helpful...
> >>> -Nick
>
> >>> On Tue, Nov 24, 2009 at 2:17 PM, Erik Kay <[email protected]> wrote:
>
> >>>> (apologies for resend)
> >>>> Your call to executeScript should use tab.id (an integer), not tab (an
> >>>> object).
> >>>> Erik
>
> >>>> On Tue, Nov 24, 2009 at 12:03 PM, Keithamus <[email protected]> wrote:
>
> >>>>> As the title suggests, I am trying to find a way to fill all of the
> >>>>> password boxes on a page, while in a browser action. From what I can
> >>>>> see the best way to do this is using chrome.tabs.executeScript();
>
> >>>>> I'll show you my code so far:
>
> >>>>> var script =
> >>>>> var script = function() {
> >>>>> var forms,i,form,n;
> >>>>> f = document.forms;
> >>>>> for(n=0; n<forms.length;
> >>>>> ++n) {
> >>>>> form = forms[n];
> >>>>> for (i=0;
> >>>>> i<form.length; ++i) {
> >>>>> if
> >>>>> (form[i].type.toLowerCase() == 'password') {
>
> >>>>> form[i].value=Passwd;
> >>>>> }
> >>>>> }
> >>>>> }
> >>>>> }
>
> >>>>> chrome.tabs.getSelected(null,function(tab) {
>
> >>>>> chrome.tabs.executeScript(tab,{code:script,allFrames:true})
> >>>>> });
>
> >>>>> When I run this I get the following:
>
> >>>>> Uncaught Error: Invalid value for argument 0. Expected 'integer' but
> >>>>> got 'object' chrome/ExtensionProcessBindings:54
>
> >>>>> Which is infuriating as it tells me nothing.
>
> >>>>> Am I just noobing this, or am I on the right path? If people could
> >>>>> point me in the right direction that'd be great. Cheers
>
> >>>>> --
>
> >>>>> You received this message because you are subscribed to the Google
> >>>>> Groups "Chromium-extensions" group.
> >>>>> To post to this group, send email to
> >>>>> [email protected].
> >>>>> To unsubscribe from this group, send email to
> >>>>> [email protected].
> >>>>> For more options, visit this group at
> >>>>>http://groups.google.com/group/chromium-extensions?hl=en.
>
> >>>> --
>
> >>>> You received this message because you are subscribed to the Google
> >>>> Groups "Chromium-extensions" group.
> >>>> To post to this group, send email to
> >>>> [email protected].
> >>>> To unsubscribe from this group, send email to
> >>>> [email protected].
> >>>> For more options, visit this group at
> >>>>http://groups.google.com/group/chromium-extensions?hl=en.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/chromium-extensions?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=en.