S
S
Spark72020-11-04 21:04:22
Google Chrome
Spark7, 2020-11-04 21:04:22

How to quickly switch proxy?

Can you tell me a software or extension for chromium-like ones that could easily change the proxy to the next one from the list I uploaded in a couple of clicks?
Everything that I found either with a bunch of prescribing paths to each server, or non-working extensions

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nadim Zakirov, 2020-11-05
@zkrvndm

Create a folder named Proxy , in it create 2 files.
The contents of the manifest.json file should be like this:

{
  
  "name" : "Proxy",

  "manifest_version" : 2,
   
  "version" : "1.0",
    
  "description" : "Болванка для создания расширения для смены прокси на лету",
    
  "permissions" : [ "proxy", "webRequest", "webRequestBlocking", "<all_urls>" ],
  
  "background" : { "persistent": true, "scripts": [ "background.js" ] }

}

The contents of the background.js file should be like this:
// Функция для установки произвольного http-прокси:

function setProxy(address, port, login, password) {
  
  if (typeof address == 'undefined' && typeof port == 'undefined') {
    
    chrome.proxy.settings.clear(
      {},
      function() {
        console.log('Настройки прокси успешно удалены');
      }
    );
    
  }
  
  else {
    
    if (typeof login == 'undefined' && typeof password == 'undefined') {
      
      window.auth = undefined;
      
    }
    
    else {
      
      window.auth = Object.create(null);
      window.auth['login'] = login;
      window.auth['password'] = password;
      
    }
    
    chrome.proxy.settings.set(
      {
        value: {
          mode: 'pac_script',
          pacScript: {
            data: 'function FindProxyForURL(url, host) { return "PROXY '+address+':'+port+'";  }'
          }
        },
        scope: 'regular'
      },
      function() {
        console.log('Прокси http://'+address+':'+port+' успешно установлен');
      }
    );
    
  }
  
}

// Автоматиечский ввод логина и пароля, если прокси требует авторизации:

chrome.webRequest.onAuthRequired.addListener(
    function(info, callback) {
        if (info.isProxy && typeof window.auth !== 'undefined') {
      callback({
        authCredentials: {
          username: window.auth['login'],
          password: window.auth['password']
        }
      });
    }
    else {
      callback();
    }
    },
    { urls: [ '<all_urls>' ] },
    [ 'asyncBlocking' ]
);

// Обнуление настроек прокси сразу после установки расширения:

chrome.proxy.settings.clear({}, function() {});

Next , install the Proxy folder as an extension in your browser:
Menu -> Additional tools -> Extensions ->
Developer mode -> Load unpacked extension

To change the proxy in the browser, just call the setProxy() function in the console of the extension's background page, passing the proxy address as the first parameter , the second port, the third login, and the fourth password. Example:
setProxy('185.202.3.118', '65233', 'idle', 'dfgfgfgfdd');

To remove a previously set proxy, just call the same function without parameters. And yes, it only works with http proxies, I did not support socks proxies, since this was not necessary in my project.
I hope you realize that this is just a sample code for changing the proxy in the browser. Of course, you need to remake the disc for yourself, making it an interface, but these are your worries, I definitely won’t do it for free.

Z
zlo1, 2020-11-05
@zlo1

raise the intermediary proxy ( 3proxy )
and specify it in the browser settings
and specify (change) the target proxy in the 3proxy configuration

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question