views:

21

answers:

1

I'm trying to block a script file from loading on user defined websites. To block a script file I'm using beforeload event and event.preventDefault(); in content script which works fine as long as I already know website list. My problem is I don't know website list in advance, so to get the website list I'm sending a request to background page but response is asynchronous and unusable.

Is there any synchronous message passing in Chrome Extensions that I possibly missed in Google's docs?

// my (simplified) code from content script:
document.addEventListener("beforeload", function(event)
{
  chrome.extension.sendRequest({fnc:"is_owner"}, function(response)
  {
    // asynchronous response is not usable because
    // all scripts have already been loaded
    if (response.is_owner) event.preventDefault();
  });
}, true);
+1  A: 

Unfortunately there isn't. There is a bug report opened about lack of synchronous message passing, maybe if enough people star it they will do something about it.

serg
Thanks for link, I stared it.
x64igor