Narou Index scroller

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

当前为 2019-09-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Narou Index scroller
  3. // @namespace http://ncode.syosetu.com/
  4. // @version 0.7
  5. // @description 小説家になろうの目次で前後の章に移動するアイコンとナビをつける
  6. // @author b2ox
  7. // @match https://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 fsize = parseFloat(nhead.css('font-size'));
  27. const h = Math.min(fsize * (n + 3), $(window).height() * 0.6);
  28. 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');
  29. chNavi.append(lst)
  30. nhead.append(chNavi)
  31. }
  32. }

QingJ © 2025

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