WWW-Mechanize-Firefox
view release on metacpan or search on metacpan
examples/proxy-settings.pl view on Meta::CPAN
#!perl -w
use strict;
use Getopt::Long;
use Firefox::Application;
my $ff = Firefox::Application->new();
# Check the network proxy settings
my $prefs = $ff->repl->expr(<<'JS');
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
JS
print "Your proxy settings are\n";
print "Proxy type\t", $prefs->getIntPref('network.proxy.type'),"\n";
print "HTTP proxy\t", $prefs->getCharPref('network.proxy.http'),"\n";
print "HTTP port\t", $prefs->getIntPref('network.proxy.http_port'),"\n";
print "SOCKS proxy\t", $prefs->getCharPref('network.proxy.socks'),"\n";
print "SOCKS port\t", $prefs->getIntPref('network.proxy.socks_port'),"\n";
# Switch off the proxy
if ($prefs->getIntPref('network.proxy.type') != 0) {
$prefs->setIntPref('network.proxy.type',0);
};
# Switch on the manual proxy configuration
$prefs->setIntPref('network.proxy.type',1);
=head1 NAME
proxy-settings.pl - display and change the proxy settings of Firefox
=head1 SYNOPSIS
proxy-settings.pl
lib/WWW/Mechanize/Firefox/Examples.pm view on Meta::CPAN
This program switches Firefox into fullscreen mode. It shows
how to access Firefox-internal variables and how to manipulate them.
=cut
Download this example: L<http://cpansearch.perl.org/src/CORION/WWW-Mechanize-Firefox-0.80/examples/fullscreen.pl>
=head2 Example: proxy-settings.pl
Check the network proxy settings
my $prefs = $ff->repl->expr(<<'JS');
#!perl -w
use strict;
use Getopt::Long;
use Firefox::Application;
my $ff = Firefox::Application->new();
# Check the network proxy settings
my $prefs = $ff->repl->expr(<<'JS');
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
JS
print "Your proxy settings are\n";
print "Proxy type\t", $prefs->getIntPref('network.proxy.type'),"\n";
print "HTTP proxy\t", $prefs->getCharPref('network.proxy.http'),"\n";
print "HTTP port\t", $prefs->getIntPref('network.proxy.http_port'),"\n";
print "SOCKS proxy\t", $prefs->getCharPref('network.proxy.socks'),"\n";
print "SOCKS port\t", $prefs->getIntPref('network.proxy.socks_port'),"\n";
# Switch off the proxy
if ($prefs->getIntPref('network.proxy.type') != 0) {
$prefs->setIntPref('network.proxy.type',0);
};
# Switch on the manual proxy configuration
$prefs->setIntPref('network.proxy.type',1);
=head1 NAME
proxy-settings.pl - display and change the proxy settings of Firefox
=head1 SYNOPSIS
proxy-settings.pl
( run in 0.784 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )