您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动刷linuxdo文章
当前为
// ==UserScript== // @name Auto Read // @namespace http://tampermonkey.net/ // @version 0.1 // @description 自动刷linuxdo文章 // @author liuweiqing // @match https://linux.do/* // @grant none // @license MIT // ==/UserScript== (function () { ("use strict"); //1.进入网页 https://linux.do/t/topic/数字(1,2,3,4) //2.使滚轮均衡的往下移动模拟刷文章 localStorage.setItem("read", "true"); // 开始时就自动滚动 const delay = 2000; // 滚动检查的间隔(毫秒) let scrollInterval = null; let checkScrollTimeout = null; function scrollToBottomSlowly( stopDistance = 9999999999, callback = undefined ) { const distancePerStep = 20; const delayPerStep = 20; if (scrollInterval !== null) { clearInterval(scrollInterval); } scrollInterval = setInterval(() => { if ( window.innerHeight + window.scrollY >= document.body.offsetHeight - 100 || window.innerHeight + window.scrollY >= stopDistance ) { clearInterval(scrollInterval); scrollInterval = null; if (typeof callback === "function") { callback(); // 当滚动结束时调用回调函数 } } else { window.scrollBy(0, distancePerStep); } }, delayPerStep); } // 功能:跳转到下一个话题 function navigateToNextTopic() { // 定义包含两个URL的数组 const urls = [ "https://linux.do/latest", "https://linux.do/top?period=all", "https://linux.do/unread", "https://linux.do/new", ]; // 生成一个随机索引 const randomIndex = Math.floor(Math.random() * urls.length); // 根据随机索引选择一个URL const nextTopicURL = urls[randomIndex]; // 在跳转之前,标记即将跳转到下一个话题 localStorage.setItem("navigatingToNextTopic", "true"); // 尝试导航到下一个话题 window.location.href = nextTopicURL; } // 检查是否已滚动到底部(不断重复执行) function checkScroll() { if (localStorage.getItem("read")) { if ( window.innerHeight + window.scrollY >= document.body.offsetHeight - 100 ) { console.log("已滚动到底部"); navigateToNextTopic(); } else { scrollToBottomSlowly(); if (checkScrollTimeout !== null) { clearTimeout(checkScrollTimeout); } checkScrollTimeout = setTimeout(checkScroll, delay); } } } // 入口函数 // 检查是否正在导航到下一个话题 window.addEventListener("load", () => { if (localStorage.getItem("read") === "true") { if (localStorage.getItem("navigatingToNextTopic") === "true") { console.log("正在导航到下一个话题"); // 等待一段时间或直到页面完全加载 // 页面加载完成后,移除标记 localStorage.removeItem("navigatingToNextTopic"); //先随机滚动一段距离然后再查找链接 scrollToBottomSlowly( Math.random() * document.body.offsetHeight * 3, searchLinkClick ); } else { console.log("执行正常的滚动和检查逻辑"); // 执行正常的滚动和检查逻辑 checkScroll(); } } }); // 创建一个控制滚动的按钮 function searchLinkClick() { // 在新页面加载后执行检查 // 使用CSS属性选择器寻找href属性符合特定格式的<a>标签 const links = document.querySelectorAll('a[href^="/t/topic/"]'); const alreadyReadLinks = JSON.parse( localStorage.getItem("alreadyReadLinks") || "[]" ); // 获取已阅读链接列表 // 筛选出未阅读的链接 const unreadLinks = Array.from(links).filter( (link) => !alreadyReadLinks.includes(link.href) ); // 如果找到了这样的链接 if (unreadLinks.length > 0) { // 从所有匹配的链接中随机选择一个 const randomIndex = Math.floor(Math.random() * unreadLinks.length); const link = unreadLinks[randomIndex]; // 打印找到的链接(可选) console.log("Found link:", link.href); // // 模拟点击该链接 // setTimeout(() => { // link.click(); // }, delay); // 将链接添加到已阅读列表并更新localStorage alreadyReadLinks.push(link.href); localStorage.setItem( "alreadyReadLinks", JSON.stringify(alreadyReadLinks) ); // 导航到该链接 window.location.href = link.href; } else { // 如果没有找到符合条件的链接,打印消息(可选) console.log("No link with the specified format was found."); scrollToBottomSlowly( Math.random() * document.body.offsetHeight * 3, searchLinkClick ); } } const button = document.createElement("button"); button.textContent = "停止阅读"; button.style.position = "fixed"; button.style.top = "10px"; button.style.right = "10px"; button.style.zIndex = 1000; document.body.appendChild(button); button.onclick = function () { const currentlyReading = localStorage.getItem("read") === "true"; const newReadState = !currentlyReading; localStorage.setItem("read", newReadState.toString()); button.textContent = newReadState ? "停止阅读" : "开始阅读"; if (!newReadState) { if (scrollInterval !== null) { clearInterval(scrollInterval); scrollInterval = null; } if (checkScrollTimeout !== null) { clearTimeout(checkScrollTimeout); checkScrollTimeout = null; } localStorage.removeItem("navigatingToNextTopic"); } else { window.location.href = "https://linux.do/t/topic/13716/40"; checkScroll(); } }; })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址