【分享】微信读书网页版自动滚动油猴脚本

960 阅读1分钟
【分享】微信读书网页版自动滚动油猴脚本
油猴简单介绍

浏览器插件Tampermonkey,中文俗称油猴,可以把他理解为一个用户脚本管理器,依靠编写的扩展脚本(JavaScript代码)运行在浏览器上,来改变被访问网页的功能,提升我们的网页浏览体验。具体的浏览器插件安装请自行百度。

微信读书网页版自动滚动动画演示

Aug-31-2023 11-59-27.gif

微信读书网页版自动滚动脚本代码
// ==UserScript==
// @name         微信读书自动滚动
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       wandou
// @match        https://weread.qq.com/web/reader/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let i=0

    const scroll = () => {
        // 获取滚动区域的DOM
        let parentDom = document.querySelector(".renderTargetContainer .wr_canvasContainer")
        // 判断是否有滚动条
        parentDom.style.top='-'+i+"px";
        console.log(i);
        i++;
    };
    let timer= setInterval(scroll, 100);

    window.addEventListener("unload", function() {
        clearInterval(timer);
    });

})();