Greasy Fork is available in English.

shumin-微信读书

自用特化版本,原版参见https://greasyfork.org/zh-CN/scripts/421994

  1. // ==UserScript==
  2. // @name shumin-微信读书
  3. // @version 1.0.3
  4. // @namespace http://tampermonkey.net/
  5. // @description 自用特化版本,原版参见https://greasyfork.org/zh-CN/scripts/421994
  6. // @contributor Li_MIxdown;hubzy;xvusrmqj;LossJ;JackieZheng;das2m;harmonyLife;SimonDW
  7. // @author qianjunlang
  8. // @match https://weread.qq.com/web/reader/*
  9. // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js
  10. // @icon https://weread.qq.com/favicon.ico
  11. // @grant GM_log
  12. // @grant GM_addStyle
  13. // @grant unsafeWindow
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @grant GM_openInTab
  17. // @grant GM_download
  18. // @grant GM_setClipboard
  19. // @grant GM_notification
  20. // ==/UserScript==
  21. 'use strict';
  22.  
  23. /*
  24. GM_addStyle('*{font-family: FangSong !important;}');
  25. //GM_addStyle(".readerChapterContent{color: #FeFeFe;}");
  26. var style_tag = document.createElement('style');
  27. style_tag.innerHTML = `
  28. .bookInfo_title, .readerHeaderButton, .readerFooter_button, .readerTopBar, .readerTopBar_title_link, .readerTopBar_title_chapter, .actionItem.addShelfItem {
  29. font-family: Microsoft YaHei UI !important;
  30. }
  31. `;
  32. document.head.appendChild(style_tag);
  33. */
  34.  
  35. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  36.  
  37. $(window).on('load', async function () {
  38.  
  39. function getCurrentMaxWidth(element) {
  40. let currentValue = window.getComputedStyle(element).maxWidth;
  41. currentValue = currentValue.substring(0, currentValue.indexOf('px'));
  42. currentValue = parseInt(currentValue);
  43. return currentValue;
  44. }
  45. function changeWidth(increse) {
  46. const item1 = document.querySelector(".readerContent .app_content");
  47. const item2 = document.querySelector('.readerTopBar');
  48. const currentValue = getCurrentMaxWidth(item1);
  49.  
  50. item1.style['max-width'] = item2.style['max-width'] = parseInt( currentValue + 100*increse ) + 'px';
  51.  
  52. const myEvent = new Event('resize');
  53. window.dispatchEvent(myEvent)
  54. }
  55.  
  56. $(".readerControls_item.download").css("display", "none"); // 删除下载APP按钮
  57. $(".readerControls_item.isNormalReader").css("display", "none"); // 删除双栏
  58. $(".readerControls_item.wetype").css("display", "none"); // 删除微信输入
  59.  
  60. var butDiy = `<button id='lv-button1' class='readerControls_item widthIncrease' style='color:#ffffff;cursor:pointer;'>←→</button><button id='lv-button2' class='readerControls_item widthDecrease' style='color:#ffffff;cursor:pointer;'>→←</button>`;
  61. $('.readerControls').append(butDiy);
  62. document.getElementById('lv-button1').addEventListener('click', () => changeWidth(+1));
  63. document.getElementById('lv-button2').addEventListener('click', () => changeWidth(-1));
  64. changeWidth(5); // 默认加宽到最大
  65.  
  66. let rightBorder=14, rightOffset=-10;
  67. $('.readerControls').css({
  68. "position": "fixed",
  69. "transition": "right 0.05s ease-in 0s",
  70. "border-right": rightBorder +"px solid transparent",
  71. "left": "auto", 'opacity':'0.3', "right": rightOffset-rightBorder +"px",
  72. });
  73. $('.readerControls').hover(
  74. () => { $('.readerControls').css({'opacity':'1', "right": 0+"px",}) },
  75. () => { $('.readerControls').css({'opacity':'0.3', "right": rightOffset-rightBorder +"px",}) },
  76. );//等于.mouseleave().mouseenter()
  77.  
  78. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  79.  
  80. document.querySelector('.readerTopBar').style.transition = "top 0.1s ease-in 0s";
  81.  
  82. var windowTop = 0;
  83. $(window).scroll( () => {
  84. let scrollS = $(this).scrollTop();
  85.  
  86. document.querySelector('.readerTopBar').style.top = ( scrollS>=windowTop ? -70 : 0 ) +"px";
  87.  
  88. windowTop = scrollS;
  89. });
  90.  
  91. })();