// ==UserScript== // @name 远景小助手 // @namespace http://tampermonkey.net/ // @version 23.0.0.0 // @description 远景论坛自定义小功能~ 优化你的访问体验。常用功能: 一键领取任务与奖励,快捷发言-自定义常用语,阅读回复免翻页,可选功能: 屏蔽指定用户的发言,隐藏等级 | 徽章 | 签名 | 默认黄色小老虎表情显示等。 // @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 none // ==/UserScript== (function () { "use strict"; if (document.head == null) { return; } const FINAL_VERSION = "23"; const pluginName = "远景小助手"; const style = document.createElement("style"); const denyUsers = []; try { // eslint-disable-next-line moment.locale("zh-cn"); } catch (e) {} style.innerHTML = ` .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(".imicn a").forEach((it) => { let atext = (it.innerHTML + "").trim(); if (atext == "发消息") { it.after(createAddFrientDom(it.href)); } }); } 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 showDialog( "当前时间 " + moment().format("LT") + ",还没签到时间噢!