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

eventPage.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. sites_url = "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/master/sites.json"
  2. sites = {}
  3. function getSitesAndMirrors() {
  4. $.getJSON(sites_url).done(function(data) { chrome.storage.local.set({"sites": data}) })
  5. }
  6. function getCurrentTabUrl(callback) {
  7. var queryInfo = {
  8. active: true,
  9. currentWindow: true
  10. };
  11. chrome.tabs.query(queryInfo, function(tabs) {
  12. var tab = tabs[0];
  13. var url = tab.url;
  14. console.assert(typeof url == 'string', 'tab.url should be a string');
  15. callback(url);
  16. });
  17. }
  18. function updateTab() {
  19. getCurrentTabUrl(function(url) {
  20. chrome.storage.local.get("sites", function(sites){
  21. sites = sites.sites
  22. domain = url.match(/:\/\/(www\.)?([^\/]+)\//).slice(-1)[0]
  23. if(domain in sites) {
  24. chrome.browserAction.setIcon({path: 'rsc/icon-red.png'})
  25. }
  26. else {
  27. chrome.browserAction.setIcon({path: 'rsc/icon.png'})
  28. }
  29. })
  30. })
  31. }
  32. chrome.runtime.onStartup.addListener(getSitesAndMirrors)
  33. chrome.runtime.onInstalled.addListener(getSitesAndMirrors)
  34. chrome.tabs.onActivated.addListener(updateTab)
  35. chrome.tabs.onUpdated.addListener(updateTab)