1

We have a database with millions of domain categorizations (storing it client side is not an option) and we want to make a chrome extension to blacklist sites based on how they are categorized in the Mysql database.

The server side stuff is easy, we post the domain, and return the category.

The tricky part is blocking requests based on the categorization. Here are a few potential implementations and why they won't (quite) work.

Idea 1:

  1. Redirect all traffic using Chrome.webRequest to mysite.com/script.php?url=www.theoriginalurl
  2. This script checks the database's category & either redirects them to the theoriginalurl.com or denies the request, redirecting them to www.youGotBlocked...
  3. Have the chrome extension check the http referrer header to make sure that they came from mysite.com (unless the url is mysite.com, then do nothing).

Problems:

It doesn't seem like we can set the referrer header in PHP, so we have no way of knowing that they came from mysite.com. It seems like maybe we should be passing info via a cookie, but I haven't thought of an elegant solution involving cookies.

Idea 2:

Every time Chrome.webRequest fires make an AJAX POST request to mysite.com/categorizeURL.php with the URL to get the category. Block or allow based on the server's response.

Problems:

Either we make the request asynchronous and we can't get the response in time (their is no way that we have found to delay the callback until the server responds -- more on that here). Or we make the request synchronous, and IT WORKS!!! Except for the fact that if they can't reach our server, their entire browser locks up and they essentially need to refresh the extension to be able to access the internet again.

Other ideas?

Does anyone have other ideas for creating a blacklist via a Chrome extension? I simply refuse to believe that it is not possible.

Community
  • 1
  • 1
user417669
  • 178
  • 3
  • 15
  • 1. Why can't the list be stored (synced) to the client? 2. Would adding a timeout to the synchronous Ajax request help? – Whymarrh Jan 29 '14 at 00:36
  • @Whymarrh you actually can't add timeout's to synchronous ajax requests (I didn't believe it either) and the list is just way to big to store locally. Its over 50MB. – user417669 Jan 29 '14 at 00:38
  • @Dagon haha, people choose to install chrome extensions :) – user417669 Jan 29 '14 at 00:39
  • @user417669 are you serious about 50M? This is really not so much, especially if you choose to store it in IndexedDB – Dmitrii Sorin Jan 29 '14 at 07:30
  • The thing is IndexedDB actually also requires asynchronous access, so it wouldn't solve the problem :/ – user417669 Jan 29 '14 at 20:28

0 Answers0