WebHelper

Add some useful features to some websites.

当前为 2022-06-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WebHelper
  3. // @name:vi WebHelper
  4. // @namespace https://lelinhtinh.github.io
  5. // @description Add some useful features to some websites.
  6. // @description:vi Bổ sung một số tính năng hữu ích cho một vài trang web.
  7. // @version 1.0.1
  8. // @icon https://i.imgur.com/FHgT0E4.png
  9. // @author Zzbaivong
  10. // @oujs:author baivong
  11. // @license MIT; https://baivong.mit-license.org/license.txt
  12. // @match https://tienhieptruyen.net/*
  13. // @require https://unpkg.com/hotkeys-js/dist/hotkeys.min.js
  14. // @noframes
  15. // @supportURL https://github.com/lelinhtinh/Userscript/issues
  16. // @run-at document-idle
  17. // @grant none
  18. // @inject-into content
  19. // ==/UserScript==
  20.  
  21. /* global hotkeys */
  22. const k = hotkeys.noConflict();
  23.  
  24. const chapter = document.querySelector('.chapter-c');
  25. chapter.scrollIntoView();
  26.  
  27. let lineHeight = parseFloat(getComputedStyle(chapter).lineHeight);
  28. document.querySelector('.chap-list-update .font-size').addEventListener('change', () => {
  29. setTimeout(() => {
  30. lineHeight = parseFloat(getComputedStyle(chapter).lineHeight);
  31. }, 100);
  32. });
  33.  
  34. k('left', () => {
  35. document.querySelector('.chap-header .btn-next .fa-angle-double-left').parentNode.click();
  36. });
  37. k('right', () => {
  38. document.querySelector('.chap-header .btn-next .fa-angle-double-right').parentNode.click();
  39. });
  40.  
  41. k('up', () => {
  42. console.log(window.innerHeight);
  43. document.documentElement.scrollTop -= window.innerHeight - lineHeight;
  44. });
  45. k('down', () => {
  46. document.documentElement.scrollTop += window.innerHeight - lineHeight;
  47. });