// ==UserScript== // @name 远景小助手 // @namespace http://tampermonkey.net/ // @version 26.0.0.0 // @description 远景论坛自定义小功能~ 优化你的访问体验,免受烦人的水帖子困扰。常用功能: 一键领取任务与奖励,快捷发言-自定义常用语,阅读回复免翻页,可选功能: 屏蔽指定用户的发言,隐藏等级 | 徽章 | 签名 | 默认黄色小老虎表情显示等。请优先使用篡改猴(Tampermonkey)加载此脚本(这是最后一版了,以后不再提供更新)。 // @supportURL https://lalaki.cn/rp // @homepage https://lalaki.cn // @author lalaki // @match https://*.pcbeta.com/* // @icon https://lalaki.cn/p/?i=pbi // @grant GM_setValue // @grant GM_getValue // @require https://fastly.jsdelivr.net/npm/moment@2.30.1/min/moment.min.js // @require https://fastly.jsdelivr.net/npm/moment@2.30.1/locale/zh-cn.js // @run-at document-body // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/513205/%E8%BF%9C%E6%99%AF%E5%B0%8F%E5%8A%A9%E6%89%8B.user.js // @updateURL https://update.greasyfork.icu/scripts/513205/%E8%BF%9C%E6%99%AF%E5%B0%8F%E5%8A%A9%E6%89%8B.meta.js // ==/UserScript== (function () { "use strict"; if (document.head == null) { return; } const FINAL_VERSION = "26"; const pluginName = "远景小助手"; const style = document.createElement("style"); const denyUsers = []; try { // eslint-disable-next-line moment.locale("zh-cn"); } catch (e) {} style.innerHTML = ` ::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; } ::-webkit-scrollbar-thumb { background: #1985db; border-radius: 3px; border-left:1px solid #eee; } ::-webkit-scrollbar-thumb:hover { background: #555; } .la-force-hidden{ display:none !important; visibility:hidden !important; } .la-custom-toolbar .la-p{ background:#018ed5; width:100%; text-align:center; padding:11px 0 11px 0; border-top:1px solid #eee; } .la-custom-toolbar{ width:0px; display:none; } .la-custom-toolbar-show{ display:flex; width: 100px; transition: width 0.1s ease; } .la-p a{ color:#f3f3f3 !important; } .la-p:hover{ background:#006ea6; } .la-a-cursor{ cursor:pointer; } .la-blue{ color:blue !important; } .la-green{ color:#6dff02 !important; } .la-bg-active{ background:#2ca10a; } .la-error{ color:#ffc107; } `; document.body.prepend(style); const ui = document.createElement("div"); ui.setAttribute("hidden", "hidden"); ui.style = "user-select:none;color:inherit;background-color:transparent;font-size:150%;position:fixed;left:0;top:0;z-index:2147483646"; document.body.append(ui); const shadow = ui.attachShadow({ mode: "open" }); const cont = document.createElement("div"); const h0 = "display:none"; function tryBlockUsers() { document.querySelectorAll(".quote").forEach((q) => { let qu = ("" + q.innerText).trim(); denyUsers.forEach((u) => { if (qu != "" && qu.startsWith(u)) { q.style = h0; } }); }); document.querySelectorAll("a").forEach((a) => { let parent = a; let patch = false; while (parent != null) { let username = ("" + a.innerHTML).trim(); if (username == "" || denyUsers.indexOf(username) == -1) { break; } let pid = ("" + parent.id).trim(); if ( pid.startsWith("post_") || pid.startsWith("stickthread_") || pid.startsWith("normalthread_") ) { parent.style = h0; break; } let pClass = ("" + parent.className).trim(); let nd = parent.nodeName.toLowerCase(); if ( pClass == "pbw" || pClass == "bw0_all" || nd == "tr" || nd == "li" ) { //处理特殊情况 parent.style = h0; break; } if ( pClass == "nts" || nd == "body" || pClass == "p_pop" || pClass == "y" ) { //保护节点 break; } let pc = 0; parent.querySelectorAll("a").forEach((pa) => { if (pa.href.indexOf(a.href) != -1) { pc++; } }); if (pc > 1) { parent.style = h0; patch = true; break; } parent = parent.parentNode; } if (patch) { //修复回复帖子 parent = a; while (parent != null) { let pid = ("" + parent.id).trim(); if ( pid.startsWith("post_") || pid.startsWith("stickthread_") || pid.startsWith("normalthread_") ) { parent.style = h0; break; } parent = parent.parentNode; } } }); } //UI界面布局 cont.innerHTML = `
问题反馈/功能建议: 请在这里提交
", "notice", "提示" ); }; if (isScrollTop) { let scrollTop = document.querySelector("#scrolltop"); if (scrollTop != null) { function scrollBtnFix() { let rect = scrollTop.getBoundingClientRect(); let st0 = rect.left + rect.width; let st1 = rect.top + rect.height; let mWidth = window.innerWidth; let mHeight = window.innerHeight; let sData = GM_getValue("sl", "UNSET"); let hasData = false; let sDataSplit = []; if (sData.indexOf(";") != -1) { sDataSplit = sData.split(";"); hasData = sDataSplit.length > 1; } if (st0 > mWidth) { scrollTop.style.left = mWidth - 1.5 * rect.width + "px"; } else if (hasData) { let saveLeft = parseInt(sDataSplit[0]) + rect.width; if (saveLeft < mWidth) { scrollTop.style.left = saveLeft - rect.width + "px"; } } if (st1 > mHeight) { scrollTop.style.top = mHeight - 1.5 * rect.height + "px"; } else if (hasData) { let saveTop = parseInt(sDataSplit[1]) + rect.height; if (saveTop < mHeight) { scrollTop.style.top = saveTop - rect.height + "px"; } } } window.addEventListener("scroll", scrollBtnFix); window.addEventListener("resize", scrollBtnFix); scrollTop.addEventListener("mousedown", (e) => { if (e.button === 0) { let rect0 = scrollTop.getBoundingClientRect(); offsetX = e.clientX - rect0.left; offsetY = e.clientY - rect0.top; document.addEventListener("mousemove", mouseMoveHandler); document.addEventListener("mouseup", mouseUpHandler); e.preventDefault(); } }); scrollTop.style.backgroundImage = "url('https://ps.w.org/scroll-top/assets/icon-128x128.png')"; scrollTop.style.backgroundSize = "contain"; scrollTop.style.borderRadius = "7px"; scrollTop.style.zIndex = 9999; function mouseMoveHandler(e) { let sLeft = `${e.clientX - offsetX}px`; let sTop = `${e.clientY - offsetY}px`; scrollTop.style.left = sLeft; scrollTop.style.top = sTop; scrollTop.style.cursor = "move"; GM_setValue("sl", sLeft + ";" + sTop); } let sData = GM_getValue("sl", "UNSET"); if (sData.indexOf(";") != -1) { let sDataSplit = sData.split(";"); if (sDataSplit.length > 1) { scrollTop.style.left = sDataSplit[0]; scrollTop.style.top = sDataSplit[1]; } } function mouseUpHandler() { scrollTop.style.cursor = "pointer"; document.removeEventListener("mousemove", mouseMoveHandler); document.removeEventListener("mouseup", mouseUpHandler); } } } cont.querySelectorAll(".custom_avas").forEach((ca) => { ca.onclick = (e0) => { let imgUri = e0.target.src; let url = GM_getValue("imgurls", "NUL"); if (e0.target.className.indexOf("la-bg-active") == -1) { e0.target.className += " la-bg-active"; if ((url + "").trim() == "" || url == "NUL") { GM_setValue("imgurls", imgUri); } else { GM_setValue("imgurls", url + ";" + imgUri); } } else { e0.target.classList.remove("la-bg-active"); if ((url + "").trim() == "" || url == "NUL") { return; } else { let newUri = url.replaceAll(imgUri, ""); GM_setValue("imgurls", newUri.replaceAll(";;", ";")); } } }; }); function createAddFrientDom(url) { let fastFriend = document.createElement("a"); fastFriend.innerHTML = "加好友"; fastFriend.style = "cursor:pointer;margin:0 0 0 16px"; fastFriend.onclick = () => { let result = new URLSearchParams(url); let uid = result.get("touid"); if (fastFriend.innerHTML != "等待通过") { fetch( "https://bbs.pcbeta.com/home.php?mod=spacecp&ac=friend&op=add&uid=" + uid, { method: "GET", credentials: "include", } ) .then(async (res) => ({ status: res.status, buffer: await res.arrayBuffer(), })) .then(({ status, buffer }) => { if (status == 200) { let decoder = new TextDecoder("gbk"); let html = decoder.decode(buffer); if (html.indexOf("不存在") == -1) { let dom = document.createElement("div"); dom.innerHTML = html; let addForm = dom.querySelector("#addform_" + uid); if (addForm != null) { let px = addForm.querySelector(".px"); if (px != null) { px.value = "Hello"; } if (addForm != null) { fetch(addForm.action, { method: "POST", body: new FormData(addForm), }) .then(async (res) => ({ status: res.status, buffer: await res.arrayBuffer(), })) .then(({ status, buffer }) => { if (status == 200) { fastFriend.innerHTML = "等待通过"; } else { alert("添加失败"); } }); } } else { let msg = dom.querySelector("#messagetext p"); if (msg != null) { alert(msg.innerHTML); } } } } }); } }; return fastFriend; } if (location.href.indexOf("viewthread") != -1) { document.querySelectorAll(".tip.aimg_tip").forEach((it)=>{it.className+=" la-force-hidden";}); document.querySelectorAll(".imicn a").forEach((it) => { let atext = (it.innerHTML + "").trim(); if (atext == "发消息") { it.after(createAddFrientDom(it.href)); } }); //回帖工具栏 const replyToolBar = document.createElement("div"); document.addEventListener("mousemove", (event) => { let mouseX = event.clientX; let mouseY = event.clientY; let screenWidth = window.innerWidth; if (mouseX >= screenWidth - 100) { replyToolBar.className = "la-custom-toolbar la-custom-toolbar-show"; } else { replyToolBar.className = "la-custom-toolbar"; } }); replyToolBar.className = "la-custom-toolbar"; replyToolBar.style = "position:fixed;right:0;background:#333;top:50%;height:0px;z-index:999;flex-direction:column;align-items:center;justify-content:center;color:#f4f4f4;font-size:15px;font-weight:300;user-select:none"; replyToolBar.innerHTML = ` `; document.body.append(replyToolBar); function getLaP() { let pa = document.createElement("div"); pa.className = "la-p"; return pa; } let mainItem = document.querySelector("#postlist table .pti"); if (mainItem != null) { mainItem.querySelectorAll("a").forEach((it) => { let pa = getLaP(); it.style.display = "block"; pa.append(it); replyToolBar.append(pa); }); mainItem.querySelectorAll(".pipe").forEach((it) => { it.style = "display:none"; }); ["前往首页", "前往尾页", "回复本贴", "↑", "↓"].forEach((it) => { let pa = getLaP(); pa.innerHTML = `${it}`; if (it == "↑") { replyToolBar.prepend(pa); } else { replyToolBar.append(pa); } pa.onclick = () => { switch (it) { case "前往首页": var rp = document.querySelector("#thread_subject"); if (rp != null) { rp.click(); } break; case "前往尾页": var lst = document.querySelector(".pg .nxt"); if (lst != null) { location.href = lst.previousSibling.href; } break; case "回复本贴": var crt = document.querySelector("#post_reply"); if (crt != null) { crt.click(); } break; case "↑": window.scrollTo({ top: 0, left: 0, behavior: "smooth" }); break; case "↓": window.scrollTo({ top: document.body.scrollHeight, left: 0, behavior: "smooth", }); break; } }; }); } } let fsDom = document.querySelector(".bm .mtm .bm_c"); if (fsDom != null) { fsDom.style.marginTop = "20px"; fsDom.style.display = "flex"; let fsInput = fsDom.querySelector(".px.vm"); if (fsInput != null) { fsInput.style.flexGrow = 1; fsInput.parentNode.style.display = "contents"; fsInput.style.marginRight = "5px"; } } if (autoPgs && location.href.indexOf("viewthread") != -1) { if (document.title.indexOf("打卡专用") != -1) { try { // eslint-disable-next-line let hour = parseInt(moment().format("HH")); if (hour != 3 && hour != 4 && hour != 5) { let rp = document.querySelector("#post_reply"); if (rp != null) { rp.click(); } } else { // eslint-disable-next-line let latime = moment().format("LT"); // eslint-disable-next-line showDialog( `当前时间 ${latime},还没签到时间噢!