Narou Index scroller

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

ของเมื่อวันที่ 21-07-2017 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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.

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

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);
    });
})();