Narou Index scroller

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

  1. // ==UserScript==
  2. // @name Narou Index scroller
  3. // @namespace http://ncode.syosetu.com/
  4. // @version 0.7.3
  5. // @description 小説家になろうの目次で前後の章に移動するアイコンとナビをつける
  6. // @author b2ox
  7. // @match *://ncode.syosetu.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. {
  12. const chapters = $('div.index_box > div.chapter_title')
  13. const lst = $('<ul>')
  14. const n = chapters.length
  15. chapters.each((i,elm) => {
  16. const nav = $('<span>')
  17. const _up = $('<span>').text('⇧').attr('title','前章へ移動').css('cursor','pointer').click(() => {$('#ct'+(i-1))[0].scrollIntoView();window.scrollBy(0,-20);})
  18. const _down = $('<span>').text('⇩').attr('title','次章へ移動').css('cursor','pointer').click(() => {$('#ct'+(i+1))[0].scrollIntoView();window.scrollBy(0,-20);})
  19. lst.append($('<li>').text($(elm).text()).css('margin','1ex').css('cursor','pointer').click(() => {$('#ct'+i)[0].scrollIntoView();window.scrollBy(0,-20);}))
  20. if (i>0) nav.append(_up)
  21. if (i<n-1) nav.append(_down)
  22. $(elm).attr('id','ct'+i).prepend(nav)
  23. })
  24. if (n > 0) {
  25. const nhead = $('#novel_header');
  26. const style = window.getComputedStyle(nhead[0]);
  27. const lsize = parseFloat(style.lineHeight == 'normal' ? style.fontSize : style.lineHeight);
  28. const h = Math.min(lsize * (n + 3), $(window).height() * 0.6);
  29. const chNavi = $('<div id="chapter_navi"/>').css('margin','1em').css('border','solid 2px black').css('width','max-content').css('height',`${h}px`).css('overflow','scroll');
  30. chNavi.append(lst)
  31. nhead.append(chNavi)
  32. }
  33. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址