Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use strict; use warnings; =head1 NAME jsxray-proxy - A JavaScript::XRay proxy =head1 SYNOPSIS jsxray [options] Options: -port -switches -no-xray -help -man =head1 DESCRIPTION Straps L<HTTP::Proxy> onto L<JavaScript::XRay> so I can use JavaScript::XRay really easily and on arbitrary web sites. =over =item -port ... Specifies a port to listen on. The default is 8080. =item -switches Specifies switches to use for JavaScript::XRay. Prefix your switch wit +h no- to pass it as a turned off switch. =item -no-xray Doesn't install JavaScript::XRay. It's just a simple proxy now. =item -help Displays the program's options. =item -man Displays the entire manual. =back =cut use Getopt::Long 'GetOptions'; use autouse 'Pod::Usage', 'pod2usage'; GetOptions( help => \&help, man => \&man, 'port=i' => \( my ($port) = 8080 ), 'switches=s' => \( my ($switches) = 'all' ), 'no-xray' => \my ($no_xray) ) or pod2usage( -verbose => 0 ); sub help { pod2usage( -verbose => 1 ) } sub man { pod2usage( -verbose => 2 ) } require HTTP::Proxy; my $proxy = HTTP::Proxy->new( port => $port ); if ( not $no_xray ) { require HTTP::Proxy::BodyFilter::simple; require JavaScript::XRay; my %switches = map { /^no-(.+)/ ? ( $1 => 0 ) : ( $_ => 1 ) } $switches =~ /((?:no-)?[a-z]+)/g; my $filter = HTTP::Proxy::BodyFilter::simple->new( sub { return unless $_[2]->header('content-type') =~ /text/; my $uri = $_[2]->request->uri; my $xray = JavaScript::XRay->new( abs_uri => $uri, switches => \%switches ); ${ $_[1] } = $xray->filter( ${ $_[1] } ); } ); $proxy->push_filter( response => $filter ); } $proxy->start;

In reply to JavaScript::XRay + HTTP::Proxy equals Crazy Delicious by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found