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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Get the current URL.
  3. *
  4. * @param {function(string)} callback - called when the URL of the current tab
  5. * is found.
  6. */
  7. function getCurrentTabUrl(callback) {
  8. var queryInfo = {
  9. active: true,
  10. currentWindow: true
  11. };
  12. chrome.tabs.query(queryInfo, function(tabs) {
  13. var tab = tabs[0];
  14. var url = tab.url;
  15. console.assert(typeof url == 'string', 'tab.url should be a string');
  16. callback(url);
  17. });
  18. }
  19. function takeMeTo(url) {
  20. updateProperties = {
  21. url: "https://" + url
  22. }
  23. chrome.tabs.update(updateProperties=updateProperties)
  24. }
  25. getCurrentTabUrl(function(url) {
  26. chrome.storage.local.get("sites", function(sites){
  27. sites = sites.sites
  28. domain = url.match(/:\/\/(.+)\//)[1]
  29. if(domain in sites) {
  30. proxies = sites[url.match(/:\/\/(.+)\//)[1]]
  31. $("#mirror").css("display", "block")
  32. $("#nomirror").css("display", "none")
  33. $("#mirror button").on("click", function() {
  34. takeMeTo(proxies[Math.floor(Math.random()*proxies.length)])
  35. })
  36. }
  37. else {
  38. $("#mirror").css("display", "none")
  39. $("#nomirror").css("display", "block")
  40. }
  41. })
  42. })