AnyEvent-Chromi

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

## EXAMPLES

- List all tabs

        $chromi->call(
            'chrome.windows.getAll', [{ populate => Types::Serialiser::true }],
            sub {
                my ($status, $reply) = @_;
                $status eq 'done' or return;
                defined $reply and ref $reply eq 'ARRAY' or return;
                map { say "$_->{url}" } @{$reply->[0]{tabs}};
                $cv->send();
            }

- Focus a tab

        $chromi->call(
            'chrome.tabs.update', [$tab_id, { active => Types::Serialiser::true }],
        );

See also the "examples" directory:

examples/client.pl  view on Meta::CPAN

    my $cv = AnyEvent->condvar;

    AnyEvent::Chromi->new(mode => 'client', on_connect => sub {
        my ($chromi) = @_;
        $chromi->call(
            'chrome.windows.getAll', [{ populate => Types::Serialiser::true }],
            sub {
                my ($status, $reply) = @_;
                $status eq 'done' or return;
                defined $reply and ref $reply eq 'ARRAY' or return;
                map { say "$_->{url}" } @{$reply->[0]{tabs}};
                $cv->send();
            }
        );
    });

    $cv->wait();
}

main;

lib/AnyEvent/Chromi.pm  view on Meta::CPAN

=item *

List all tabs

    $chromi->call(
        'chrome.windows.getAll', [{ populate => Types::Serialiser::true }],
        sub {
            my ($status, $reply) = @_;
            $status eq 'done' or return;
            defined $reply and ref $reply eq 'ARRAY' or return;
            map { say "$_->{url}" } @{$reply->[0]{tabs}};
            $cv->send();
        }

=item * Focus a tab

    $chromi->call(
        'chrome.tabs.update', [$tab_id, { active => Types::Serialiser::true }],
    );

=back



( run in 1.306 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )