ad3 Performance
C<GM_setValue>, C<GM_getValue> and C<GM_log> talk to the proxy using
synchronous JSONRPC - so they're a little slow. It remains to be seen
whether this is a problem for typical Grease
shift;
my $h = $self->{_html} ||= HTML::Tiny->new;
return 'var GM__global = '
. $h->json_encode(
{
host => $self->{uri}->host,
passthru => $self->get_
}
req.open(method, url, async);
req.send(data);
}
// From http://www.JSON.org/json2.js
function GM__jsonEncode(value) {
var m = { // table of character substitutions
'\b':
package HTTP::Proxy::GreaseMonkey::Redirector;
use warnings;
use strict;
use Carp;
use JSON;
use HTTP::Response;
use HTML::Tiny;
use YAML qw( DumpFile LoadFile );
use LockFile::Simple qw( lock unlock
h_internal {
my ( $self, $headers, $message, $query ) = @_;
my $result = eval {
# JSON == YAML, right?
my %handler = (
setValue => sub {
my ( $args,
{_html} ||= HTML::Tiny->new;
my $qs = $h->url_decode( $query );
my $args = from_json( $qs );
my $method = delete $args->{m}
|| die "Missing 'm' arg";
my $c
= map { $h->json_encode( $_ ) } ( $self->namespace, $self->name );
return join "\n", map {
"function GM_$_() { return GM__proxyFunction("
. join( ', ', $h->json_encode( $_