微信阅读挂机

微信读书刷时长脚本。

目前為 2024-08-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         微信阅读挂机
// @namespace    npm/vite-plugin-monkey
// @version      1.0.6
// @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 u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(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,e,n){var r,o={},i=null,u=null;for(r in void 0!==n&&(i=""+n),void 0!==e.key&&(i=""+e.key),void 0!==e.ref&&(u=e.ref),e)p.call(e,r)&&!y.hasOwnProperty(r)&&(o[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps)void 0===o[r]&&(o[r]=e[r]);return {$$typeof:f,type:t,key:i,ref:u,props:o,_owner:v.current}}l.Fragment=d,l.jsx=m,l.jsxs=m,a.exports=l;var h=a.exports,b={},g=i;function w(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=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.current.apply(this,t)}),o.current}function j(t$1){var n=t.useRef(t$1);return n.current=t$1,n}b.createRoot=g.createRoot,b.hydrateRoot=g.hydrateRoot,"function"==typeof SuppressedError&&SuppressedError;var _=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},E="object"==typeof u&&u&&u.Object===Object&&u,O="object"==typeof self&&self&&self.Object===Object&&self,x=E||O||Function("return this")(),T=x,S=function(){return T.Date.now()},R=/\s/;var C=function(t){for(var e=t.length;e--&&R.test(t.charAt(e)););return e},N=/^\s+/;var k=function(t){return t?t.slice(0,C(t)+1).replace(N,""):t},L=x.Symbol,q=L,A=Object.prototype,M=A.hasOwnProperty,P=A.toString,Y=q?q.toStringTag:void 0;var $=function(t){var e=M.call(t,Y),n=t[Y];try{t[Y]=void 0;var r=!0;}catch(i){}var o=P.call(t);return r&&(e?t[Y]=n:delete t[Y]),o},I=Object.prototype.toString;var U=$,W=function(t){return I.call(t)},D=L?L.toStringTag:void 0;var F=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":D&&D in Object(t)?U(t):W(t)},B=function(t){return null!=t&&"object"==typeof t};var X=k,z=_,K=function(t){return "symbol"==typeof t||B(t)&&"[object Symbol]"==F(t)},V=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,H=/^0o[0-7]+$/i,J=parseInt;var Q=_,Z=S,tt=function(t){if("number"==typeof t)return t;if(K(t))return NaN;if(z(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=z(e)?e+"":e;}if("string"!=typeof t)return 0===t?t:+t;t=X(t);var n=G.test(t);return n||H.test(t)?J(t.slice(2),n?2:8):V.test(t)?NaN:+t},et=Math.max,nt=Math.min;var rt=function(t,e,n){var r,o,i,u,c,a,l=0,s=!1,f=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=r,i=o;return r=o=void 0,l=e,u=t.apply(i,n)}function v(t){var n=t-a;return void 0===a||n>=e||n<0||f&&t-l>=i}function y(){var t=Z();if(v(t))return m(t);c=setTimeout(y,function(t){var n=e-(t-a);return f?nt(n,i-(t-l)):n}(t));}function m(t){return c=void 0,d&&r?p(t):(r=o=void 0,u)}function h(){var t=Z(),n=v(t);if(r=arguments,o=this,a=t,n){if(void 0===c)return function(t){return l=t,c=setTimeout(y,e),s?p(t):u}(a);if(f)return clearTimeout(c),c=setTimeout(y,e),p(a)}return void 0===c&&(c=setTimeout(y,e)),u}return e=tt(e)||0,Q(n)&&(s=!!n.leading,i=(f="maxWait"in n)?et(tt(n.maxWait)||0,e):i,d="trailing"in n?!!n.trailing:d),h.cancel=function(){void 0!==c&&clearTimeout(c),l=0,r=a=o=c=void 0;},h.flush=function(){return void 0===c?u:m(Z())},h},ot=_;const it=c((function(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return ot(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),rt(t,e,{leading:r,maxWait:e,trailing:o})}));function ut(t$1,e){var o,i=j(t$1),u=null!==(o=null==e?void 0:e.wait)&&void 0!==o?o:1e3,c=t.useMemo((function(){return it((function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.current.apply(i,function(t,e,n){if(2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value);}catch(c){o={error:c};}finally{try{r&&!r.done&&(n=i.return)&&n.call(i);}finally{if(o)throw o.error}}return u}(t),!1))}),u,e)}),[]);return function(t$1){var e=j(t$1);t.useEffect((function(){return function(){e.current();}}),[]);}((function(){c.cancel();})),{run:c,cancel:c.cancel,flush:c.flush}}function ct(t,e){let n=null,r=function(){let t=null;return {start:()=>{const e=new window.AudioContext;t=e.createOscillator(),t.frequency.setValueAtTime(2e4,e.currentTime),t.connect(e.destination),t.start();},stop:()=>{null==t||t.stop();}}}(),o=!1;return {start:()=>{n=function(){const n=`setInterval(() => postMessage(0), ${e});`,r=new Worker(URL.createObjectURL(new Blob([n])));return r.onmessage=t,r}(),r.start(),o=!0;},stop:()=>{null==n||n.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[n,i]=t.useState(2),u=t.useRef(),c=function(t$1,n){const o=t.useRef(null),i=t.useRef(t$1),u=t.useRef(!1);return i.current=t$1,t.useEffect((()=>(o.current=ct((()=>i.current()),n),u.current&&o.current.start(),()=>{var t;return null==(t=o.current)?void 0:t.stop()})),[n]),{start:()=>{if(!o.current)throw new Error(at);o.current.start(),u.current=!0;},stop:()=>{if(!o.current)throw new Error(at);o.current.stop(),u.current=!1;},isRunning:()=>{if(o.current)return o.current.isRunning();throw new Error(at)}}}((()=>{window.scrollBy(0,1),l(),window.scrollY===u.current&&s(),u.current=window.scrollY;}),[40,20,10][t$1-1]),a=w((()=>{2===n?(c.start(),i(1)):(c.stop(),i(2));})),l=w((()=>{const t=new MouseEvent("mousemove",{clientX:100,clientY:100,screenX:2367,screenY:640,movementX:-10,movementY:-5});document.dispatchEvent(t);})),{run:s}=ut((()=>{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===n?"挂机中":"挂机"})},dt=({speed:t,onChange:e})=>{const n=w((()=>{e(t%3+1);}));return h.jsxs("button",{className:"readerControls_item "+st,onClick:n,title:"滚动速度",children:[t,"档"]})};function pt(){const[e,n]=t.useState(1);return h.jsxs(t.Fragment,{children:[h.jsx(dt,{speed:e,onChange:n}),h.jsx(ft,{speed:e})]})}function vt(){const e=document.createElement("div");e.className=lt+" readerControls",document.body.append(e),b.createRoot(e).render(h.jsx(t.StrictMode,{children:h.jsx(pt,{})}));}"loading"===document.readyState?(!function(){const t=document.addEventListener;document.addEventListener=function(e,n,r){["visibilitychange","blur","focus","contextmenu"].includes(e)||t.call(this,e,n,r);};}(),document.addEventListener("DOMContentLoaded",vt)):vt();

})(React, ReactDOM);