轻小说文库下载器(Wenku8 Download)

轻小说文库下载器, 进入小说目录页面即可看的下载按钮

  1. // ==UserScript==
  2. // @name 轻小说文库下载器(Wenku8 Download)
  3. // @namespace FreeScripts
  4. // @description 轻小说文库下载器, 进入小说目录页面即可看的下载按钮
  5. // @include *://www.wenku8.net/novel/*/*/index.htm
  6. // @version 1.0
  7. // @grant GM_download
  8.  
  9. // ==/UserScript==
  10. ;(() => {
  11. const novelId = /\/novel\/\d+\/(\d+)/.exec(location.pathname)[1]
  12. const $ = document.querySelector.bind(document)
  13. const $$ = document.querySelectorAll.bind(document)
  14. const title = $('#title').textContent
  15.  
  16. const addBtn = (volume) => {
  17. const name = title + volume.textContent.trim() + '.txt'
  18. var current = volume.parentElement.nextElementSibling.firstElementChild
  19. var paragraphId = current.childNodes[0]
  20. .getAttribute('href')
  21. .replace('.htm', '')
  22. var url = `http://dl.wenku8.com/packtxt.php?aid=${novelId}&vid=${paragraphId}&charset=utf-8`
  23. var link = document.createElement('a')
  24. link.setAttribute('href', 'javascript:')
  25. link.addEventListener('click', () => GM_download(url, name))
  26. link.innerText = `下载 ${name} `
  27. volume.appendChild(link)
  28. }
  29.  
  30. var volumes = $$('.vcss')
  31. Array.from(volumes).forEach(addBtn)
  32. })()