每隔2分钟模拟鼠标从屏幕中心向四个方向移动500像素,并显示运行信息
// ==UserScript==
// @name 自动模拟鼠标移动(屏幕中心,500像素)并显示运行信息,刷网课防止暂停
// @namespace none
// @version 0.2
// @description 每隔2分钟模拟鼠标从屏幕中心向四个方向移动500像素,并显示运行信息
// @match https://ua.peixunyun.cn/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 用于记录运行次数
let runCount = 0;
const intervalTime = 120000; // 每2分钟执行一次
const moveDistance = 500; // 移动距离500像素
// 创建并显示信息的div
function createInfoDiv() {
const infoDiv = document.createElement('div');
infoDiv.id = 'run-info';
infoDiv.style.position = 'fixed';
infoDiv.style.top = '10px';
infoDiv.style.right = '10px';
infoDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
infoDiv.style.color = 'white';
infoDiv.style.padding = '10px';
infoDiv.style.fontSize = '14px';
infoDiv.style.zIndex = '10000';
infoDiv.style.borderRadius = '5px';
document.body.appendChild(infoDiv);
updateInfoDiv();
}
// 更新显示的信息
function updateInfoDiv() {
const infoDiv = document.getElementById('run-info');
const currentTime = new Date().toLocaleTimeString(); // 获取当前时间
infoDiv.innerHTML = `
<p>第 ${runCount} 次运行</p>
<p>上次运行时间:${currentTime}</p>
<p>每次间隔:${(intervalTime / 60000)} 分钟</p>
`;
}
// 模拟鼠标移动
function moveMouse() {
// 运行次数增加
runCount++;
// 获取屏幕的宽度和高度
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
// 计算屏幕的中心点
const centerX = screenWidth / 2;
const centerY = screenHeight / 2;
// 模拟鼠标从屏幕中心向四个方向移动500像素
var directions = [
{dx: centerX, dy: centerY + moveDistance}, // 向下移动500像素
{dx: centerX, dy: centerY - moveDistance}, // 向上移动500像素
{dx: centerX + moveDistance, dy: centerY}, // 向右移动500像素
{dx: centerX - moveDistance, dy: centerY} // 向左移动500像素
];
// 顺序模拟四个方向的鼠标移动
directions.forEach(function(direction) {
var event = new MouseEvent('mousemove', {
'view': window,
'bubbles': true,
'cancelable': true,
'clientX': direction.dx,
'clientY': direction.dy
});
document.dispatchEvent(event);
});
// 每次移动后更新显示信息
updateInfoDiv();
}
// 初始化并创建信息显示
createInfoDiv();
// 每隔2分钟(120000毫秒)移动一次鼠标
setInterval(moveMouse, intervalTime);
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址