Create a gist now

Instantly share code, notes, and snippets.

chrome拡張のユーザ数をImKayacで通知するスクリプト
#!/usr/bin/env perl
use strict;
use warnings;
use Web::Query;
use WebService::ImKayac::Simple;
use Log::Minimal;
# 自分のImKayacのアカウント
# パスワードとか鍵設定してる人は適当に直してください
my $im_kayac_user = '__USER_NAME__';
# 拡張のパーマリンクの共通部分
my $url_base = "https://chrome.google.com/webstore/detail";
# ここに拡張のパーマリンクの残り部分
my @app_list = (
"/twitter-search-it/ampkcohimpfbgopdhbnllmgofhmcbdla",
"/clone-to-sourcetree-butto/ebglgbilpccfljajcocchgpaddgapaoa"
);
my $msg = "";
for my $app_path (@app_list) {
my $wq = wq( $url_base . $app_path );
my $app_name = undef;
$wq->find("h1.webstore-test-detail-dialog-title")->each(
sub {
my ( undef, $wq ) = @_;
$app_name = $wq->text();
}
);
my $app_user = undef;
$wq->find(".webstore-f-g-Fe")->first()->each(
sub {
my ( undef, $wq ) = @_;
$app_user = $wq->text();
}
);
if ( $app_name && $app_user ) {
$msg .= sprintf( "%s : %s\n", $app_name, $app_user );
} else {
warnf "app_name is not found." unless ($app_name);
warnf "app_user is not found." unless ($app_user);
}
}
if ($msg) {
my $im = WebService::ImKayac::Simple->new( user => $im_kayac_user, );
$im->send($msg);
infof $msg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment