// ==UserScript== // @name MT论坛 // @namespace http://tampermonkey.net/ // @description MT论坛效果增强,如自动签到、自动展开帖子、滚动加载评论、显示uid、屏蔽用户、手机版小黑屋、编辑器优化等 // @version 2.5.5.6 // @author WhiteSevs // @icon https://bbs.binmt.cc/favicon.ico // @match *://bbs.binmt.cc/* // @compatible edge Beta/Dev/Candy 测试通过 // @compatible Yandex 测试通过 // @compatible Kiwi 测试通过 // @license GPL-3.0-only // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @grant unsafeWindow // @run-at document-start // @supportURL https://github.com/893177236/Monkey_script // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.4.1/jquery.min.js // @require https://unpkg.com/any-touch/dist/any-touch.umd.min.js // @require https://greasyfork.org/scripts/449471-viewer/code/Viewer.js?version=1081056 // @require https://greasyfork.org/scripts/449512-xtiper/code/Xtiper.js?version=1081249 // @require https://greasyfork.org/scripts/449562-nzmsgbox/code/NZMsgBox.js?version=1082044 // @downloadURL none // ==/UserScript== (function () { 'use strict'; const log = { success: (str) => { console.log("%c" + str, "color: #00a5ff"); }, error: (str) => { console.trace("%c" + str, "color: #f20000"); } } function tryCatch(func, params, errorFunc) { /* 捕获错误 */ let ret = null; try { if (typeof func == "string") { ret = window.eval(func); } else { if (params == null) { ret = func(); } else { ret = func(params); } } } catch (error) { console.log("%c" + (func.name ? func.name : func + "出现错误"), "color: #f20000"); console.log("%c" + ("错误原因:" + error), "color: #f20000"); console.trace(func); window.eval(errorFunc); } finally { return ret; } } const popup2 = { /* 自定义新的popup */ config: { mask: { zIndex: 1000000, style: `#force-mask{ width: 100%; height: 100%; position: fixed; top: 0px; left: 0px; background: black; opacity: 0.6; z-index: 1000000; display: flex; align-content: center; justify-content: center; align-items: center; }`, }, confirm: { zIndex: 1000100, style: ` #popup2-confirm .popup2-confirm-cancel, #popup2-confirm .popup2-confirm-ok{ user-select: none }`, }, toast: { zIndex: 1100000, style: `.popup2-toast{ width: fit-content; padding: 10px 16px; color: #fff; background: rgba(0,0,0,0.65); position: fixed; margin: 0 auto; left: 0; right: 0; bottom: 0; border-radius: 4px; font-size: 14px; z-index: 1100000; max-width: 80vw; opacity: 1; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; -webkit-backface-visibility: hidden; -webkit-font-smoothing: antialiased/subpixel-antialiased; touch-action: pan-y; -webkit-user-select: none; transform: translateY(160px); } .popup2-toast-show{ transform: translateY(-80px) !important; transition: all 0.2s ease 0s; -webkit-transition: all 0.2s ease 0s; }`, } }, init: () => { Object.keys(popup2.config).forEach(function (key) { let style = popup2.config[key].style; if (style != "") { GM_addStyle(style); } }) }, force_mask_init: function () { document.documentElement.style.overflow = 'hidden'; if (!$jq("#force-mask").length) { $jq('body').append($jq('
' + user_level + '<\/a><\/p>Lv'; user_info.appendChild(user_level_node); } }, } const mobile = { autoExpendFullTextByForumPost() { /* 自动展开帖子内容 */ if (GM_getValue("v18") && location.href.match(mt_config.rexp.forum_post)) { GM_addStyle(` div.comiis_message.bg_f.view_one.b_b.cl.message > div.comiis_messages.comiis_aimg_show.cl{ max-height: inherit !important; overflow-y: inherit !important; position: inherit !important; } .comiis_lookfulltext_key, .comiis_lookfulltext_bg{ display: none !important; }`) } }, autoSignIn() { /* 签到 */ utils.cookie(); function checkLogin() { /* 检测是否登录 */ let pc_login = document.querySelector("#comiis_key"); let mobile_login_cookie = Cookies.get("cQWy_2132_auth"); console.log("账号cQWy_2132_auth: ",mobile_login_cookie ? (mobile_login_cookie.slice(0,5)+"...") : mobile_login_cookie ); return pc_login || mobile_login_cookie; } function getFormHash() { /* 获取账号的formhash */ let inputFormHash = top.document.querySelector("input[name=formhash]"); let sidenv_exit = top.document.querySelector("div[class=sidenv_exit]>a"); /* 退出按钮(登录状态才有),电脑版的 */ let sidenv_exit_match = null; let comiis_recommend_addkey = top.document.querySelector("a.comiis_recommend_addkey"); /* 论坛浏览图片下的点赞按钮,获取formhash */ let comiis_recommend_addkey_match = null; inputFormHash = inputFormHash ? inputFormHash.value : null; if(sidenv_exit){ sidenv_exit_match = sidenv_exit.href.match(mt_config.rexp.formhash); sidenv_exit_match = sidenv_exit_match ? sidenv_exit_match[sidenv_exit_match.length - 1] : null; } if(comiis_recommend_addkey){ comiis_recommend_addkey_match = comiis_recommend_addkey.href.match(mt_config.rexp.hash); comiis_recommend_addkey_match = comiis_recommend_addkey_match ? comiis_recommend_addkey_match[comiis_recommend_addkey_match.length-1] : null; } return inputFormHash || sidenv_exit_match || comiis_recommend_addkey_match; } function danmurun(run_time, con, line) { /* 弹幕 */ function randDanmu() { let icon = utils.randomArr(['', 's', 'e', 'w', 'a', 'h', 'https://cdn-bbs.mt2.cn/template/comiis_app/comiis/img/favicon.ico']); let type = utils.randomArr(['w', 'b']); let danmuinfo = ["已签到", "请刷新", "不要呆着了", "快点滴", "手机要爆炸了", "麻溜的", "说的就是你", "看什么看", "懂不懂自动签到的含金量啊", "别迷恋哥,哥只是个传说", "你不懂自动签到的含金量", "花会枯萎,自动签到永不凋零"]; if (con) { danmuinfo = danmuinfo.concat("恭喜你签到获取" + con + "金币奖励"); } if (line) { danmuinfo = danmuinfo.concat("你的签到排行为: 第 " + line); } let randTip = utils.randomArr(danmuinfo); xtip.danmu(randTip, { icon: icon, type: type, }); } return setInterval(function () { randDanmu(); }, run_time); } function signIn(_formhash_) { /* 签到 */ console.log("发送签到请求"); GM_xmlhttpRequest({ method: "get", url: "/k_misign-sign.html?operation=qiandao&format=button&formhash=" + _formhash_ + "&inajax=1&ajaxtarget=midaben_sign", headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" }, timeout: 5000, onload: (r) => { console.log(r); GM_setValue("mt_sign", parseInt(utils.getFormatTime("yyyyMMdd"))); if (r.lastChild || typeof r == "string") { /* ajax函数版本 */ if (typeof r == "string") { popup2.toast({ "text": "签到: 成功" }); var intervalId = danmurun(450); setTimeout(function () { /* 10秒后关闭 */ clearInterval(intervalId); }, 50000); return; }; let signInContent = r.lastChild.firstChild.nodeValue; if (signInContent.indexOf("您已经被列入黑名单") != -1) { popup2.toast({ "text": "签到: 您已经被列入黑名单" }); return } if (signInContent.indexOf("今日已签" != -1)) { popup2.toast({ "text": "签到: 今日已签" }); return } } else { /* GM_xmlhttpRequest版本 */ let CDATA = r.responseText.match(/<\!\[CDATA\[([\s\S]*)\]\]>/); CDATA = CDATA[CDATA.length - 1]; let CDATA_Node = $jq("" + CDATA + ""); let content = CDATA_Node.text(); console.log(content); if (content.indexOf("您已经被列入黑名单") != -1) { popup2.toast({ "text": "签到: 您已经被列入黑名单" }); return } if (content.indexOf("今日已签") != -1) { popup2.toast({ "text": "签到: 今日已签" }); return } let signIn_con = CDATA_Node.find(".con"); /* 签到奖励 */ let signIn_line = CDATA_Node.find(".line"); /* 签到排名 */ if (signIn_con.length && signIn_line.length) { let con = signIn_con.text().match(/([0-9]+)金币/); let line = signIn_line.text().match(/([0-9]+)/); con = con[con.length - 1]; line = line[line.length - 1]; console.log(`金币${con},排名${line}`); popup2.toast({ "text": `签到排名 ${line}金币 ${con}` }); var intervalId = danmurun(450, con, line); setTimeout(function () { /* 10秒后关闭 */ clearInterval(intervalId); popup2.toast_close(); }, 50000); return } popup2.toast({ "text": "签到: 未知结果,请查看控制台信息" }); } if (typeof r == "string") { /* 无油猴函数的版本的签到成功是没有返回值的 */ popup2.toast({ "text": "签到: 成功" }); var intervalId = danmurun(450); setTimeout(function () { /* 10秒后关闭 */ clearInterval(intervalId); popup2.toast_close(); }, 50000); return } }, onerror: (r) => { console.log(r); console.log("签到: 网络异常"); popup2.toast({ "text": "签到: 网络异常" }); } }) } if (!GM_getValue("v17")) { return; } if (!checkLogin()) { popup2.toast("当前尚未登录账号"); return; } let formhash = getFormHash(); if (formhash == null) { console.log("获取账号formhash失败"); popup2.toast({ "text": "获取账号formhash失败" }); return; } if (utils.getFormatTime("HH") == "23" && parseInt(utils.getFormatTime("mm")) >= 55) { /* 倒计时开启 */ console.log("开启倒计时自动签到"); let intervalId = setInterval(() => { let current_time = utils.getFormatTime("HH:mm:ss"); if (utils.getFormatTime("hh:mm") == "00:00") { signIn(formhash); clearInterval(intervalId); } else { popup2.toast(`倒计时: ${current_time}`); } }, 1000); return; } if (GM_getValue("mt_sign") == parseInt(utils.getFormatTime("yyyyMMdd"))) { return; } else { signIn(formhash); } }, blackHome: { showBlackHomeView: async () => { /* 显示小黑屋界面 */ if (typeof $jq.NZ_MsgBox == "undefined") { popup2.toast("加载NZMsgBox.js中"); await GM_asyncLoadScriptNode("https://greasyfork.org/scripts/449562-nzmsgbox/code/NZMsgBox.js"); if (typeof $jq.NZ_MsgBox == "undefined") { popup2.toast("网络异常,加载NZMsgBox.js失败"); return; } else { console.log("成功加载NZMsgBox.js"); } } $jq.NZ_MsgBox.alert({ title: "小黑屋名单", content: "获取中", type: "", location: "center", buttons: { confirm: { text: "确定" } } }); let blacklistret = await mobile.blackHome.getBlackList(); if (blacklistret == null) { $jq(".msgcon").html("获取小黑屋名单失败,请重新获取"); return }; let blackListJSON = utils.jsonStrToObject(blacklistret)["data"]; let blackContent = ''; function jsonToArrayWithAddPropertyTime(data) { let _list_ = []; let _no_time_list_ = []; console.log(data); $jq.each(data, function (index, value) { let date = value["dateline"].match(/([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}[\s]*[0-9]{1,2}:[0-9]{1,2})/g); if (date == null) { let _time_ = parseInt(Date.now() / 1000); let _time_after_count_ = 0; let sec_data = value["dateline"].match(/([0-9]+|半)[\s\S]*秒前/); /* xx|半秒前 */ let min_data = value["dateline"].match(/([0-9]+|半)[\s\S]*分钟前/); /* xx|半分钟前 */ let hour_data = value["dateline"].match(/([0-9]+|半)[\s\S]*小时前/); /* xx|半小时前 */ let yesterday_time_data = value["dateline"].match(/昨天[\s\S]*(\d{2}):(\d{2})/); /* 昨天 xx:xx */ let before_yesterday_time_data = value["dateline"].match(/前天[\s\S]*(\d{2}):(\d{2})/); /* 前天 xx:xx */ let day_data = value["dateline"].match(/([0-9]+|半)[\s\S]*天前/); /* xx天前 */ if (sec_data) { sec_data = sec_data[sec_data.length - 1]; sec_data = sec_data.replace(/半/g, 0.5); sec_data = parseFloat(sec_data); _time_after_count_ = _time_ - sec_data; } else if (min_data) { min_data = min_data[min_data.length - 1]; min_data = min_data.replace(/半/g, 0.5); min_data = parseFloat(min_data); _time_after_count_ = _time_ - min_data * 60; } else if (hour_data) { hour_data = hour_data[hour_data.length - 1]; hour_data = hour_data.replace(/半/g, 0.5); hour_data = parseFloat(hour_data); _time_after_count_ = _time_ - sec_data * 60 * 60; } else if (yesterday_time_data) { let yesterday_hour_data = yesterday_time_data[1]; let yesterday_min_data = yesterday_time_data[2]; _time_after_count_ = _time_ - 86400 - parseInt(yesterday_hour_data) * 3600 - parseInt(yesterday_min_data) * 60; } else if (before_yesterday_time_data) { let before_yesterday_hour_data = before_yesterday_time_data[1]; let before_yesterday_min_data = before_yesterday_time_data[2]; _time_after_count_ = _time_ - 86400 * 2 - parseInt(before_yesterday_hour_data) * 3600 - parseInt(before_yesterday_min_data) * 60; } else if (day_data) { day_data = day_data[day_data.length - 1]; day_data = day_data.replace(/半/g, 0.5); day_data = parseFloat(day_data); _time_after_count_ = _time_ - day_data * 60 * 60 * 24; } value["time"] = parseInt(_time_after_count_) * 1000; _list_ = _list_.concat(value); return } else { date = date[0] }; value["time"] = utils.formatDateStrToStamp(date); _list_ = _list_.concat(value); }); _list_.sort(utils.sortListByProperty("time", "desc")); if (_no_time_list_.length) { _no_time_list_.sort(utils.sortListByProperty("sortTime", "asc")); } _list_ = _no_time_list_.concat(_list_); return _list_; } let newBlacklist = jsonToArrayWithAddPropertyTime(blackListJSON); console.log(newBlacklist); $jq.each(newBlacklist, function (index, value) { let blackreson = (value["reason"] == "") ? "无" : value["reason"]; blackContent = blackContent + ` ` + value["username"] + ` 操作时间: ` + value["dateline"] + ` 操作行为: ` + value["action"] + ` 过期时间: ` + value["groupexpiry"] + ` 操作人员: ` + value["operator"] + ` 操作理由: ` + blackreson + ` `; /* console.log(value); */ }) let mainBlackContent = '
操作行为: ` + value["action"] + `
过期时间: ` + value["groupexpiry"] + `
操作人员: ` + value["operator"] + `
${chartbedname}
账号
密码
没有账号?点我去注册!
是否删除帖子?
确定删除该文件?
${forumPostTitle}
bbs.binmt.cc
确定移出付费主题白嫖列表?
回复 ${content}
${content}
共有 0 人参与投票
距结束还有: ${polldatas > 1 ? ''+(polldatas-1)+' 天 ':''}23 小时 59 分钟
月天数 ` + people["monthDays"] + ` 天 , 上次奖励 ` + people["reward"] + `