Find access to blocked websites https://rsf.org/collateral-freedom

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function getCurrentTabUrl(callback) {
  2. // Query filter to be passed to chrome.tabs.query - see
  3. // https://developer.chrome.com/extensions/tabs#method-query
  4. var queryInfo = {
  5. active: true,
  6. currentWindow: true
  7. };
  8. chrome.tabs.query(queryInfo, function(tabs) {
  9. // chrome.tabs.query invokes the callback with a list of tabs that match the
  10. // query. When the popup is opened, there is certainly a window and at least
  11. // one tab, so we can safely assume that |tabs| is a non-empty array.
  12. // A window can only have one active tab at a time, so the array consists of
  13. // exactly one tab.
  14. var tab = tabs[0];
  15. // A tab is a plain object that provides information about the tab.
  16. // See https://developer.chrome.com/extensions/tabs#type-Tab
  17. var url = tab.url;
  18. // tab.url is only available if the "activeTab" permission is declared.
  19. // If you want to see the URL of other tabs (e.g. after removing active:true
  20. // from |queryInfo|), then the "tabs" permission is required to see their
  21. // "url" properties.
  22. console.assert(typeof url == 'string', 'tab.url should be a string');
  23. callback(url);
  24. });
  25. // Most methods of the Chrome extension APIs are asynchronous. This means that
  26. // you CANNOT do something like this:
  27. //
  28. // var url;
  29. // chrome.tabs.query(queryInfo, function(tabs) {
  30. // url = tabs[0].url;
  31. // });
  32. // alert(url); // Shows "undefined", because chrome.tabs.query is async.
  33. }
  34. function updateTab() {
  35. getCurrentTabUrl(function(url) {
  36. if(url.match(/:\/\/(.+)\//)[1] == "www.ijavn.org") {
  37. chrome.browserAction.setIcon({path: 'icon-red.png'})
  38. }
  39. else {
  40. chrome.browserAction.setIcon({path: 'icon.png'})
  41. }
  42. })
  43. }
  44. chrome.tabs.onActivated.addListener(updateTab)
  45. chrome.tabs.onUpdated.addListener(updateTab)