5 use open ':encoding(utf8)';
6 binmode(STDOUT
, ":utf8");
11 use Glib qw
/TRUE FALSE/;
12 use List
::Util
qw(shuffle);
15 # http://stackoverflow.com/questions/254345/how-can-i-extract-url-and-link-text-from-html-in-perl
16 # http://www.perlmonks.org/?node_id=695886
17 my $website = WWW
::Mechanize
-> new
(agent
=> "NotBlocked/0.01");
18 $website -> get
($_[0]);
19 my @href = $website -> links
();
22 my $absolute_path = $_ -> url_abs
() -> abs;
23 my $key = sprintf "%s%s", $absolute_path, $_ -> text
();
24 $href_hash{$key} = [$absolute_path, $_ -> text
()];
31 my %href_hash = %{$_[1]};
32 my @href_keys = @
{$_[2]};
33 my $window = Gtk2
::Window
->new;
34 if ($href_hash{$href_keys[$_[0]-1]}->[1]) {
35 $window->set_title($href_hash{$href_keys[$_[0]-1]}->[1]);
37 $window->set_title($href_hash{$href_keys[$_[0]-1]}->[0]);
39 $window->set_default_size(500, 100);
40 $window->signal_connect(destroy
=> sub { Gtk2
->main_quit; });
41 my $button = Gtk2
::Button
->new($href_hash{$href_keys[$_[0]-1]}->[0]);
42 $window->add($button);
44 my $x = int(rand(1171));
45 my $y = int(rand(891));
46 $window->move($x, $y);
47 if ($_[0]-1 eq $#href_keys) {
54 my %href_hash = &html
($ARGV[0]);
55 my @href_keys = shuffle
keys %href_hash;
57 Glib
::Timeout
->add(200, sub{&x11
($count, \
%href_hash, \
@href_keys)});