// ==UserScript== // @name 长佩专用 - 自动翻页 只显示匿名 // @namespace http://tampermonkey.net/ // @version 0.1.1 // @description 自动翻页 只显示匿名 // @author You // @match *://allcp.net/forum.php?mod=viewthread&tid=* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; if (document.URL.length<60) { var url = document.URL + "&extra=&page=" var pageNext = 2; }else{ var url = document.URL var pageNext = parseInt(url.split("=").reverse()[0]) + 1 } // 初始化 // 1.1 添加点击的按钮 var btnRight = document.createElement("div"); btnRight.style.cssText = `position:fixed;bottom:140px;right:20px; padding:7px;width:40px;background:rgb(174,230,255); font:14px/1.5 '';color:#444;text-align:center;` btnRight.innerText = "点击显示匿名" document.body.appendChild(btnRight); //设置是否隐藏匿名 var onlyAnous = false; //1.2 原有评论处理 if (onlyAnous) { hiddenAnous(document.querySelectorAll("table.plhin")) } //2.1 当滚动时检测是否到底 document.onmousewheel = function (eve) { var e = eve || window.event; if (document.body.clientHeight < e.pageY + 2000) { newPage(pageNext); } } //2.2 获取下一页 function newPage(pageNext) { url = url.slice(0, url.lastIndexOf("=") + 1) + pageNext; var xhr = new XMLHttpRequest(); xhr.open("get", url, false); // 禁止异步执行 xhr.onreadystatechange = function () { console.log("xhr.ready", xhr.readyState, xhr.status) if (xhr.readyState == 4 && xhr.status == 200) { callback(xhr.responseText); } } xhr.send(""); } //2.3 处理下一页的response function callback(rsp) { var d = document.createElement("div"); d.innerHTML = rsp; var nextComment = d.querySelectorAll("table.plhin") var ele = document.createElement("div"); ele.style.cssText = "diaply:flex;justify-content:space-between;width:960px;margin:0 auto;" ele.innerHTML= `