Greasy Fork

Greasy Fork is available in English.

远景小助手

远景论坛自定义小功能~,常用功能: 一键领取任务与奖励,自定义常用语,屏蔽指定用户的发言,隐藏等级 | 徽章 | 默认黄色小老虎表情显示等。

目前为 2024-10-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         远景小助手
// @namespace    http://tampermonkey.net/
// @version      11.0.0.1
// @description  远景论坛自定义小功能~,常用功能: 一键领取任务与奖励,自定义常用语,屏蔽指定用户的发言,隐藏等级 | 徽章 | 默认黄色小老虎表情显示等。
// @homepage     https://lalaki.cn
// @author       lalaki
// @match        https://*.pcbeta.com/*
// @icon         https://lalaki.cn/p/?i=pbi
// @grant        GM_setValue
// @grant        GM_getValue
// @license      MIT
// ==/UserScript==

(function () {
	"use strict";
	const FINAL_VERSION = "12";
	const pluginName = "远景小助手";
	const style = document.createElement("style");
	style.textContent = `
  `;
	document.head.appendChild(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:2147483647";
	document.body.append(ui);
	const shadow = ui.attachShadow({ mode: "open" });
	const cont = document.createElement("div");
	//UI界面布局
	cont.innerHTML = `
<style>
    .la-bg {
        font-family: "Segoe UI", Arial, sans-serif;
        margin: 6px auto auto 6px;
        background: #fff;
        width: 290px;
        height: 374px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        border-radius: 10px;
        position: absolute;
    }

    .la-close {
        position: absolute;
        padding: 6px 6px 6px 8px;
        right: 0;
        top: 0;
        border-top-right-radius: 10px;
        font-size: 22px;
        font-family: monospace;
        cursor: pointer;
        color: #333;
    }

    .la-close:hover {
        background: #ff5757;
        color: #fff;
    }

    .la-title-bar {
        position: absolute;
        display: flex;
        width: 100%;
        padding: 7px 0 5px 7px;
        flex-wrap: wrap;
        user-select: none;
    }

    .la-title {
        font-size: 15px;
        display: inline;
        padding: 0 0 0 7px;
        color: #333;
    }

    .la-hr {
        height: 1px;
        background: #efefef;
        width: 100%;
        position: relative;
        margin: 6px 0 0 0;
        transform: translateX(-7px);
    }

    .la-drag-border {
        width: 290px;
        height: 374px;
        border: 2px solid #000;
        position: fixed;
        z-index:99999;
    }

    .la-main {
        position: absolute;
        top: 40px;
        height: 326px;
        width: 282px;
        display: flex;
        align-items: center;
        margin: 0 0 0 3px;
        border-radius: 2px;
        color:#333;
    }

    .la-li:hover {
        background: #ececec;
    }

    .la-li {
        padding: 7px 0 7px 10px;
        border: 1px solid #ececec;
        border-radius: 3px;
        align-items: center;
        display: flex;
        margin: 4px auto;
    }

    .la-icon {
        transform: scaleX(1.88);
        position: absolute;
        display: inline-block;
        right: 20px;
        font-size: 14px;
        pointer-events:none;
    }

    ul {
        list-style-type: none;
        width: 100%;
        padding: 0 0 0 2px;
        margin: 0;
        height: 100%;
        overflow: auto;
        position: absolute;
        top: 0;
    }

    .switch {
        position: relative;
        display: inline-block;
        width: 39px;
        height: 23px;
    }

    .switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #ccc;
        -webkit-transition: .4s;
        transition: .4s;
    }

    .slider:before {
        position: absolute;
        content: "";
        height: 15px;
        width: 15px;
        left: 4px;
        bottom: 4px;
        background-color: white;
        -webkit-transition: .4s;
        transition: .4s;
    }

    input:checked+.slider {
        background-color: #2196F3;
    }

    input:focus+.slider {
        box-shadow: 0 0 1px #2196F3;
    }

    input:checked+.slider:before {
        -webkit-transform: translateX(15px);
        -ms-transform: translateX(15px);
        transform: translateX(15px);
    }

    .slider.round {
        border-radius: 34px;
    }

    .slider.round:before {
        border-radius: 50%;
    }

    .la-switch {
        position: absolute;
        right: 10px;
    }

    .la-li-item {
        text-indent: 10px;
        display: none;
    }

    #all_ava:hover{
        background:#fff !important;
    }

    #all_ava{
        flex-wrap:wrap;
        justify-content:space-around;
    }

    #all_ava img{
        margin:5px auto;
    }
</style>
<div draggable="false" class="la-bg">
    <div class="la-title-bar"><img alt="close" draggable="false"
            src="https://lalaki.cn/p/?i=pbi">
        <div class="la-title">${pluginName}</div>
        <div class="la-hr"></div>
    </div>
    <div class="la-close">×</div>
    <div class="la-drag-border" hidden="hidden"></div>
    <div class="la-main">
        <ul>
            <li>
                <div class="la-li" id="custom">个性化<div class="la-icon">∨</div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">不显示用户资料
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="uinfo">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">不显示用户等级
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="lv">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">不显示用户徽章
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="ava">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">不显示用户签名
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="usign">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">不显示IP属地
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="ip">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">不显示默认表情
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="exp">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
           <li>
                <div class="la-li la-li-item la-li-item1">内容铺满全屏
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="afull">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">WordPress置顶按钮
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="astui">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">隐藏底部的“版权所有”
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="lacopy">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">兼容性
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="alegacy">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item1">为自己佩戴勋章
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="aforme">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li style="display:none">
                <div class="la-li la-li-item la-li-item1" id="all_ava"></div>
            </li>
            <li>
                <div class="la-li" id="fast_msg">快捷发言<div class="la-icon">∨</div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item2">功能总开关
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="fast_msg_01">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
            <li id="fast_msg_data" hidden="hidden">
                <div class="la-li la-li-item la-li-item2">
                  <textarea style="height: 106px;width: 249px;"></textarea>
                </div>
            </li>
            <li>
                <div class="la-li" id="block_users">黑名单<div class="la-icon">∨</div>
                </div>
            </li>
            <li>
                <div class="la-li la-li-item la-li-item3">功能总开关
                    <div class="la-switch">
                        <label class="switch">
                            <input type="checkbox" id="block_users_01">
                            <span class="slider round"></span>
                        </label>
                    </div>
                </div>
            </li>
             <li id="block_users_data" hidden="hidden">
                <div class="la-li la-li-item la-li-item3">
                  <textarea style="height: 106px;width: 249px;"></textarea>
                </div>
            </li>
             <li style="padding:0 0 0 0">
                <div class="la-li la-li-item" id="la_help" style="display:flex;text-indent:0px;padding:7px 0 7px 0px;justify-content:center;">
               使用帮助
                </div>
            </li>
            <li id="update_tips" style="padding:0 0 0 0" hidden="hidden">
                <div class="la-li la-li-item la-li-item4">
               立即更新
                </div>
            </li>
        </ul>
    </div>
</div>
    `;
	shadow.append(cont);
	const titleBar = cont.querySelector(".la-title-bar");
	cont.querySelector(".la-close").onclick = () => {
		ui.setAttribute("hidden", "hidden");
	};
	let offsetX, offsetY;
	const dragBorder = cont.querySelector(".la-drag-border");
	titleBar.addEventListener("mousedown", (e) => {
		if (e.button != 0) {
			return;
		}
		dragBorder.removeAttribute("hidden");
		offsetX = e.clientX - cont.getBoundingClientRect().left;
		offsetY = e.clientY - cont.getBoundingClientRect().top;
		document.addEventListener("mousemove", laMouseMoveHandler);
		document.addEventListener("mouseup", laMouseUpHandler);
	});
	function laMouseMoveHandler(e) {
		dragBorder.style.left = `${e.clientX - offsetX}px`;
		dragBorder.style.top = `${e.clientY - offsetY}px`;
	}
	function laMouseUpHandler() {
		document.removeEventListener("mousemove", laMouseMoveHandler);
		document.removeEventListener("mouseup", laMouseUpHandler);
		let left = dragBorder.style.left;
		let top = dragBorder.style.top;
		if ((left + top + "").trim() != "") {
			ui.style.left = left;
			ui.style.top = top;
		}
		dragBorder.setAttribute("hidden", "hidden");
	}
	//添加到顶部菜单
	const shortcut = document.createElement("a");
	shortcut.innerHTML = pluginName;
	shortcut.style = "cursor:pointer;user-select:none";
	shortcut.onclick = () => {
		if (ui.hasAttribute("hidden")) {
			ui.removeAttribute("hidden");
		} else {
			ui.setAttribute("hidden", "hidden");
		}
	};
	const toplinks = document.querySelectorAll("#toptb a");
	for (let i = 0; i < toplinks.length; i++) {
		let menuText = toplinks[i]?.innerHTML + "";
		if (["马甲", "快捷导航", "返回首页"].indexOf(menuText) != -1) {
			toplinks[i].before(shortcut);
			if (menuText.indexOf("马甲") != -1) {
				toplinks[i].style = "display:none";
			}
			break;
		} else if (menuText == "登录") {
			let tmp = document.createElement("li");
			tmp.style = "width:auto";
			tmp.append(shortcut);
			toplinks[i].parentNode.before(tmp);
			tmp.parentNode.style = "width:auto";
			shortcut.style =
				"width:auto;padding:0 0 0 5px;cursor:pointer;user-select:none";
			break;
		}
	}
	if (location.host == "i.pcbeta.com") {
		let signShortcut = document.createElement("a");
		signShortcut.innerHTML = "一键领任务与奖励";
		signShortcut.style = "cursor:pointer;position: relative;user-select:none";
		signShortcut.onclick = (e3) => {
			//一键领取任务与奖励~
			let signDom = e3.target;
			if (signDom.children.length > 0) {
				return;
			}
			let signLog = document.createElement("div");
			signLog.style =
				"position:absolute;width:auto;height:auto;color:#fff;left:0;";
			signLog.onclick = () => {
				signDom.removeChild(signLog);
			};
			signDom.append(signLog);
			let dataCount = 0;
			let arr = [];
			[
				"https://i.pcbeta.com/home.php?mod=task&item=new",
				"https://i.pcbeta.com/home.php?mod=task&item=doing",
			].forEach((it) => {
				fetch(it, { method: "GET", credentials: "include" })
					.then(async (res) => ({
						status: res.status,
						buffer: await res.arrayBuffer(),
					}))
					.then(({ status, buffer }) => {
						if (status == 200) {
							let signCount = 1;
							let decoder = new TextDecoder("gbk");
							let text = decoder.decode(buffer);
							let dom = document.createElement("div");
							dom.innerHTML = text;
							dom.querySelectorAll("a").forEach((it) => {
								let href = (it.getAttribute("href") + "").trim();
								if (href.indexOf("id=") != -1 && href.indexOf("task") != -1) {
									arr.push(href);
								}
							});
							if (arr.length > 0) {
								arr.forEach((it) => {
									fetch(it, { method: "GET", credentials: "include" })
										.then(async (res) => ({
											status: res.status,
											body: await res.text(),
										}))
										.then(({ status, body }) => {
											if (status == 200) {
												signLog.innerHTML += "成功了" + signCount + "次~<br>";
												signCount++;
											} else {
												signLog.innerHTML +=
													"<b style='color:#ffc107'>出现错误,请手动操作</b><br>";
											}
										});
								});
							} else {
								if (dataCount > 0) {
									signLog.innerHTML = "没有任务了~全都做完了。";
								}
								dataCount++;
							}
						}
					});
			});
		};
		shortcut.after(signShortcut);
	}
	const items = cont.querySelectorAll(".la-li-item1");
	const items2 = cont.querySelectorAll(".la-li-item2");
	const items3 = cont.querySelectorAll(".la-li-item3");
	const menus = cont.querySelectorAll(".la-li");
	menus.forEach((it) => {
		it.addEventListener("click", (e) => {
			const icon = e.target.querySelector(".la-icon");
			switch (("" + e.target.id).trim()) {
				case "custom":
					for (let i = 0; i < items.length; i++) {
						let menuShown = ("" + items[i].style.display).trim();
						if (menuShown.indexOf("flex") != -1) {
							items[i].style = "display:none";
							icon.style = "transform:scaleX(1.88)";
						} else {
							items[i].style = "display:flex";
							icon.style = "transform:scaleX(1.88) rotate(180deg);";
						}
					}
					break;
				case "fast_msg":
					for (let i = 0; i < items2.length; i++) {
						let menuShown = ("" + items2[i].style.display).trim();
						if (menuShown.indexOf("flex") != -1) {
							items2[i].style = "display:none";
							icon.style = "transform:scaleX(1.88)";
						} else {
							items2[i].style = "display:flex";
							icon.style = "transform:scaleX(1.88) rotate(180deg);";
						}
					}
					break;
				case "block_users":
					for (let i = 0; i < items3.length; i++) {
						let menuShown = ("" + items3[i].style.display).trim();
						if (menuShown.indexOf("flex") != -1) {
							items3[i].style = "display:none";
							icon.style = "transform:scaleX(1.88)";
						} else {
							items3[i].style = "display:flex";
							icon.style = "transform:scaleX(1.88) rotate(180deg);";
						}
					}
					break;
			}
		});
	});
	//载入配置
	let hideDetails = GM_getValue("dts", "false") == true;
	let hideStar = GM_getValue("star", "false") == true;
	let hideAva = GM_getValue("ava", "false") == true;
	let hideSign = GM_getValue("hsg", "false") == true;
	let hideIp = GM_getValue("hip", "false") == true;
	let hideExp = GM_getValue("exp", "false") == true;
	let hideAvas = GM_getValue("avas", "false") == true;
	let showFull = GM_getValue("full", "false") == true;
	let showFastMsg = GM_getValue("fm", "false") == true;
	let showBlockUsers = GM_getValue("bu", "false") == true;
	let isLegacy = GM_getValue("lga", "false") == true;
	let isScrollTop = GM_getValue("stui", "false") == true;
	let isHideCopy = GM_getValue("lacopy", "false") == true;
	let legacy = cont.querySelector("#alegacy");
	legacy.checked = isLegacy;
	let fastMsgUI = cont.querySelector("#fast_msg_data");
	let blockui = cont.querySelector("#block_users_data");
	let fastMsgText = cont.querySelector("#fast_msg_data textarea");
	let blockUsersText = cont.querySelector("#block_users_data textarea");
	let meDom = document.querySelector(".vwmy a");
	let me = "";
	if (meDom != null) {
		me = (meDom.innerHTML + "").trim();
		meDom.href = "https://i.pcbeta.com";
	}
	let denyUsers = [];
	let avas = [
		"https://i.pcbeta.com/static/image/common/medal_201209/zscj.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/yxbz.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/xcs.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/ycxf.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/rxhy.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/jdz.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/hdzz.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/cyxf.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/jydr.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/ryhy.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/yjsf.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/yxbs.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/nmxx.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/mhdr.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/kfdr.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/jsdr.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/jzt.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/byg.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/yxdr.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/xbs.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/xbs2.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/pcdr.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/tsgx.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/ss.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/rich.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/7.png",
		"https://i.pcbeta.com/static/image/common/medal_iety.png",
		"https://i.pcbeta.com/static/image/common/medal_surface1.png",
		"https://i.pcbeta.com/static/image/common/medal_movies.png",
		"https://i.pcbeta.com/static/image/common/medal_appx.png",
		"https://i.pcbeta.com/static/image/common/medal_zdx.png",
		"https://i.pcbeta.com/static/image/common/medal_book.png",
		"https://i.pcbeta.com/static/image/common/medal_8th.png",
		"https://i.pcbeta.com/static/image/common/medal_smdr.png",
		"https://i.pcbeta.com/static/image/common/medal_dianzan.png",
		"https://i.pcbeta.com/static/image/common/medal_windowsphone.png",
		"https://i.pcbeta.com/static/image/common/medal_worldcup.png",
		"https://i.pcbeta.com/static/image/common/medal_daxuesheng.png",
		"https://i.pcbeta.com/static/image/common/medal_9a.png",
		"https://i.pcbeta.com/static/image/common/Win_10_forerunner.png",
		"https://i.pcbeta.com/static/image/common/10.png",
		"https://i.pcbeta.com/static/image/common/medal_201209/medal_11th.png",
	];
	let allIMG = "";
	let sUrl = GM_getValue("imgurls", "NUL");
	avas.forEach((avai) => {
		let showBG = sUrl.indexOf(avai) != -1;
		allIMG +=
			"<img class='custom_avas' src=" +
			avai +
			" style=" +
			(showBG ? "background:#2ca10a" : "") +
			">";
	});
	let avaUI = cont.querySelector("#all_ava");
	avaUI.innerHTML = allIMG;
	cont.querySelectorAll(".la-li input").forEach((it) => {
		let cid = ("" + it.id).trim();
		if (hideDetails && cid == "uinfo") {
			//隐藏用户详情
			it.checked = hideDetails;
			document.querySelectorAll(".pil.cl")?.forEach((dt) => {
				dt.style = "display:none";
			});
		} else if (hideStar && cid == "lv") {
			it.checked = hideStar;
			document
				.querySelectorAll(".avatar_p")
				.forEach((a) => (a.style = "display:none"));
			document.querySelectorAll("p").forEach((st) => {
				if (("" + st.id).startsWith("g_up")) {
					st.style = "display:none";
				}
			});
			document.querySelectorAll(".pls p img").forEach((it) => {
				it.style = "display:none";
			});
		} else if (hideAva && cid == "ava") {
			it.checked = hideAva;
			document
				.querySelectorAll(".md_ctrl")
				.forEach((a) => (a.style = "display:none"));
		} else if (hideSign && cid == "usign") {
			it.checked = hideSign;
			document.querySelectorAll(".sign")?.forEach((sg) => {
				sg.style = "display:none";
			});
		} else if (hideIp && cid == "ip") {
			it.checked = hideIp;
			document.querySelectorAll("span").forEach((aa) => {
				if ((aa.innerHTML + "").trim().startsWith("IP属地")) {
					aa.style = "display:none";
				}
			});
		} else if (isHideCopy && cid == "lacopy") {
			it.checked = isHideCopy;
			let copy1 = document.querySelector(".ftbg");
			if (copy1 != null) {
				copy1.style.display = "none";
			}
		} else if (isScrollTop && cid == "astui") {
			it.checked = isScrollTop;
		} else if (hideExp && cid == "exp") {
			it.checked = hideExp;
			document.querySelectorAll("img").forEach((i) => {
				if (
					("" + i.src).startsWith("https://bbs.pcbeta.com/static/image/smiley")
				) {
					i.style = "display:none";
				}
			});
		} else if (hideAvas && cid == "aforme") {
			it.checked = hideAvas;
			let bava = document.createElement("p");
			bava.className = "md_ctrl";
			let myUrl = sUrl.split(";");
			myUrl.forEach((s0) => {
				let s0u = (s0 + "").trim();
				if (s0u != "") {
					let avico = document.createElement("img");
					avico.src = s0u;
					bava.append(avico);
				}
			});
			avaUI.parentNode.style = "display:block";
			document.querySelectorAll(".pil.cl").forEach((ckme) => {
				let dom0 = ckme.parentNode.querySelector(".authi a");
				if (dom0 != null) {
					let ifMe = dom0.innerHTML.trim();
					if (ifMe == me && me != "") {
						ckme.after(bava.cloneNode(true));
					}
				}
			});
		} else if (showFull && cid == "afull") {
			it.checked = showFull;
			// eslint-disable-next-line
			widthauto(document.createElement("div"));
			let menu1 = document.querySelector(".appl");
			if (menu1 != null) {
				menu1.style.padding = "0 0 0 8px";
			}
			let topbar1 = document.querySelector("#scbar");
			if (topbar1 != null) {
				topbar1.style.width = "auto";
			}
			let content2 = document.querySelector("#ct");
			if (content2 != null) {
				content2.style.paddingRight = "24px";
				let content1 = content2.querySelector(".mn");
				if (content1 != null) {
					content1.style.marginRight = "-10px";
				}
			}
			try {
				// eslint-disable-next-line
				$("css_widthauto").disabled = true;
			} catch (e) {}
		} else if (showFastMsg && cid == "fast_msg_01") {
			it.checked = showFastMsg;
			let fastMsgList = GM_getValue("fastMsgs", "UNSET");
			if (fastMsgList.trim() != "" && fastMsgList != "UNSET") {
				fastMsgText.value = fastMsgList;
				//快捷发言UI
				let faster = document.createElement("span");
				let append = document.querySelector("#append_parent");
				if (legacy.checked) {
					setInterval(() => {
						let r1 = document.querySelector("#fwin_content_reply .fpd");
						if (r1 == null) {
							r1 = document.querySelector(".bar");
						}
						if (r1 != null) {
							r1.append(faster);
						}
					}, 500);
				}
				if (append != null) {
					const observer = new MutationObserver((mutationsList) => {
						for (let mutation of mutationsList) {
							if (
								mutation.type == "childList" &&
								document.querySelector(".area textarea") != null
							) {
								setTimeout(() => {
									let r1 = document.querySelector("#fwin_content_reply .fpd");
									if (r1 == null) {
										r1 = document.querySelector(".bar");
									}
									if (r1 != null) {
										r1.append(faster);
									}
								}, 500);
							}
						}
					});
					observer.observe(append, {
						childList: true,
					});
				}
				faster.innerHTML = "&nbsp;&nbsp;常用语模板";
				faster.style =
					"position:absolute;cursor:pointer;user-select:none;z-index:200";
				faster.onclick = () => {
					let fasterUIGet = faster.parentNode.querySelector("ul");
					if (fasterUIGet != null) {
						if (fasterUIGet.style.display == "block") {
							fasterUIGet.style.display = "none";
						} else {
							fasterUIGet.style.display = "block";
						}
						return;
					}
					let fasterListUI = document.createElement("ul");
					fasterListUI.style =
						"left:" +
						faster.offsetLeft +
						"px;min-width:100px;border-radius:7px;z-index:99999;user-select:none;padding:4px;margin-top:26px;position:absolute;background:#fff;box-shadow:-5px 5px 10px rgba(0, 0, 0, 0.1),5px 5px 10px rgba(0, 0, 0, 0.1),0 5px 10px rgba(0, 0, 0, 0.1);";
					let fastMsgs1 = (fastMsgText.value + "").trim();
					if (fastMsgs1 != "") {
						fasterListUI.innerHTML =
							"<style>.my-hover:hover{color:red;}</style>";
						fastMsgs1.split("\n").forEach((fm) => {
							let fasterListItem = document.createElement("li");
							fasterListItem.innerHTML = fm;
							fasterListItem.className = "my-hover";
							fasterListItem.style =
								"cursor:pointer;font-size:16px;border-bottom:1px solid #ececec;padding: 2px 7px 2px 7px;";
							fasterListItem.onclick = () => {
								let editContent = document.querySelector(".area textarea");
								let editNb = editContent.nextElementSibling;
								if (
									editContent == null ||
									(editNb != null && editNb.nodeName.toLowerCase() == "iframe")
								) {
									try {
										document
											.querySelector("iframe")
											.contentDocument.querySelector("body").innerHTML =
											fasterListItem.innerHTML;
									} catch (e) {
										// eslint-disable-next-line
										showDialog("当前页面不支持常用语");
									}
								}
								if (editContent != null) {
									document.querySelector(".area textarea").value =
										fasterListItem.innerHTML;
								}
								fasterListUI.style.display = "none";
							};
							fasterListUI.append(fasterListItem);
						});
						faster.after(fasterListUI);
					}
				};
			}
			fastMsgUI.removeAttribute("hidden");
			fastMsgUI.addEventListener("input", function (ev) {
				let value0 = ("" + ev.target.value).trim();
				GM_setValue("fastMsgs", value0);
			});
		} else if (showBlockUsers && cid == "block_users_01") {
			it.checked = showBlockUsers;
			let denyList = GM_getValue("denyUsers", "UNSET");
			if (denyList.trim() != "" && denyList != "UNSET") {
				blockUsersText.value = denyList;
				denyUsers = denyList
					.trim()
					.split("\n")
					.map((it) => it.trim());
			}
			blockui.removeAttribute("hidden");
			blockUsersText.addEventListener("input", function (ev) {
				let value0 = ("" + ev.target.value).trim();
				GM_setValue("denyUsers", value0);
			});
			document.querySelector("#postlist")?.childNodes.forEach((p) => {
				//在用户名后面添加拉黑按钮
				let pid = p.id;
				if (("" + pid).startsWith("post_")) {
					let user = document.querySelector("#" + pid + " .authi a");
					let username = ("" + user.innerHTML).trim();
					if (username != "" && denyUsers.indexOf(username) != -1) {
						p.style = "display:none";
					}
					let parent = user.parentNode;
					let block = document.createElement("a");
					block.innerHTML = "拉黑Ta";
					block.style = "float:right;cursor:pointer";
					block.onclick = () => {
						if (block.innerHTML == "已拉黑") {
							return;
						}
						// eslint-disable-next-line
						showDialog(
							"小主请三思,确定要拉黑 <b>" + username + "</b> 吗?",
							"confirm",
							"询问",
							() => {
								blockUsersText.value = blockUsersText.value + "\n" + username;
								block.innerHTML = "已拉黑";
								blockUsersText.dispatchEvent(
									new Event("input", { bubbles: true })
								);
							}
						);
					};
					if (me != username) {
						parent.append(block);
					}
				}
			});
			if (denyUsers.length > 0) {
				const h0 = "display:none";
				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;
						}
					}
				});
			}
		}
		it.addEventListener("change", (e) => {
			let isChecked = e.target.checked;
			switch (e.target.id) {
				case "uinfo":
					GM_setValue("dts", isChecked);
					break;
				case "lv":
					GM_setValue("star", isChecked);
					break;
				case "ava":
					GM_setValue("ava", isChecked);
					break;
				case "usign":
					GM_setValue("hsg", isChecked);
					break;
				case "ip":
					GM_setValue("hip", isChecked);
					break;
				case "exp":
					GM_setValue("exp", isChecked);
					break;
				case "aforme":
					GM_setValue("avas", isChecked);
					avaUI.parentNode.style = isChecked ? "display:block" : "display:none";
					break;
				case "alegacy":
					GM_setValue("lga", isChecked);
					break;
				case "lacopy":
					GM_setValue("lacopy", isChecked);
					break;
				case "astui":
					GM_setValue("stui", isChecked);
					if (!isChecked) {
						GM_setValue("sl", "NUL");
					}
					break;
				case "afull":
					GM_setValue("full", isChecked);
					// eslint-disable-next-line
					widthauto(document.createElement("div"));
					try {
						// eslint-disable-next-line
						$("css_widthauto").disabled = !isChecked;
					} catch (e) {}
					break;
				case "fast_msg_01":
					GM_setValue("fm", isChecked);
					if (!isChecked) {
						fastMsgUI.setAttribute("hidden", "hidden");
					} else {
						//加载快捷发言
						let fastMsgList = GM_getValue("fastMsgs", "UNSET");
						if (fastMsgList.trim() != "" && fastMsgList != "UNSET") {
							fastMsgText.value = fastMsgList;
						}
						fastMsgUI.removeAttribute("hidden");
					}
					break;
				case "block_users_01":
					GM_setValue("bu", isChecked);
					if (!isChecked) {
						blockui.setAttribute("hidden", "hidden");
					} else {
						//加载拉黑用户
						let denyList = GM_getValue("denyUsers", "UNSET");
						if (denyList.trim() != "" && denyList != "UNSET") {
							blockUsersText.value = denyList;
						}
						blockui.removeAttribute("hidden");
					}
					break;
			}
		});
	});
	cont.querySelector("#la_help").onclick = () => {
		// eslint-disable-next-line
		showDialog(
			"配置修改/拉黑用户需要刷新页面才会生效噢<br><br>如果置顶按钮找不到了,重新启用一下就能找到了<br><br><p>问题反馈/功能建议: <a style='color:blue' target='_blank' href='https://lalaki.cn/rp/'>请在这里提交</a></p>",
			"notice",
			"提示"
		);
	};
	if (isScrollTop) {
		let scrollTop = document.querySelector("#scrolltop");
		if (scrollTop != null) {
			window.onresize = () => {
				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";
					}
				}
			};
			scrollTop.addEventListener("mousedown", (e) => {
				if (e.button === 0) {
					offsetX = e.clientX - scrollTop.getBoundingClientRect().left;
					offsetY = e.clientY - scrollTop.getBoundingClientRect().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.style.background + "").trim() == "") {
				e0.target.style = "background:#2ca10a";
				if ((url + "").trim() == "" || url == "NUL") {
					GM_setValue("imgurls", imgUri);
				} else {
					GM_setValue("imgurls", url + ";" + imgUri);
				}
			} else {
				e0.target.style = "";
				if ((url + "").trim() == "" || url == "NUL") {
					return;
				} else {
					let newUri = url.replaceAll(imgUri, "");
					GM_setValue("imgurls", newUri.replaceAll(";;", ";"));
				}
			}
		};
	});
	cont.querySelector("#update_tips").removeAttribute("hidden");
	let vers = cont.querySelector(".la-li-item4");
	vers.style =
		"display:flex;justify-content:center;text-indent:0px;padding:7px 0 7px 0;";
	vers.innerHTML = "版本号: v" + FINAL_VERSION;
	fetch("https://lalaki.cn/up/")
		.then(async (res) => ({
			status: res.status,
			body: await res.text(),
		}))
		.then(({ status, body }) => {
			if (status == 200 && body != FINAL_VERSION) {
				vers.innerHTML =
					"检测到新版本,可<a href='https://lalaki.cn/pb' target='_blank'>前往更新</a>";
			}
		});
})();