Open ghost opened 9 years ago
I'm going to provide the following magic snippet as a temporary solution.
var changes = {};
window.prompt().split(';').forEach(function (proxy, i) {
var profile = OmegaPac.Profiles.create({
name: "Proxy" + (i + 1),
color: "#99ccee",
profileType: "FixedProfile",
fallbackProxy: OmegaPac.Profiles.parseHostPort(proxy.trim(), 'http'),
});
OmegaPac.Profiles.updateRevision(profile);
changes[OmegaPac.Profiles.nameAsKey(profile)] = profile;
});
chrome.storage.local.set(changes, location.reload.bind(location));
As usual, to run this snippet, please press F12 (Cmd + Opt + I
on Mac) on the options page. Then select the "Console" tab and paste the above snippet there. After you press enter, a little prompt window will popup. Please enter all your proxies there seperated by semi-colon (like 127.0.0.1:1234;127.0.0.1:5678 and so on). You may want to copy & paste since it would be a very long string. Press enter and your proxies would be there.
Another way to do that would be importing a crafted backup file, as suggested by henderpa in the linked issue of the old version.
The backup file is in JSON format, and it won't be too hard to edit using text editors, provided that you have beautified the JSON.
Of course, JSON files are better to be edited and generated using programming languages. For example, the fragment containing your profiles can be printed by replacing the last line of the snippet with the following statement:
console.log(JSON.stringify(changes, null, 4));
The fragment can then be merged with an existing backup file. (By merging, I mean removing the out-most surrounding curly braces {}
of both files, join them with comma ,
, and finally surround the result again with curly braces {}
. Basically {AAAAA}
+ {BBBBB}
=> {AAAAA, BBBBB}
.)
Ive been trying around to change the proxy list i can download to get into that format but i cant find how. The proxy list i download goes as follows: 0.0.0.0:port 0.0.0.0:port 0.0.0.0:port and so on. How can i change that to 0.0.0.0:port;0.0.0.0:port;0.0.0.0:port?
@zamen40 Just use your text editor to replace the line breaks with semicolon. For example you can use vim to insert ";" at the end of each line :%s/$/;
, and then join them together ggvGJ
.
nevermind, accessing JavaScript console different on Mac it seems
Should this work for proxies with User/Pass authentication?
My format is IP:port:user:pass;
It's importing, but the formats are incorrect.
it's inputting the IP:port:user into the Server and nothing into the Authentication boxes.
@myrorym Comment above edited to show the right shortcut for Dev Console on Mac, which should be Cmd + Opt + I
by Google.
It is technically possible to add user/pass authentication, but it would take some time for me to enhance the magic snippet above. Stay tuned.
Thanks, I'm tuned in.
The following script should work for the host:port:user:pass
format.
Note: This won't work for IPv6 literals as host.
var changes = {};
window.prompt().split(';').forEach(function (proxy, i) {
var parts = proxy.trim().split(':');
if (parts.length < 2) return;
var profile = OmegaPac.Profiles.create({
name: "Proxy" + (i + 1),
color: "#99ccee",
profileType: "FixedProfile",
fallbackProxy: OmegaPac.Profiles.parseHostPort(parts[0] + ':' + parts[1], 'http'),
auth: parts[2] && {fallbackProxy: {
username: parts[2],
password: parts[3],
}}
});
OmegaPac.Profiles.updateRevision(profile);
changes[OmegaPac.Profiles.nameAsKey(profile)] = profile;
});
chrome.storage.local.set(changes, location.reload.bind(location));
Thanks!!!
One other issue, when i import a list of proxy ips in a particular order, when they get imported it automatically puts them in numerical order and takes them out of the order that I wanted them to make it easy for me to scroll through.
Is there a way to import them and preserve the order they were put into instead of always having them sorted numerically?
Thanks!!!
@stlpro Really? I believe they are always ordered by their name, which should be "Proxy 1", "Proxy 2", ...etc. And the number should be based on the exact order that you input. Am I wrong?
Hmm, maybe I have to have a default profile set up first? They are just named by their ips, so they get ordered by number. How would I import them with names? On Mar 26, 2015 1:26 AM, "FelisCatus" notifications@github.com wrote:
@stlpro https://github.com/stlpro Really? I believe they are always ordered by their name, which should be "Proxy 1", "Proxy 2", ...etc. And the number should be based on the exact order that you input. Am I wrong?
— Reply to this email directly or view it on GitHub https://github.com/FelisCatus/SwitchyOmega/issues/235#issuecomment-86358895 .
@stlpro Are you sure that you're using the snippet above? It doesn't require any default profile, and it creates profiles named like "Proxy 1". You can delete or reset your old, IP-named profiles and try importing again.
Is there bulk proxy import, either by way of magic snippets as in the below thread from proxyswitchy sharp or by a normal bulk import feature? I don't know if I should upgrade to the new one or not as I use the bulk import feature a lot.
https://code.google.com/p/switchysharp/issues/detail?id=887
Thanks!