Quick and dirty Win32 web browser ON/OFF proxy toggle, tested with FireFox and IE6. Useful when switching between networks at work and home (for me, 5/7 days). As always, back up important files before risking them.
use strict;
use warnings;
my $proxy_on='user_pref("network.proxy.type", 1);';
my $prefs_js='C:/Documents and Settings/EdwardG/Application Data/Phoen
+ix/Profiles/default/7h4tw1oc.slt/prefs.js';
open my $p,'<',$prefs_js or die $!;
my @prefs = <$p>;
close $p;
my @prefs_minus_proxy = grep !/\Q$proxy_on\E/, @prefs;
my $proxy_was_off = ($#prefs == $#prefs_minus_proxy);
open $p,'>',$prefs_js or die $!;
print $p @prefs_minus_proxy;
print $p $proxy_on if $proxy_was_off;
close $p;
# Internet Explorer 6
my %regHash;
use Win32::TieRegistry ( TiedHash => \%regHash ); # thanks tye!
$regHash{"CUser\\Software\\Microsoft\\Windows\\CurrentVersion\\Interne
+t Settings\\ProxyEnable"}
=[ $proxy_was_off ? "0x0001" : "0x0000", "REG_DWORD" ];
$|=1;
print "Proxy is now ", $proxy_was_off ? 'ON' : 'OFF';
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.