Narou Index scroller

小説家になろうの目次で前後の章に移動するアイコンをつける

Tính đến 21-07-2017. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Narou Index scroller
// @namespace    http://ncode.syosetu.com/
// @version      0.3
// @description  小説家になろうの目次で前後の章に移動するアイコンをつける
// @author       b2ox
// @match        http://ncode.syosetu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var chapters = $('div.index_box > div.chapter_title');
    var n = chapters.length;
    chapters.each(function(i,e){
        var nav = $('<span>');
        var _up = $('<span>').text('⇧').attr('title','前章へ移動').css('cursor','pointer').click(function(){$('#ct'+(i-1))[0].scrollIntoView();window.scrollBy(0,-20);});
        var _down = $('<span>').text('⇩').attr('title','次章へ移動').css('cursor','pointer').click(function(){$('#ct'+(i+1))[0].scrollIntoView();window.scrollBy(0,-20);});
        if (i>0) nav.append(_up);
        if (i<n-1) nav.append(_down);
        $(e).attr('id','ct'+i).prepend(nav);
    });
})();