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

popup.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. console.log(domain)
  30. if(domain in sites) {
  31. proxies = sites[url.match(/:\/\/(.+)\//)[1]]
  32. $("#mirror").css("display", "block")
  33. $("#nomirror").css("display", "none")
  34. $("#mirror button").on("click", function() {
  35. takeMeTo(proxies[Math.floor(Math.random()*proxies.length)])
  36. })
  37. }
  38. else {
  39. $("#mirror").css("display", "none")
  40. $("#nomirror").css("display", "block")
  41. }
  42. })
  43. })