If you're on Mac Dev channel, this may not work (it was the case
around a week ago, at least). In my extension in the background page
request handler I have:
sendResponse((sender.tab.url == request.location.href) ?
processRequest(request) : {});
Of course, I set request.location to document.location before making a request.
Evgeny
InvisibleHand
On Tue, Dec 22, 2009 at 6:47 PM, dk_man <[email protected]> wrote:
> Added 'all_frames':false as suggested, but I still seem to be getting
> multiple requests, as noted from the log entry:
>
> 62background.html:26d3l3lkinz3f56t.cloudfront.net
> 62background.html:26www.amazon.com
> 31background.html:26spe.atdmt.com
> 62background.html:26d3l3lkinz3f56t.cloudfront.net
> 31background.html:26view.atdmt.com
> 31background.html:26www.amazon.com
> 32background.html:26view.atdmt.com
>
>
>
> On Dec 22, 12:44 am, PhistucK <[email protected]> wrote:
>> Try to add to the content script entry in the manifest -
>> "all_frames": false
>>
>> This should be the default, but it might have been missed and will be fixed
>> soon.
>>
>> ☆PhistucK
>>
>> On Tue, Dec 22, 2009 at 10:41, dk_man <[email protected]> wrote:
>> > I'm coming across an unexpected behavior with the sendRequest() call.
>> > My basic setup involves a content_script which passes the hostname to
>> > the background.html for processing. Here's the stripped down code:
>>
>> > content_script:
>> > ===========
>> > chrome.extension.sendRequest(window.location.hostname);
>>
>> > background.html:
>> > ============
>> > chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
>>
>> > chrome.extension.onRequest.addListener(
>> > function(hostname, sender, sendResponse) {
>> > sendResponse({});
>>
>> > console.log(hostname);
>> > });
>> > });
>>
>> > What I'm encountering when I view the logs for a site like
>> > 'www.amazon.com'is that I'm logging nine different hostnames for each
>> > page load. I was expecting the content_script to only sendRequest()
>> > once instead of nine times. Also, why does the
>> > window.location.hostname from the content script send other hostnames
>> > in addition to Amazon?
>>
>> > Here's the output from the console:
>>
>> > 35background.html:26d3l3lkinz3f56t.cloudfront.net
>> > 35background.html:26www.amazon.com
>> > 70background.html:26d3l3lkinz3f56t.cloudfront.net
>> > 35background.html:26spe.atdmt.com
>> > 35background.html:26www.amazon.com
>> > 35background.html:26d3l3lkinz3f56t.cloudfront.net
>> > 35background.html:26view.atdmt.com
>> > 35background.html:26www.amazon.com
>> > 36background.html:26view.atdmt.com
>>
>> > Any help or clarification would be much appreciated.
>>
>> > --
>>
>> > 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]<chromium-extensions%[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.