Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.   <script type="text/javascript">
  3.     var active = false;
  4.     var tor_config = {
  5.         mode: "fixed_servers",
  6.         rules: {
  7.                 proxyForHttp: {
  8.                         scheme: "http",
  9.                         host: "127.0.0.1",
  10.                         port: 8118
  11.                 },
  12.                 proxyForHttps: {
  13.                         scheme: "http",
  14.                         host: "127.0.0.1",
  15.                         port: 8118
  16.                 },
  17.                 proxyForFtp: {
  18.                         scheme: "http",
  19.                         host: "127.0.0.1",
  20.                         port: 8118
  21.                 },
  22.                 fallbackProxy: {
  23.                         scheme: "socks5",
  24.                         host: "127.0.0.1",
  25.                         port: 9050
  26.                 }
  27.  
  28.         }
  29.     };
  30.    
  31.     var default_config = {
  32.         mode: "direct"
  33.         };
  34.    
  35.     chrome.experimental.proxy.settings.get(
  36.     {'incognito': false},
  37.     function(config)
  38.     {console.log(JSON.stringify(config.value.mode));
  39.         if(config.value.mode == "fixed_servers")
  40.         {
  41.             active = true;
  42.             chrome.browserAction.setBadgeText({text : "TOR" });
  43.         }
  44.        
  45.     });
  46.    
  47.    
  48.    
  49.     chrome.browserAction.onClicked.addListener(function() {
  50.     var config = active ? default_config : tor_config;
  51.     active = !active;
  52.     var status = active ? "TOR" : "";
  53.     //var icon_url = active ? "/icon_on.png" : "/icon_off.png";
  54.    
  55.     chrome.experimental.proxy.settings.set(
  56.     {'value': config, 'incognito':false}
  57.     );
  58.     chrome.browserAction.setBadgeText({text : status });
  59.     //chrome.browserAction.setIcon({path: icon_url});
  60. });
  61.  
  62.  
  63.   </script>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement