ニコニコ漫画

    @@ -1,6 +1,6 @@ /* * @title ニコニコ漫画 - * @description Flash Player がない環境でニコニコ漫画を見る + * @description Flash Player がない環境でニコニコ漫画を見る * @include http://seiga.nicovideo.jp/watch/* * @license MIT License * @require @@ -10,8 +10,25 @@ var id = location.href.match(/http:\/\/seiga\.nicovideo\.jp\/watch\/mg([0-9]+)/); var url = []; +var bgm = []; var i = 0; -var img = $("<img></img>"); +var img = $("<img></img>").css({border: "solid 1px #000"}); +var audio = $("<audio autoplay loop></audio>").appendTo("body"); + +var next = function() { + $.ajax({ + url: '/api/theme/next?id=' + id[1], + type: 'get', + dataType: 'xml', + success: function(xml, status) { + if (status != 'success') return; + var next = $(xml).find("next"); + if (next && window.confirm(next.find("title").text())) { + location.href = "http://seiga.nicovideo.jp/watch/mg" + next.find("id").text(); + } + } + }); +}; $.ajax({ url: '/api/theme/data?theme_id=' + id[1], @@ -19,8 +36,9 @@ dataType: 'xml', success: function(xml, status) { if (status != 'success') return; - $(xml).find("source_url").each(function(){ - url.push($(this).text()); + $(xml).find("image").each(function(){ + url.push($(this).find("source_url").text()); + bgm.push("http://lohas.nicoseiga.jp" + $(this).find("bgm_path").text()); }); $("#playerBody").empty().append(img); img.attr("src", url[i]); @@ -30,10 +48,15 @@ if (x < w / 2) { if (url[i - 1]) i--; } else { - if (url[i + 1]) i++; + if (url[i + 1]) { + i++; + } else { + next(); + } } - img.attr("src", url[i]); + $(this).attr("src", url[i]); }); + audio.attr("src", bgm[0]); } });
  • /*
     * @title ニコニコ漫画
     * @description Flash Player がない環境でニコニコ漫画を見る
     * @include http://seiga.nicovideo.jp/watch/*
     * @license MIT License
     * @require 
     */
    
    jQuery(function($){
    
    var id = location.href.match(/http:\/\/seiga\.nicovideo\.jp\/watch\/mg([0-9]+)/);
    var url = [];
    var bgm = [];
    var i = 0;
    var img = $("<img></img>").css({border: "solid 1px #000"});
    var audio = $("<audio autoplay loop></audio>").appendTo("body");
    
    var next = function() {
        $.ajax({
            url: '/api/theme/next?id=' + id[1],
            type: 'get',
            dataType: 'xml',
            success: function(xml, status) {
                if (status != 'success') return;
                var next = $(xml).find("next");
                if (next && window.confirm(next.find("title").text())) {
                    location.href = "http://seiga.nicovideo.jp/watch/mg" + next.find("id").text();
                }
            }
        });
    };
    
    $.ajax({
        url: '/api/theme/data?theme_id=' + id[1],
        type: 'get',
        dataType: 'xml',
        success: function(xml, status) {
            if (status != 'success') return;
            $(xml).find("image").each(function(){
                url.push($(this).find("source_url").text());
                bgm.push("http://lohas.nicoseiga.jp" + $(this).find("bgm_path").text());
            });
            $("#playerBody").empty().append(img);
            img.attr("src", url[i]);
            img.click(function(e) {
                var w = $(this).width();
                var x = e.pageX - $(this).offset().left;
                if (x < w / 2) {
                    if (url[i - 1]) i--;
                } else {
                    if (url[i + 1]) {
                        i++;
                    } else {
                        next();
                    }
                }
                $(this).attr("src", url[i]);
            });
            audio.attr("src", bgm[0]);
        }
    });
    
    });
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/09/03 18:45:41 - 2013-09-03
  2. 2013/08/09 20:20:17 - 2013-08-09
  3. 2013/08/09 19:17:46 - 2013-08-09
  4. 2013/08/08 20:26:36 - 2013-08-08
  5. 2013/08/08 01:06:01 - 2013-08-08
  6. 2013/08/07 18:25:39 - 2013-08-07
  7. 2013/08/06 20:40:48 - 2013-08-06
  8. 2013/08/06 19:32:03 - 2013-08-06
  9. 2013/08/05 19:01:10 - 2013-08-05
  10. 2013/08/05 02:00:30 - 2013-08-05
  11. 2013/08/03 23:55:44 - 2013-08-03
  12. 2013/08/03 23:48:24 - 2013-08-03
  13. 2013/08/03 22:44:22 - 2013-08-03