1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

小説家になろうのランキングで一話あたりの平均文字数を表示させたい

Posted at

小説家になろうのランキングで、新しく読むものを探すときに
一話あたりの平均文字数を表示させたいと思った。
(1話がどのくらいのボリューム感なのか知りたいのです。)
総文字数と総話数が出てるので、そこから引っ張ってくれば表示は出来そう。

jqueryを使っているみたいなので、そのまま利用させてもらう事にして
小説を読もう! || 小説ランキング[日間]
上で、下記のスクリプトを実行でひとまず平均文字数の表示ができた。

$(".rank_table").each(function(){
    var s=$(this).children().text().match(/全(\d+)部分/);
    if(s!=null){
        var t=$(this).find(".marginleft").text().match(/([0-9,]+)文字/)[1].replace(/,/g,'');
        $(this).append("<b>平均文字数:"+Math.round(t/s[1])+"</b>");
    }
})

まあ、話数とか文字数を正規表現で強引に抜き出しているので
ページの作りが変わってしまうと、使えなくなってしまうのだけど。

完全に小説家になろうのランキング専用になるけど
後でまた使いそうなので
ブックマークレットにしておこうとしたら
Qiitaだとjavascriptのリンク張れなかったので
とりあえずソースだけ置いておく。

javascript:(function(){$(".rank_table").each(function(){var s=$(this).children().text().match(/全(\d+)部分/);if(s!=null){var t=$(this).find(".marginleft").text().match(/([0-9,]+)文字/)[1].replace(/,/g,""); $(this).append("<b class=\"average\">平均文字数:"+Math.round(t/s[1])+"</b>");}})})()

もし使う人いれば、手動でブックマークに突っ込んでください。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?