微信阅读挂机

微信读书刷时长脚本。

当前为 2024-08-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         微信阅读挂机
// @namespace    npm/vite-plugin-monkey
// @version      1.0.7
// @author       cuihao777
// @description  微信读书刷时长脚本。
// @license      MIT
// @icon         https://weread.qq.com/favicon.ico
// @match        https://weread.qq.com/web/reader/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/umd/react.production.min.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/umd/react-dom.production.min.js
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==

(t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const o=document.createElement("style");o.textContent=t,document.head.append(o)})(" div._root_fqqqv_1{margin-left:0;margin-right:550px;left:initial;right:50%}div._root_fqqqv_1>._button_fqqqv_7{cursor:pointer;color:#fff}div._root_fqqqv_1>._button_fqqqv_7:hover{box-shadow:0 0 6px #ffffffb3}.wr_whiteTheme div._root_fqqqv_1>._button_fqqqv_7{color:#000}.wr_whiteTheme div._root_fqqqv_1>._button_fqqqv_7:hover{box-shadow:0 0 6px #000000b3}@media (max-width: 1365px){div._root_fqqqv_1{margin-right:430px}}@media (max-width: 1023px){div._root_fqqqv_1{margin-right:318px}} ");

(function (t, i) {
	'use strict';

	var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a={exports:{}},l={},s=t,f=Symbol.for("react.element"),d=Symbol.for("react.fragment"),p=Object.prototype.hasOwnProperty,v=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,y={key:!0,ref:!0,__self:!0,__source:!0};function m(t,n,e){var r,o={},i=null,c=null;for(r in void 0!==e&&(i=""+e),void 0!==n.key&&(i=""+n.key),void 0!==n.ref&&(c=n.ref),n)p.call(n,r)&&!y.hasOwnProperty(r)&&(o[r]=n[r]);if(t&&t.defaultProps)for(r in n=t.defaultProps)void 0===o[r]&&(o[r]=n[r]);return {$$typeof:f,type:t,key:i,ref:c,props:o,_owner:v.current}}l.Fragment=d,l.jsx=m,l.jsxs=m,a.exports=l;var h=a.exports,g={},w=i;function b(t$1){var r=t.useRef(t$1);r.current=t.useMemo((function(){return t$1}),[t$1]);var o=t.useRef();return o.current||(o.current=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return r.current.apply(this,t)}),o.current}function x(t$1){var e=t.useRef(t$1);return e.current=t$1,e}g.createRoot=w.createRoot,g.hydrateRoot=w.hydrateRoot,"function"==typeof SuppressedError&&SuppressedError;var j=function(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)},_="object"==typeof c&&c&&c.Object===Object&&c,E="object"==typeof self&&self&&self.Object===Object&&self,O=_||E||Function("return this")(),T=O,S=function(){return T.Date.now()},C=/\s/;var R=function(t){for(var n=t.length;n--&&C.test(t.charAt(n)););return n},k=/^\s+/;var L=function(t){return t?t.slice(0,R(t)+1).replace(k,""):t},N=O.Symbol,F=N,M=Object.prototype,$=M.hasOwnProperty,q=M.toString,A=F?F.toStringTag:void 0;var P=function(t){var n=$.call(t,A),e=t[A];try{t[A]=void 0;var r=!0;}catch(i){}var o=q.call(t);return r&&(n?t[A]=e:delete t[A]),o},W=Object.prototype.toString;var Y=P,I=function(t){return W.call(t)},U=N?N.toStringTag:void 0;var D=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":U&&U in Object(t)?Y(t):I(t)},X=function(t){return null!=t&&"object"==typeof t};var B=L,H=j,K=function(t){return "symbol"==typeof t||X(t)&&"[object Symbol]"==D(t)},z=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,V=/^0o[0-7]+$/i,J=parseInt;var Q=j,Z=S,tt=function(t){if("number"==typeof t)return t;if(K(t))return NaN;if(H(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=H(n)?n+"":n;}if("string"!=typeof t)return 0===t?t:+t;t=B(t);var e=G.test(t);return e||V.test(t)?J(t.slice(2),e?2:8):z.test(t)?NaN:+t},nt=Math.max,et=Math.min;var rt=function(t,n,e){var r,o,i,c,u,a,l=0,s=!1,f=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(n){var e=r,i=o;return r=o=void 0,l=n,c=t.apply(i,e)}function v(t){var e=t-a;return void 0===a||e>=n||e<0||f&&t-l>=i}function y(){var t=Z();if(v(t))return m(t);u=setTimeout(y,function(t){var e=n-(t-a);return f?et(e,i-(t-l)):e}(t));}function m(t){return u=void 0,d&&r?p(t):(r=o=void 0,c)}function h(){var t=Z(),e=v(t);if(r=arguments,o=this,a=t,e){if(void 0===u)return function(t){return l=t,u=setTimeout(y,n),s?p(t):c}(a);if(f)return clearTimeout(u),u=setTimeout(y,n),p(a)}return void 0===u&&(u=setTimeout(y,n)),c}return n=tt(n)||0,Q(e)&&(s=!!e.leading,i=(f="maxWait"in e)?nt(tt(e.maxWait)||0,n):i,d="trailing"in e?!!e.trailing:d),h.cancel=function(){void 0!==u&&clearTimeout(u),l=0,r=a=o=u=void 0;},h.flush=function(){return void 0===u?c:m(Z())},h},ot=j;const it=u((function(t,n,e){var r=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ot(e)&&(r="leading"in e?!!e.leading:r,o="trailing"in e?!!e.trailing:o),rt(t,n,{leading:r,maxWait:n,trailing:o})}));function ct(t$1,n){var o,i=x(t$1),c=null!==(o=null==n?void 0:n.wait)&&void 0!==o?o:1e3,u=t.useMemo((function(){return it((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i.current.apply(i,function(t,n,e){if(2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([],function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),c=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)c.push(r.value);}catch(u){o={error:u};}finally{try{r&&!r.done&&(e=i.return)&&e.call(i);}finally{if(o)throw o.error}}return c}(t),!1))}),c,n)}),[]);return function(t$1){var n=x(t$1);t.useEffect((function(){return function(){n.current();}}),[]);}((function(){u.cancel();})),{run:u,cancel:u.cancel,flush:u.flush}}function ut(t,n){let e=null,r=function(){let t=null;return {start:()=>{const n=new window.AudioContext;t=n.createOscillator(),t.frequency.setValueAtTime(2e4,n.currentTime),t.connect(n.destination),t.start();},stop:()=>{null==t||t.stop();}}}(),o=!1;return {start:()=>{e=function(){const e=`setInterval(() => postMessage(0), ${n});`,r=new Worker(URL.createObjectURL(new Blob([e])));return r.onmessage=t,r}(),r.start(),o=!0;},stop:()=>{null==e||e.terminate(),r.stop(),o=!1;},isRunning:()=>o}}const at="Timer is not initialized. Please use it after the component has been mounted.",lt="_root_fqqqv_1",st="_button_fqqqv_7",ft=({speed:t$1=1})=>{const[e,i]=t.useState(2),c=t.useRef(),u=function(t$1,e){const o=t.useRef(null),i=t.useRef(t$1),c=t.useRef(!1);return i.current=t$1,t.useEffect((()=>(o.current=ut((()=>i.current()),e),c.current&&o.current.start(),()=>{var t;return null==(t=o.current)?void 0:t.stop()})),[e]),{start:()=>{if(!o.current)throw new Error(at);o.current.start(),c.current=!0;},stop:()=>{if(!o.current)throw new Error(at);o.current.stop(),c.current=!1;},isRunning:()=>{if(o.current)return o.current.isRunning();throw new Error(at)}}}((()=>{window.scrollBy(0,1),l(),window.scrollY===c.current&&s(),c.current=window.scrollY;}),[40,20,10][t$1-1]),a=b((()=>{2===e?(u.start(),i(1)):(u.stop(),i(2));})),l=b((()=>{const t=new MouseEvent("mousemove",{clientX:100,clientY:100,screenX:2367,screenY:640,movementX:-10,movementY:-5});document.dispatchEvent(t);})),{run:s}=ct((()=>{const t=new KeyboardEvent("keydown",{key:"ArrowRight",keyCode:39});document.dispatchEvent(t);}),{wait:1e4,trailing:!1});return h.jsx("button",{className:"readerControls_item "+st,onClick:a,title:"自动播放",children:1===e?"挂机中":"挂机"})},dt=({speed:t,onChange:n})=>{const e=b((()=>{n(t%3+1);}));return h.jsxs("button",{className:"readerControls_item "+st,onClick:e,title:"滚动速度",children:[t,"档"]})};function pt(){const[n,e]=t.useState(1);return h.jsxs(t.Fragment,{children:[h.jsx(dt,{speed:n,onChange:e}),h.jsx(ft,{speed:n})]})}const vt=new class{constructor(){this.fontFamiliy="LXGW WenKai Screen";}hook(){const t=t=>{const n=this.getFont();return t.includes(n)?t:t.replace(/(.+?px\s)(.*)/,'$1"'+n+'", $2')},n=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){const e=n.apply(this,arguments),r=e.fillText;return e.fillText=function(){e.font=t(e.font),console.log(e.font),r.apply(e,arguments);},e};}setFont(t){this.fontFamiliy=t;}getFont(){return this.fontFamiliy}};function yt(){const n=document.createElement("div");n.className=lt+" readerControls",document.body.append(n),g.createRoot(n).render(h.jsx(t.StrictMode,{children:h.jsx(pt,{})}));}"loading"===document.readyState?(!function(){const t=document.addEventListener;document.addEventListener=function(n,e,r){["visibilitychange","blur","focus","contextmenu"].includes(n)||t.call(this,n,e,r);},vt.hook();}(),document.addEventListener("DOMContentLoaded",yt)):yt();

})(React, ReactDOM);