// ==UserScript==
// @name 远景小助手
// @namespace http://tampermonkey.net/
// @version 11.0.0.2
// @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
// @downloadURL none
// ==/UserScript==
(function () {
"use strict";
const FINAL_VERSION = "13";
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 = `
${pluginName}
×
`;
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 + "次~
";
signCount++;
} else {
signLog.innerHTML +=
"出现错误,请手动操作
";
}
});
});
} 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 +=
"
";
});
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"));
try {
// eslint-disable-next-line
$("css_widthauto").disabled = true;
} catch (e) {}
let umPos = document.querySelector("#um div");
if (umPos != null) {
umPos.style = "right:0;position:absolute;top:-2px";
}
let hdTop = document.querySelector("#hd .wp");
if (hdTop != null) {
hdTop.style.marginTop = "40px";
}
let menu1 = document.querySelector(".appl .tbn");
if (menu1 != null) {
menu1.style.padding = "0 0 0 8px";
menu1.parentNode.style =
"transform:translateX(-7px);background-size:cover;margin:0px 0 0 20px;order:1";
} else {
let app1 = document.querySelector(".appl");
if (app1 != null) {
app1.style = "margin:0 0 0 0;background-size:cover;";
}
}
let topbar1 = document.querySelector("#scbar");
if (topbar1 != null) {
topbar1.style.width = "auto";
}
let diyPage = document.querySelector("#diypage");
let sdPtm = document.querySelector(".sd.ptm");
if (sdPtm != null) {
sdPtm.style.order = 4;
}
let tlist = document.querySelector("#threadlist");
if (tlist != null) {
tlist.style = "padding:0 0 0 20px;width:100%;box-sizing:border-box";
}
let content2 = document.querySelector("#ct");
if (content2 != null) {
content2.style =
"padding:32px 0 0 0;margin:0 auto;justify-content:center;";
if (
document.querySelector("#pgt") == null &&
document.querySelector("#postlist") == null
) {
content2.style.display = "flex";
}
let content1 = content2.querySelector(".mn");
if (content1 != null) {
content1.style =
"box-sizing:border-box;margin:0 -180px 0 0;padding: 0 190px 0 0;order:2;flex-grow:1";
}
}
let psd = document.querySelector("#psd");
if (psd != null) {
psd.style.order = 5;
}
let userPtm = document.querySelector(".mn.ptm");
if (userPtm != null) {
userPtm.style.paddingLeft = "20px";
}
if (diyPage != null) {
diyPage.style = "display:flex;justify-content:center";
diyPage.parent.style = "justily-content:center;";
}
let homePage = document.querySelector("#wp");
if (homePage != null && location.hostname == "www.pcbeta.com") {
homePage.style =
"display:flex;justify-content:center;flex-direction:column;";
}
} 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 = " 常用语模板";
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 =
"";
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(
"小主请三思,确定要拉黑 " + username + " 吗?",
"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(
"配置修改/拉黑用户需要刷新页面才会生效噢
如果置顶按钮找不到了,重新启用一下就能找到了
问题反馈/功能建议: 请在这里提交
",
"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 =
"检测到新版本,可前往更新";
}
});
})();