// ==UserScript== // @name MT论坛 // @namespace http://tampermonkey.net/ // @description MT论坛效果增强,如自动签到、自动展开帖子、滚动加载评论、显示uid、屏蔽用户、手机版小黑屋、编辑器优化等 // @version 2.6.3 // @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=1118788 // @require https://greasyfork.org/scripts/449562-nzmsgbox/code/NZMsgBox.js?version=1082044 // @require https://greasyfork.org/scripts/452322-js-watermark/code/js-watermark.js?version=1102558 // @require https://greasyfork.org/scripts/456607-gm-html2canvas/code/GM_html2canvas.js?version=1128500 // @require https://greasyfork.org/scripts/455186-whitesevsutils/code/WhiteSevsUtils.js?version=1128511 // @downloadURL none // ==/UserScript== (function () { "use strict"; const log = { success: (str) => { console.log("%c" + str, "color: #00a5ff"); }, error: (str) => { console.trace("%c" + str, "color: #f20000"); }, }; 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; width: 100% !important; background: transparent !important; border-radius: unset; }`, }, 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('
')); } else { $jq("#force-mask").html(""); } }, confirm: function (param_options) { let options = { text: "Call By popup2.confirm", reverse: false /* 底部按钮倒序 */, mask: true, only: true, ok: { enable: true, text: "确定", callback: () => { popup2.confirm_close(); }, }, cancel: { enable: true, text: "取消", callback: () => { popup2.confirm_close(); }, }, other: { enable: false, text: "另一个按钮", callback: () => { popup2.confirm_close(); }, }, }; if (typeof param_options == "string") { options.text = param_options; } else { options = Utils.assignJSON(options, param_options); } let bottomBtnHTML = ""; let confirmHTML = ""; let maxZIndex = Utils.getMaxZIndex() + 10; let confirmZIndex = popup2.config.confirm.zIndex > maxZIndex ? popup2.config.confirm.zIndex : maxZIndex + 10; if (options.ok.enable || options.cancel.enable) { } if (!options.reverse) { bottomBtnHTML = `${options.cancel.text} ${options.ok.text} `; } else { bottomBtnHTML = `${options.ok.text} ${options.cancel.text} `; } confirmHTML = `
${options.text}
${bottomBtnHTML}
`; if (options.only) { this.confirm_close(); } let jqConfirmHTML = $jq(confirmHTML); if (options.other.enable) { jqConfirmHTML.find("dd.b_t .popup2-confirm-bottom-btn").after( $jq(`
${options.other.text}
`) ); jqConfirmHTML.find(".popup2-confirm-other").on("click", function () { Utils.tryCatch(options.other.callback); }); } $jq("body").append(jqConfirmHTML); $jq(`#popup2-confirm a:contains('${options.ok.text}')`).on( "click", () => { Utils.tryCatch(options.ok.callback); } ); if (options.mask) { this.mask_show(maxZIndex); } else { this.mask_close(); } }, toast: (param_options) => { let options = { text: "Call By popup2.toast", only: true, delayTime: 2000, }; if (typeof param_options == "string") { options.text = param_options; } else { for (var key in options) { if (typeof param_options[key] !== "undefined") { options[key] = param_options[key]; } } } if (options.only) { popup2.toast_close(); } let toastobj = $jq(`
${options.text}
`); $jq("body").append(toastobj); toastobj.css( "transform", `matrix(1, 0, 0, 1, 0, ${ toastobj.outerHeight() > 80 ? toastobj.outerHeight() + 80 : 80 })` ); setTimeout(() => { toastobj.addClass("popup2-toast-show"); setTimeout(() => { popup2.toast_close(toastobj); }, options.delayTime); }, 150); }, mask_show: function (zIndex = 0) { this.force_mask_init(); $jq("#force-mask").show(); if (zIndex !== 0) { $jq("#force-mask").css("z-index", zIndex); } }, mask_loading_show: function () { this.force_mask_init(); $jq("#force-mask") .html( `` ) .show(); }, mask_close: function () { $jq("#force-mask").html("").hide(); document.documentElement.style.overflow = "auto"; }, toast_close: (toastobj) => { if (toastobj) { toastobj.remove(); } else { $jq(".popup2-toast").remove(); } }, confirm_close: function () { this.mask_close(); $jq.each($jq(".popup2-popmenu"), function (index, obj) { $jq(obj).remove(); }); }, }; const envIsMobile = () => { /* 用的两套模板id */ var _unsafeWindow_ = window; if (typeof unsafeWindow !== "undefined") { _unsafeWindow_ = unsafeWindow; } return !(_unsafeWindow_.STYLEID === "4"); }; let xtips = { /* 因xtip的消息函数会重复显示,自定义一个 */ value: [], toast: (text, options) => { xtips.value.forEach((item) => { xtip.close(item); }); xtips.value = []; let xtip_toast_id = null; if (options == null) { xtip_toast_id = xtip.msg(text); } else { xtip_toast_id = xtip.msg(text, options); } xtips.value = xtips.value.concat(xtip_toast_id); }, }; let mt_config = { dom_obj: { select_beauty: function () { /* 下拉列表对象 */ return document.querySelector( mt_config.dom_querySelector.select_beauty ); }, combox_switch: function () { /* 复选框对象 */ return document.querySelector( mt_config.dom_querySelector.combox_switch ); }, comiis_verify: function () { /* 帖子内各个人的信息节点【list】 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.comiis_verify ); }, comiis_formlist: function () { /* 导航中最新、热门、精华、恢复、抢沙发的各个帖子【list】 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.comiis_formlist ); }, comiis_mmlist: function () { /* 帖子内评论,包括帖子内容主体,第一个就是主体【list】 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.comiis_mmlist ); }, comiis_postli: function () { /* 帖子内评论,包括帖子内容主体,第一个就是主体【list】 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.comiis_postli ); }, post_bottom_controls: function () { /* 帖子底部一栏控件 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.post_bottom_controls ); }, post_list_of_comments: function () { /* 帖子内评论列表 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.post_list_of_comments ); }, post_next_commect: function () { /* 帖子内评论下一页的按钮 */ return document.querySelectorAll( mt_config.dom_querySelectorAll.post_next_commect ); }, }, dom_querySelector: { select_beauty: "select.beauty-select" /* 本脚本的选择器下拉列表 */, combox_switch: "code.whitesevcheckbox" /* 本脚本的开关选择器 */, }, dom_querySelectorAll: { comiis_verify: "span.comiis_verify" /* 帖子内各个人的信息节点【list】 */, comiis_formlist: "li.forumlist_li" /* 导航中最新、热门、精华、恢复、抢沙发的各个帖子【list】 */, comiis_mmlist: ".comiis_mmlist" /* 帖子内评论,包括帖子内容主体,第一个就是主体【list】 */, comiis_postli: "div.comiis_postli.comiis_list_readimgs.nfqsqi" /* 帖子内评论,包括帖子内容主体,第一个就是主体【list】 */, post_bottom_controls: ".comiis_znalist_bottom.b_t.cl" /* 帖子底部一栏控件 */, post_list_of_comments: "div.comiis_postlist.kqide" /* 帖子内评论列表(总) */, post_next_commect: "div.comiis_page.bg_f>a:nth-child(3)" /* 帖子内评论下一页的按钮 */, }, rexp: { bbs: /bbs.binmt.cc/ /* 论坛 */, search_url: /bbs.binmt.cc\/search.php/g /* 搜索页 */, chat_url: /home.php\?mod=space&do=pm&subop=view/g /* 聊天页 */, home_url: /home.php\?mod=spacecp&ac=profile&op=info/g /* 个人空间页 */, home_url_brief: /home.php\?mod=space/g /* 个人空间页简略url */, home_url_at: /bbs.binmt.cc\/space-uid-/g /* 个人空间页的@点进去 */, home_kmisign_url: /bbs.binmt.cc\/(forum.php\?mod=guide&view=hot(|&mobile=2)|k_misign-sign.html)/g /* 主页和签到页链接 */, home_space_url: /bbs\.binmt\.cc\/home\.php\?mod=space&do=profile&mycenter/g /* 【我的】 个人信息页链接 */, home_space_pc_uid_url: /space-uid-(.*?).html/ /* PC 个人空间链接uid */, reply_forum: /bbs.binmt.cc\/forum.php\?mod=post&action=reply/g /* 回复的界面url */, sign_url: "" /* 签到url */, navigation_url: /forum.php\?mod=guide(&index=1|)&view=(newthread|hot|digest|new|sofa)&index=1/g /* 导航链接,包括最新、热门、精华、回复、抢沙发 */, community_url: /forum.php\?forumlist/ /* 社区 */, forum_post: /(bbs.binmt.cc\/thread-|bbs.binmt.cc\/forum.php\?mod=viewthread)/g /* 帖子链接 */, forum_post_pc: /.*:\/\/bbs.binmt.cc\/thread.*/ /* 资料设置 */, data_setting_url: /mod=space&do=profile&set=comiis&mycenter=1/ /* 帖子链接-PC */, forum_guide_url: /bbs.binmt.cc\/forum.php\?mod=guide/g /* 导航链接 */, forum_post_reply: /forum.php\?mod=post&action=reply/g /* 帖子中回复的链接 */, forum_post_page: "&page=(.*)" /* 帖子链接的当前所在页 page */, forum_post_pc_page: "thread-(.*?)-" /* PC帖子链接的当前所在页 page */, forum_plate_text: /休闲灌水|求助问答|逆向教程|资源共享|综合交流|编程开发|玩机教程|建议反馈/g /* 各版块名称 */, plate_url: /bbs.binmt.cc\/forum-[0-9]{1,2}-[0-9]{1,2}.html/g /* 板块链接 */, formhash: /formhash=(.+)&/ /* 论坛账号的凭证 */, hash: /hash=(.+)&/ /* 论坛账号的凭证 */, font_special: /|<\/font>|||||align=".*?"|
[\s]*
[\s]*
/g /* 帖子内特殊字体格式 */, forum_post_guide_url: /bbs.binmt.cc\/page-[1-5].html|bbs.binmt.cc\/forum.php\?mod=guide/g /* 帖子链接和导航链接 */, mt_uid: /uid=(\d+)/ /* discuz uid */, nologin: /member.php\?mod=logging&action=login(|&mobile=2)/g /* 未登录 */, k_misign_sign: "bbs.binmt.cc/k_misign-sign.html" /* 签到url */, post_forum: /forum.php\?mod=post&action=newthread/ /* 发布帖子 */, edit_forum: /forum.php\?mod=post&action=edit/ /* 编辑帖子 */, space_post: /home.php\?mod=space.*?type=reply/ /* 个人空间-帖子 */, }, GMRunStartTime: Date.now(), cookiePre: () => { return unsafeWindow.cookiepre; } /* cookie前缀 */, uid: () => { return unsafeWindow.discuz_uid; } /* 当前账号的uid */, formhash: () => { return unsafeWindow.formhash; } /* 当前账号的formhash(有延迟仅移动端) */, }; /* mt全屏遮罩调用 popup.open(''); 关闭方式 popup.close() */ function envCheck() { /* 脚本运行环境修复,兼容部分函数 */ let checkStatus = true; let isFailedFunction = []; console.log("正在检测脚本环境..."); if (typeof $ != "undefined") { window.$jq = $.noConflict(true); /* 为什么这么写,X浏览器加载jq会替换网页上的jq */ console.log( `check: %c $jq %c √ jQuery版本:${$jq.fn.jquery}`, "background:#24272A; color:#ffffff", "color:#00a5ff" ); if ($jq.fn.jquery != "3.4.1") { console.log( "jQuery加载错误,如果是非油猴加载本脚本方式,请放到网页加载完毕后执行" ); return false; } if (typeof jQuery != "undefined") { console.log( `check: %c $ %c √ 网站的jQuery版本:${ $.fn ? $.fn.jquery : jQuery.fn.jquery }`, "background:#24272A; color:#ffffff", "color:#00a5ff" ); } } else { checkStatus = false; isFailedFunction = isFailedFunction.concat("jQuery"); console.log( "check: %c $ %c ×", "background:#24272A; color:#ffffff", "color:#f90000" ); } if (typeof mbrowser != "undefined") { window.GM_xmlhttpRequest_isRepair = false; var trans_id = uuid(); GM_xmlhttpRequest = (req) => { g_gm_callback_map[ "_" + user_script_id + "_" + trans_id + "_GM_xmlhttpRequest" ] = req; if (req.url && !req.url.startsWith("http")) { req.url = window.location.origin + "/" + req.url.replace(/^\//, ""); } if (req.data) { if (req.headers) { if (!req.headers["Content-type"]) { req.headers["Content-type"] = "application/x-www-form-urlencoded"; } } else { req.headers = { "Content-type": "application/x-www-form-urlencoded", }; } if (typeof req.data == "object") { var _formData = null; for (key of req.data.keys()) { if (!_formData) { _formData = `${key}=${req.data.get(key)}`; } else { _formData += `&${key}=${req.data.get(key)}`; } } req.data = _formData; } } mbrowser.GM_xmlhttpRequest( user_script_id, trans_id, JSON.stringify(req) ); }; console.log( "check: %c GM_xmlhttpRequest %c √ 替换成X浏览器的GM.xmlHttpRequest", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else if (typeof GM_xmlhttpRequest == "undefined") { window.GM_xmlhttpRequest_isRepair = true; isFailedFunction = isFailedFunction.concat("GM_xmlhttpRequest"); console.log( `check: %c GM_xmlhttpRequest %c 修复,该函数不存在,替换成ajax`, "background:#24272A; color:#ffffff", "background:#fff;" ); window.GM_xmlhttpRequest = (f) => { console.log(`$jq.ajax请求 url: ${f.url}`); console.log(f); let headers_options = {}; let headers_options_key = [ "Accept-Charset", "Accept-Encoding", "Access-Control-Request-Headers", "Access-Control-Request-Method", "Connection", "Content-Length", "Cookie", "Cookie2", "Date", "DNT", "Expect", "Host", "Keep-Alive", "Origin", "Referer", "TE", "Trailer", "Transfer-Encoding", "Upgrade", "User-Agent", "Via", ]; if (f.headers != null) { Array.from(headers_options_key).forEach((item) => { delete f.headers[item]; }); } else { f.headers = {}; } $jq.ajax({ url: f.url, type: f.method, data: f.data, timeout: f.timeout, dataType: f.responseType, headers: headers_options, success: (r) => { if (typeof r === "string") { f.onload({ responseText: r, type: "ajax" }); } else { f.onload(r); } }, error: (r) => { if (r.status == 200) { if (typeof r === "string") { f.onload({ responseText: r, type: "ajax" }); } else { f.onload(r); } } else { if (typeof r === "string") { f.onerror({ responseText: r, type: "ajax" }); } else { f.onerror(r); } } }, }); }; } else { window.GM_xmlhttpRequest_isRepair = false; console.log( "check: %c GM_xmlhttpRequest %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } var loadNetworkResource = []; window.GM_asyncLoadScriptContent = (url, replaceStatus) => { /* 异步执行跨域js资源 js */ if (loadNetworkResource.indexOf(url) != -1) { console.log("已加载该js:", url); return; } replaceStatus = replaceStatus == null ? true : replaceStatus; return new Promise((res) => { GM_xmlhttpRequest({ url: url, method: "GET", async: false, timeout: 10000, onload: (r) => { let execStatus = false; let retText = r.responseText; if (replaceStatus) { retText = retText.replace(/\$/g, "$jq"); retText = retText.replace(/jQuery/g, "$jq"); } try { eval(retText); execStatus = true; loadNetworkResource = loadNetworkResource.concat(url); } catch (error) { console.log("eval执行失败" + error); execStatus = false; } /* try { window.eval(retText); execStatus = true; loadNetworkResource = loadNetworkResource.concat(url); }catch (error) { console.log("window.eval执行失败 " + error); execStatus = false; }*/ res(execStatus); }, onerror: () => { console.log("网络异常,加载JS失败", url); res(false); }, }); }); }; window.GM_asyncLoadScriptNode = (url) => { return new Promise((res) => { let tempNode = document.createElement("script"); tempNode.setAttribute("src", url); document.head.append(tempNode); tempNode.onload = () => { res(); }; }); }; window.GM_asyncLoadStyleSheet = (url) => { /* 异步添加跨域css资源 */ if (loadNetworkResource.indexOf(url) != -1) { console.log("已加载该css:", url); return; } loadNetworkResource = loadNetworkResource.concat(url); let cssNode = document.createElement("link"); cssNode.setAttribute("rel", "stylesheet"); cssNode.setAttribute("href", url); cssNode.setAttribute("type", "text/css"); document.head.append(cssNode); }; if (typeof GM_getValue == "undefined") { window.GM_getValue = (key, defaultValue) => { let value = window.localStorage.getItem(key); if (typeof value == "string" && value.trim() != String()) { value = JSON.parse(value); } else if (defaultValue != null) { value = defaultValue; } return value; }; console.log( "check: %c GM_getValue %c √ 修复", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else { console.log( "check: %c GM_getValue %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } if (typeof GM_setValue == "undefined") { window.GM_setValue = (key, value) => { if (value == undefined) { value = null; } window.localStorage.setItem(key, JSON.stringify(value)); }; console.log( "check: %c GM_setValue %c √ 修复", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else { console.log( "check: %c GM_setValue %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } if (typeof GM_deleteValue == "undefined") { window.GM_deleteValue = (key) => { window.localStorage.removeItem(key); }; console.log( "check: %c GM_deleteValue %c √ 修复", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else { console.log( "check: %c GM_deleteValue %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } if (typeof GM_addStyle == "undefined") { window.GM_addStyle = (styleText) => { let cssDOM = document.createElement("style"); cssDOM.setAttribute("type", "text/css"); cssDOM.innerHTML = styleText; document.head.appendChild(cssDOM); return cssDOM; }; console.log( "check: %c GM_addStyle %c √ 修复", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else { console.log( "check: %c GM_addStyle %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } if (typeof GM_setClipboard == "undefined") { window.GM_setClipboard = (text) => { let clipBoardDOM = document.createElement("input"); clipBoardDOM.type = "text"; clipBoardDOM.setAttribute("style", "opacity:0;position:absolute;"); clipBoardDOM.id = "whitesevClipBoardInput"; document.body.append(clipBoardDOM); let clipBoardInputNode = document.getElementById( "whitesevClipBoardInput" ); clipBoardInputNode.value = text; clipBoardInputNode.removeAttribute("disabled"); clipBoardInputNode.select(); document.execCommand("copy"); clipBoardInputNode.remove(); }; console.log( "check: %c GM_setClipboard %c √ 修复", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else { console.log( "check: %c GM_setClipboard %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } if (typeof unsafeWindow == "undefined") { window.unsafeWindow = window; console.log( "check: %c unsafeWindow %c √ 修复", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } else { console.log( "check: %c unsafeWindow %c √", "background:#24272A; color:#ffffff", "color:#00a5ff" ); } if (checkStatus) { console.log(`脚本环境检测结果: 通过`); } else { let isFailedStr = ""; Array.from(isFailedFunction).forEach((item) => { isFailedStr += item + "、"; }); isFailedStr = isFailedStr.replace(/、$/, ""); console.log(`脚本环境检测结果: ${isFailedStr}失败`); } return checkStatus; } const pc = { collectionForumPost() { /* 悬浮按钮-添加收藏帖子功能 */ if (!window.location.href.match(mt_config.rexp.forum_post)) { return; } var own_formhash = document.querySelector( "#scform > input[type=hidden]:nth-child(1)" ).value; var collect_href_id = window.location.href.match( mt_config.rexp.forum_post_pc_page )[1]; var collect_href = "https://bbs.binmt.cc/home.php?mod=spacecp&ac=favorite&type=thread&id=" + collect_href_id + "&formhash=" + own_formhash; var new_collect = document.createElement("span"); var old_Suspended = document.getElementById("scrolltop"); new_collect.innerHTML = ''; old_Suspended.insertAdjacentElement("afterBegin", new_collect); }, detectUserOnlineStatus() { /* 探测用户在线状态 */ return; if (window.location.href.match(mt_config.rexp.forum_post_pc)) { var quanju = []; var cishu = 0; for ( var sss = document.getElementsByClassName("pls favatar"), ll = 0; ll < sss.length; ll++ ) { var sendmessage = sss[ll].getElementsByClassName("comiis_o cl"); if (sendmessage.length == 0) { } else { var sendmessageurl = sendmessage[0].getElementsByTagName("a")[1].href; let xhr = new XMLHttpRequest(); xhr.open("GET", sendmessageurl, false); xhr.onreadystatechange = function () { if (xhr.readyState == 4) { let pattern = /正在.*]/g; let str = xhr.responseText; let newstr = str.match(pattern)[0]; quanju.push(newstr); } }; xhr.send(); let offLineStaus = quanju[cishu].match("离线") ? true : false; cishu = cishu + 1; var onlineStatusImage = document.createElement("img"); onlineStatusImage.src = offLineStaus ? "https://cdn-bbs.mt2.cn/static/image/smiley/doge/54.png" : "https://cdn-bbs.mt2.cn/static/image/smiley/doge/35.png"; onlineStatusImage.smilied = offLineStaus ? "1353" : "1384"; onlineStatusImage.border = "0"; onlineStatusImage.style = "float:right"; sss[ll].insertAdjacentElement("afterbegin", onlineStatusImage); } } } }, latestReleaseForumPost() { /* 最新发表 */ var latestReleaseNode = $jq( `
  • 最新发表
  • ` ); $jq("#comiis_nv .wp.comiis_nvbox.cl ul").append(latestReleaseNode); if ( window.location.href == "https://bbs.binmt.cc/forum.php?mod=guide&view=newthread" ) { $jq("#mn_forum_10").removeClass("a"); latestReleaseNode .find("a") .css( "background", 'url("https://cdn-bbs.mt2.cn/template/comiis_mi/img/nv_a.png") repeat-x 50% -50px' ); } }, main() { /* 电脑版函数按顺序加载 */ popup2.toast = (text) => { if (typeof text == "string") { xtips.toast(text); } else { xtips.toast(text.text, { times: text.delayTime ? text.delayTime : 2, }); } }; Object.keys(pc).forEach((key) => { if (key !== "main") { Utils.tryCatch(pc[key]); } }); Utils.tryCatch(mobile.identifyLinks); Utils.tryCatch(mobile.autoSignIn); }, quickReply() { /* 快捷回复 */ if (!window.location.href.match(mt_config.rexp.forum_post)) { return; } document.querySelector("#scrolltop > span:nth-child(2) > a").onclick = function () { showWindow("reply", this.href); setTimeout( 'document.querySelector("#moreconf").innerHTML=document.querySelector("#moreconf").innerHTML+\'\';document.querySelector("#insertspace2").onclick=function(){document.querySelector("#postmessage").value=document.querySelector("#postmessage").value+" ";}', 200 ); }; }, async repairPCNoLoadResource() { /* 修复电脑版未加载的js资源 */ await GM_asyncLoadScriptNode( "https://cdn-bbs.mt2.cn/static/js/smilies.js?x6L", false ); await GM_asyncLoadScriptNode( "https://cdn-bbs.mt2.cn/static/js/common.js?hsy", false ); }, showUserLevel() { /* 显示用户具体等级 */ var user_avatar = document.getElementsByClassName("pls favatar"); var i = 0; var user_level = "0级"; for (i = 0; i < user_avatar.length; i++) { var user_current_level = user_avatar[i].getElementsByTagName("em")[1].outerText; var user_info = user_avatar[i].getElementsByTagName("tr")[0]; var user_level_node = document.createElement("td"); switch (user_current_level) { case "幼儿园": user_level = "1级"; break; case "小学生": user_level = "2级"; break; case "初中生": user_level = "3级"; break; case "高中生": user_level = "4级"; break; case "大学生": user_level = "5级"; break; case "硕士生": user_level = "6级"; break; case "博士生": case "实习版主": case "版主": case "审核员": user_level = "7级"; break; case "博士后": case "超级版主": case "网站编辑": user_level = "8级"; break; case "管理员": case "信息监察员": user_level = "9级"; break; } user_level_node.innerHTML = '

    ' + user_level + "

    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.registerWindowCookies(); function checkLogin() { /* 检测是否登录 */ let pc_login = document.querySelector("#comiis_key"); let mobile_login_cookie = Cookies.get("cQWy_2132_auth"); let mobile_lastvisit_cookie = Cookies.get("cQWy_2132_lastvisit"); console.log( "账号cQWy_2132_auth: ", mobile_login_cookie ? mobile_login_cookie.slice(0, 5) + "..." : mobile_login_cookie ); console.log( "账号cQWy_2132_lastvisit: ", mobile_lastvisit_cookie ? Utils.getFormatTime( "yyyy-MM-dd HH:mm:ss", parseInt(mobile_lastvisit_cookie) * 1000 ) : mobile_login_cookie ); return pc_login || mobile_login_cookie || mobile_lastvisit_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 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": Utils.getRandomPCUA(), }, timeout: 5000, onload: (r) => { console.log(r); GM_setValue("mt_sign", parseInt(Utils.getFormatTime("yyyyMMdd"))); if (r.lastChild || r.type == "ajax") { /* ajax函数版本 */ if (r.responseText == "") { popup2.toast({ text: "签到: 成功", delayTime: 4000, }); return; } let signInContent = r.lastChild.firstChild.nodeValue; if (signInContent.indexOf("您已经被列入黑名单") != -1) { popup2.toast({ text: "签到: 您已经被列入黑名单", delayTime: 4000, }); return; } if (signInContent.indexOf("今日已签" != -1)) { popup2.toast({ text: "签到: 今日已签", delayTime: 4000, }); 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: "签到: 您已经被列入黑名单", delayTime: 4000, }); return; } if (content.indexOf("今日已签") != -1) { popup2.toast({ text: "签到: 今日已签", delayTime: 4000, }); 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}
    `, delayTime: 4000, }); return; } popup2.toast({ text: "签到: 未知结果,请查看控制台信息", delayTime: 4000, }); } if (typeof r == "string") { /* 无油猴函数的版本的签到成功是没有返回值的 */ popup2.toast({ text: "签到: 成功", delayTime: 4000, }); return; } }, onerror: (r) => { console.log(r); console.log("签到: 网络异常"); popup2.toast({ text: "签到: 网络异常", delayTime: 4000, }); }, }); } if (!GM_getValue("v17")) { return; } if ( envIsMobile() && window.location.href.match(mt_config.rexp.k_misign_sign) ) { var deleteLocalStorageSignInfo = $jq(`
    `); deleteLocalStorageSignInfo.on("click", () => { popup2.confirm({ text: "

    是否清空脚本签到记录的时间?

    ", ok: { callback: () => { GM_deleteValue("mt_sign"); if (GM_getValue("mt_sign", null) != null) { popup2.toast("删除失败"); } else { popup2.toast("删除成功"); popup2.mask_close(); popup2.confirm_close(); } }, }, mask: true, }); }); $jq(".comiis_head.f_top")?.append(deleteLocalStorageSignInfo); } if (!checkLogin()) { popup2.toast("当前尚未登录账号"); return; } let formhash = getFormHash(); if (formhash == null) { if (document.querySelector("#comiis_picshowbox")) { /* 当前为评论区的看图模式 */ console.log("当前为评论区的看图模式 "); return; } 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_ - hour_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.formatTextToTimeStamp(date); _list_ = _list_.concat(value); }); _list_.sort( Utils.sortListByProperty((item) => { return item["time"]; }) ); _no_time_list_.sort( Utils.sortListByProperty((item) => { return item["time"]; }, false) ); _list_ = [..._list_, ..._no_time_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["dateline"] + `

    操作行为: ` + value["action"] + `

    过期时间: ` + value["groupexpiry"] + `

    操作人员: ` + value["operator"] + `

    操作理由: ` + blackreson + `
    `; /* console.log(value); */ }); let mainBlackContent = '' + blackContent + "
    "; $jq(".msgcon").html(mainBlackContent); $jq(".NZ-MsgBox-alert.NZ-MsgBox--motion").css("top", "100px"); $jq(".msgcon").css("height", "400px"); }, insertMobileBlackHomeButton: async function () { /* 插入手机版查看小黑屋的按钮 */ if ( window.location.href.match(mt_config.rexp.bbs) != null && GM_getValue("v30") ) { let comiis_left_Touch = document.createElement("li"); comiis_left_Touch.className = "comiis_left_Touch"; let black_home_ele = document.createElement("a"); black_home_ele.setAttribute("href", "javascript:;"); black_home_ele.className = "blacklist"; black_home_ele.innerHTML = `
    小黑屋
    `; GM_addStyle(` .NZ-MsgBox-alert .msgcontainer .msgtitle { text-align: center !important; } #autolist .k_misign_lu img { width: 40px; height: 40px; -moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px; } .k_misign_lc .f_c{ margin: 5px 0px; } tbody#autolist, tbody#autolist tr { width: auto; }`); black_home_ele.onclick = () => { mobile.blackHome.showBlackHomeView(); }; comiis_left_Touch.append(black_home_ele); $jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append( comiis_left_Touch ); } }, getBlackList: async (cid) => { /* 获取黑名单列表 */ cid = cid == null ? "" : cid; return new Promise((res) => { GM_xmlhttpRequest({ url: "https://bbs.binmt.cc/forum.php?mod=misc&action=showdarkroom&cid=" + cid + "&t=&ajaxdata=json", timeout: 5000, method: "GET", async: false, headers: { "User-Agent": Utils.getRandomPCUA(), }, onload: (r) => { res(r.responseText); }, onerror: (r) => { console.log(r); popup2.toast("网络异常,请重新获取"); res(); }, }); }); }, }, blacklistShieldUsersOrBlocks() { /* 黑名单-屏蔽用户或板块 */ if (!window.location.href.match(mt_config.rexp.home_space_url)) { return; } var white_space_ele = document.createElement("div"); var black_list_ele = document.createElement("div"); white_space_ele.className = "styli_h cl"; black_list_ele.setAttribute("id", "blacklistallmain"); black_list_ele.className = "comiis_myinfo_list bg_f cl"; black_list_ele.innerHTML = `
  • 保存
  • `; GM_addStyle(` #blacklistallmain{ height: 232px; } #blacklistallmain li.comiis_styli{ height: 180px; } #blacklistallmain #blacklistuid{ width: 90%; resize: none; opacity: 0.7; height: 70% !important; line-height: inherit; -webkit-appearance: none; border: none !important; font-size: 14px; vertical-align: middle; background-color: transparent; border-bottom: 3px solid #efefef !important; } #blacklistallmain #blacklistplate{ width: 90%; resize: none; opacity: 0.7; height: 30% !important; line-height: inherit; -webkit-appearance: none; border: none !important; font-size: 14px; vertical-align: middle; background-color: transparent; } #blacklistsave{ text-align: center; background: transparent !important; border-color: transparent !important; } `); let mt_commis_menu = document.getElementsByClassName("comiis_myinfo cl")[0]; mt_commis_menu.appendChild(white_space_ele); mt_commis_menu.appendChild(black_list_ele); mt_commis_menu.appendChild(white_space_ele); document.getElementById("blacklistuid").textContent = GM_getValue( "blacklistuid" ) ? GM_getValue("blacklistuid") : ""; document.getElementById("blacklistplate").textContent = GM_getValue( "blacklistplate" ) ? GM_getValue("blacklistplate") : ""; document.getElementById("blacklistsave").onclick = () => { let blackListUIDValue = document.getElementById("blacklistuid").value; let blackListPlateValue = document.getElementById("blacklistplate").value; GM_setValue("blacklistuid", blackListUIDValue); GM_setValue("blacklistplate", blackListPlateValue); popup2.toast("保存成功"); }; }, chartBed: { ret_code: { 200: { 200: "删除成功", }, 500: { 101: "重复上传", 400: "请求被拒绝,token错误", 401: "请求被拒绝", }, 400: { 100: "删除失败,图片已删除", 101: "重复上传", }, }, storage: { add: function (web, id_encoded, url, thumb_url, name) { let localData = GM_getValue("chartBedsImagesHistory") ? GM_getValue("chartBedsImagesHistory") : []; let saveData = localData.concat({ web: web, id_encoded: id_encoded, url: url, thumb_url: thumb_url, name: name, }); GM_setValue("chartBedsImagesHistory", saveData); }, delete: function (_web_, id_encoded) { let localData = GM_getValue("chartBedsImagesHistory") ? GM_getValue("chartBedsImagesHistory") : []; Array.from(localData).forEach((item, index) => { if (item["web"] == _web_ && item["id_encoded"] == id_encoded) { localData.splice(index, 1); GM_setValue("chartBedsImagesHistory", localData); return; } }); }, get: function () { return GM_getValue("chartBedsImagesHistory") ? GM_getValue("chartBedsImagesHistory") : []; }, }, getAuthToken(url) { /* 获取图床的auth_token */ return new Promise((res) => { GM_xmlhttpRequest({ url: url, method: "GET", headers: { "user-agent": Utils.getRandomPCUA(), }, onload: (r) => { let token = r.responseText.match( /PF.obj.config.auth_token[\s]*=[\s]*"(.+)";/i ); if (token.length == 2) { popup2.toast("auth_token成功获取"); res(token[1]); } else { console.log(r); popup2.toast("auth_token获取失败"); res(null); } }, onerror: () => { popup2.toast("网络异常"); res(null); }, }); }); }, login(url, user, pwd, auth_token) { /* 图床登录 */ return new Promise((res) => { GM_xmlhttpRequest({ url: `${url}/login`, method: "POST", data: `login-subject=${user}&password=${pwd}&auth_token=${auth_token}`, headers: { "Content-Type": "application/x-www-form-urlencoded", }, onload: (e) => { console.log(e); if (e.status == 200 && e.responseText.match("注销")) { popup2.toast("登陆成功"); res(true); } else { popup2.toast("登录失败"); res(false); } }, onerror: () => { popup2.toast("网络异常"); res(404); }, }); }); }, uploadImage(url, auth_token, imageFile) { /* 上传图片请求 */ let res_data = { imageUri: null, json_data: null, }; console.log(imageFile); let form = new FormData(); form.append("type", "file"); form.append("action", "upload"); form.append("timestamp", new Date().getTime()); form.append("auth_token", auth_token); form.append("nsfw", 0); form.append("source", imageFile); return new Promise((res) => { GM_xmlhttpRequest({ url: `${url}/json`, method: "POST", data: form, async: false, responseType: "json", headers: { Accept: "application/json", "User-Agent": Utils.getRandomPCUA(), Referer: `${url}/`, Origin: url, }, onload: (r) => { let json_data = JSON.parse(r.responseText); console.log(json_data); let status_code = json_data["status_code"]; if (status_code == 200) { popup2.toast("上传成功"); let file_reader = new FileReader(); /* FileReader主要用于将文件内容读入内存,通过一系列异步接口,可以在主线程中访问本地文件 */ file_reader.readAsDataURL( imageFile ); /* 读取图片的内容生成的base64编码的图 */ /* 读取完成后,执行该回调函数,它会返回读取的结果result */ file_reader.onload = function () { let imageUri = this.result; /* 此时的图片已经存储到了result中 */ res_data["imageUri"] = imageUri; res_data["json_data"] = json_data; res(res_data); }; } else if ( mobile.chartBed.ret_code[status_code] != null && mobile.chartBed.ret_code[status_code][ json_data["error"]["code"] ] != null ) { popup2.toast( mobile.chartBed.ret_code[status_code][ json_data["error"]["code"] ] ); res(res_data); } else { console.log(json_data); res(res_data); } }, onerror: (r) => { console.log(r.responseText); popup2.toast("网络异常"); res(res_data); }, }); }); }, deleteImage(url, auth_token, id_encoded) { /* 删除图片请求 */ return new Promise((res) => { GM_xmlhttpRequest({ url: `${url}/json`, method: "POST", data: `auth_token=${auth_token}&action=delete&single=true&delete=image&deleting[id]=${id_encoded}`, headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", }, onload: (e) => { let json_data = JSON.parse(e.responseText); let status_code = json_data["status_code"]; if (status_code == 200 && json_data["success"]["code"] == 200) { popup2.toast(mobile.chartBed.ret_code["200"]["200"]); res(true); } else if ( status_code == 400 && json_data["error"]["code"] == 100 ) { popup2.toast(mobile.chartBed.ret_code["400"]["100"]); res(true); } else if ( mobile.chartBed.ret_code[status_code] != null && mobile.chartBed.ret_code[status_code][ json_data["error"]["code"] ] != null ) { popup2.toast( mobile.chartBed.ret_code[status_code][ json_data["error"]["code"] ] ); res(false); } else { console.log(json_data); popup2.toast(json_data["error"]["message"]); res(false); } }, onerror: () => { popup2.toast("网络异常"); res(false); }, }); }); }, popupUserPwd(chartbedname, register_url, callbackfun) { popup2.confirm({ text: `

    ${chartbedname}

    `, mask: true, only: true, ok: { callback: () => { callbackfun(); }, }, }); }, }, chatChartBed() { /* 聊天的图床 */ if ( !window.location.href.match(mt_config.rexp.chat_url) || !GM_getValue("v40") ) { return; } GM_addStyle(` .comiis_post_imglist li.up_btn_kggzs a, .comiis_post_imglist li.up_btn_hello a, .comiis_post_imglist li.up_btn_z4a a{ display: block; width: 50px; height: 50px; line-height: 50px; padding: 4px; border-radius: 2px; border-style: dashed; } .comiis_post_imglist li.up_btn_kggzs a i, .comiis_post_imglist li.up_btn_hello a i, .comiis_post_imglist li.up_btn_z4a a i { position: absolute; top: 11px; left: 5px; z-index: 8; font-size: 26px; width: 50px; height: 50px; line-height: 50px; text-align: center; } .comiis_post_imglist li.up_btn_kggzs a input, .comiis_post_imglist li.up_btn_hello a input, .comiis_post_imglist li.up_btn_z4a a input { position:absolute; top:11px; left:5px; height:50px; width:50px; z-index:10; opacity:0; } .comiis_post_imglist li .delImg { position:absolute; top:-5px; left:-5px } .comiis_post_imglist li .delImg i { font-size:24px; background:#fff; border-radius:50% } .imgboxlist{ height: 170px; overflow-y: auto; } .menuclicked{ background: #fff; } #filedata_kggzs, #filedata_hello, #filedata_z4a{ display: none; } `); function chatKGChartBed() { /* 聊天快捷图片上传康哥图床 */ let chartBedUrl = "https://img.kggzs.cn/api/v1"; let chartBedUser = GM_getValue("KggzsChartBedUser"); let chartBedPwd = GM_getValue("KggzsChartBedPwd"); let chartBedToken = null; let loginStatus = false; /* 登录状态 */ let tokenStatus = false; /* token状态 */ let code = { 401: "未登录或授权失败", 403: "管理员关闭了接口功能", 429: "超出请求配额,请求受限", 500: "服务端出现异常", }; function getToken() { return new Promise((res) => { let formData = new FormData(); formData.append("email", chartBedUser); formData.append("password", chartBedPwd); GM_xmlhttpRequest({ url: `${chartBedUrl}/tokens`, method: "POST", data: formData, headers: { Accept: "application/json", }, onload: (r) => { if (code[r.status] != null) { popup2.toast(code[r.status]); res(null); return; } let json_data = JSON.parse(r.responseText); if (json_data["status"]) { popup2.toast("token成功获取"); res(json_data["data"]["token"]); } else { popup2.toast(json_data["message"]); res(null); } }, onerror: () => { popup2.toast("网络异常"); res(null); }, }); }); } function uploadImage(imageFile) { let res_data = { imageUri: null, json_data: null, }; let form = new FormData(); form.append("strategy_id", 2); /* 存储策略 */ form.append("file", imageFile); return new Promise((res) => { GM_xmlhttpRequest({ url: `${chartBedUrl}/upload`, method: "POST", data: form, async: false, responseType: "json", headers: { Accept: "application/json", "User-Agent": Utils.getRandomPCUA(), Authorization: `Bearer ${chartBedToken}`, }, onload: (r) => { if (code[r.status] != null) { popup2.toast(code[r.status]); res(res_data); return; } let json_data = JSON.parse(r.responseText); console.log(json_data); if (json_data["status"]) { popup2.toast("上传成功"); let file_reader = new FileReader(); /* FileReader主要用于将文件内容读入内存,通过一系列异步接口,可以在主线程中访问本地文件 */ file_reader.readAsDataURL( imageFile ); /* 读取图片的内容生成的base64编码的图 */ /* 读取完成后,执行该回调函数,它会返回读取的结果result */ file_reader.onload = function () { let imageUri = this.result; /* 此时的图片已经存储到了result中 */ res_data["imageUri"] = imageUri; res_data["json_data"] = json_data; res(res_data); }; } else { console.log(json_data); popup2.toast(json_data["message"]); res(res_data); } }, onerror: (r) => { popup2.toast("网络异常"); res(res_data); }, }); }); } function deleteImage(imageKey) { return new Promise((res) => { GM_xmlhttpRequest({ url: `${chartBedUrl}/images/:${imageKey}`, method: "DELETE", async: false, data: JSON.stringify({ key: "", }), responseType: "json", headers: { Accept: "application/json", "User-Agent": Utils.getRandomPCUA(), Referer: `${chartBedUrl}/`, Authorization: `Bearer ${chartBedToken}`, Origin: chartBedUrl, }, onload: (r) => { if (code[r.status] != null) { popup2.toast(code[r.status]); res(res_data); return; } let json_data = JSON.parse(r.responseText); console.log(json_data); }, onerror: (r) => { popup2.toast("网络异常"); res(res_data); }, }); }); } function clearData() { chartBedUser = ""; chartBedPwd = ""; chartBedToken = null; loginStatus = false; tokenStatus = false; GM_deleteValue("KggzsChartBedUser"); GM_deleteValue("KggzsChartBedPwd"); } $jq(document).on( "click", "#imglist_kggzs .up_btn_kggzs a", async function () { if (tokenStatus) { popup2.toast("正在配置中..."); return; } if (!chartBedUser || !chartBedPwd) { let loginCallBack = () => { let user = $jq("#chartbed_user").val().trim(); let pwd = $jq("#chartbed_pwd").val().trim(); if (user && pwd) { GM_setValue("KggzsChartBedUser", user); GM_setValue("KggzsChartBedPwd", pwd); chartBedUser = user; chartBedPwd = pwd; popup2.toast("设置完毕,请重新点击"); popup2.confirm_close(); } else { popup2.toast("账号或密码不能为空"); } }; mobile.chartBed.popupUserPwd( "康哥图床", "https://img.kggzs.cn/register", loginCallBack ); } else if (chartBedToken == null || !loginStatus) { popup2.mask_loading_show(); tokenStatus = true; popup2.toast("正在配置token"); chartBedToken = await getToken(); popup2.mask_close(); console.log("token:" + chartBedToken); if (chartBedToken != null) { $jq("#filedata_kggzs").click(); } else { clearData(); } tokenStatus = false; } else { $jq("#filedata_kggzs").click(); } } ); $jq(document).on("change", "#filedata_kggzs", (e) => { let chooseImageFiles = e.currentTarget.files; if (chooseImageFiles.length == 0) { return; } popup2.mask_loading_show(); popup2.toast("上传图片中...请稍后"); console.log(`图片数量:${chooseImageFiles.length}`); let uploadFileAwaitFunction = async (params) => { let imageFile = chooseImageFiles[params[0]]; let uploadImageReturn = await uploadImage(imageFile); if (uploadImageReturn["json_data"] != null) { console.log(uploadImageReturn); let image_id_encoded = uploadImageReturn["json_data"]["data"]["key"]; let image_url = uploadImageReturn["json_data"]["data"]["links"]["url"]; let image_thumb_url = uploadImageReturn["json_data"]["data"]["links"][ "thumbnail_url" ]; let image_name = uploadImageReturn["json_data"]["data"]["origin_name"]; let image_uri = uploadImageReturn["imageUri"]; let uploadImageHTML = `
  • 插入
  • `; $jq("#imglist_kggzs").append($jq(uploadImageHTML)); mobile.chartBed.storage.add( "kggzs", image_id_encoded, image_url, image_thumb_url, image_name ); } }; let completeFunction = () => { popup2.mask_close(); $jq("#filedata_kggzs").val(""); }; Utils.asyncArrayForEach( chooseImageFiles, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); }); $jq(document).on("click", "#imglist_kggzs .delImg", async function (e) { e.preventDefault(); e.currentTarget.parentElement.remove(); /* popup2.toast('删除中,请稍后'); let id_encoded = e.currentTarget.getAttribute("id-encode"); if(!id_encoded){ popup2.toast('获取id_encoded失败,请自行去Hello图床删除'); return; } let deleteStatus = await deleteImage(key); if(deleteStatus){ e.currentTarget.parentElement.remove(); mobile.chartBed.storage.delete("kggzs",id_encoded); } */ }); } function chatHelloChartBed() { /* 聊天快捷图片上传Hello图床 */ let chartBedUrl = "https://www.helloimg.com"; let chartBedUser = GM_getValue("HelloChartBedUser"); let chartBedPwd = GM_getValue("HelloChartBedPwd"); let chartBedAuthToken = null; let loginStatus = false; /* 登录状态 */ let authTokenStatus = false; /* authToken状态 */ let clearData = () => { GM_deleteValue("HelloChartBedUser"); GM_deleteValue("HelloChartBedPwd"); loginStatus = false; authTokenStatus = false; chartBedUser = ""; chartBedPwd = ""; chartBedAuthToken = null; }; $jq(document).on( "click", "#imglist_hello .up_btn_hello a", async function () { if (authTokenStatus) { popup2.toast("正在配置中..."); return; } if (!chartBedUser || !chartBedPwd) { let loginCallBack = () => { let user = $jq("#chartbed_user").val().trim(); let pwd = $jq("#chartbed_pwd").val().trim(); if (user && pwd) { GM_setValue("HelloChartBedUser", user); GM_setValue("HelloChartBedPwd", pwd); chartBedUser = user; chartBedPwd = pwd; popup2.toast("设置完毕,请重新点击"); popup2.confirm_close(); } else { popup2.toast("账号或密码不能为空"); } }; mobile.chartBed.popupUserPwd( "Hello图床", "https://www.helloimg.com/signup", loginCallBack ); } else if (chartBedAuthToken == null || !loginStatus) { authTokenStatus = true; popup2.mask_loading_show(); popup2.toast("正在配置auth_token"); chartBedAuthToken = await mobile.chartBed.getAuthToken( chartBedUrl ); console.log("auth_token:" + chartBedAuthToken); if (chartBedAuthToken != null) { popup2.toast("正在登录Hello图床"); let retloginStatus = await mobile.chartBed.login( chartBedUrl, chartBedUser, chartBedPwd, chartBedAuthToken ); popup2.mask_close(); if (retloginStatus) { loginStatus = true; $jq("#filedata_hello").click(); } else if (retloginStatus == false) { clearData(); } } popup2.mask_close(); authTokenStatus = false; } else { $jq("#filedata_hello").click(); } } ); $jq(document).on("change", "#filedata_hello", (e) => { let chooseImageFiles = e.currentTarget.files; if (chooseImageFiles.length == 0) { return; } popup2.mask_loading_show(); popup2.toast("上传图片中...请稍后"); let uploadFileAwaitFunction = async (params) => { let imageFile = chooseImageFiles[params[0]]; let uploadImageReturn = await mobile.chartBed.uploadImage( chartBedUrl, chartBedAuthToken, imageFile ); if (uploadImageReturn["json_data"] != null) { let image_id_encoded = uploadImageReturn["json_data"]["image"]["id_encoded"]; let image_url = uploadImageReturn["json_data"]["image"]["url"]; let image_thumb_url = uploadImageReturn["json_data"]["image"]["thumb"]["url"]; let image_name = uploadImageReturn["json_data"]["image"]["filename"]; let image_uri = uploadImageReturn["imageUri"]; let uploadImageHTML = `
  • 插入
  • `; $jq("#imglist_hello").append($jq(uploadImageHTML)); mobile.chartBed.storage.add( "hello", image_id_encoded, image_url, image_thumb_url, image_name ); } }; let completeFunction = () => { popup2.mask_close(); $jq("#filedata_hello").val(""); }; Utils.asyncArrayForEach( chooseImageFiles, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); }); $jq(document).on("click", "#imglist_hello .delImg", async function (e) { e.preventDefault(); popup2.mask_loading_show(); popup2.toast("删除中,请稍后"); let id_encoded = e.currentTarget.getAttribute("id-encode"); if (!id_encoded) { popup2.mask_close(); popup2.toast("获取id_encoded失败,请自行去Hello图床删除"); return; } let deleteStatus = await mobile.chartBed.deleteImage( chartBedUrl, chartBedAuthToken, id_encoded ); popup2.mask_close(); if (deleteStatus) { $jq(this).parent().remove(); mobile.chartBed.storage.delete("hello", id_encoded); } }); } function chatZ4AChartBed() { /* 聊天快捷图片上传Z4A图床 */ let chartBedUrl = "https://www.z4a.net"; let chartBedUser = GM_getValue("Z4AChartBedUser"); let chartBedPwd = GM_getValue("Z4AChartBedPwd"); let chartBedAuthToken = null; let loginStatus = false; /* 登录状态 */ let authTokenStatus = false; /* authToken状态 */ let clearData = () => { GM_deleteValue("Z4AChartBedUser"); GM_deleteValue("Z4AChartBedPwd"); loginStatus = false; authTokenStatus = false; chartBedUser = ""; chartBedPwd = ""; chartBedAuthToken = null; }; $jq(document).on( "click", "#imglist_z4a .up_btn_z4a a", async function () { if (authTokenStatus) { popup2.toast("正在配置中..."); return; } if (!chartBedUser || !chartBedPwd) { let loginCallBack = () => { let user = $jq("#chartbed_user").val().trim(); let pwd = $jq("#chartbed_pwd").val().trim(); if (user && pwd) { GM_setValue("Z4AChartBedUser", user); GM_setValue("Z4AChartBedPwd", pwd); chartBedUser = user; chartBedPwd = pwd; popup2.toast("设置完毕,请重新点击"); popup2.confirm_close(); } else { popup2.toast("账号或密码不能为空"); } }; mobile.chartBed.popupUserPwd( "Z4A图床", "https://www.z4a.net/signup", loginCallBack ); } else if (chartBedAuthToken == null || !loginStatus) { popup2.mask_loading_show(); authTokenStatus = true; popup2.toast("正在配置auth_token"); chartBedAuthToken = await mobile.chartBed.getAuthToken( chartBedUrl ); console.log("auth_token:" + chartBedAuthToken); if (chartBedAuthToken != null) { popup2.toast("正在登录Z4A图床"); let retloginStatus = await mobile.chartBed.login( chartBedUrl, chartBedUser, chartBedPwd, chartBedAuthToken ); popup2.mask_close(); if (retloginStatus) { loginStatus = true; $jq("#filedata_z4a").click(); } else if (retloginStatus == false) { clearData(); } } popup2.mask_close(); authTokenStatus = false; } else { $jq("#filedata_z4a").click(); } } ); $jq(document).on("change", "#filedata_z4a", async (e) => { let chooseImageFiles = e.currentTarget.files; if (chooseImageFiles.length == 0) { return; } popup2.mask_loading_show(); popup2.toast("上传图片中...请稍后"); let uploadFileAwaitFunction = async (params) => { console.log("上传图片:" + chooseImageFiles[params[0]]); let uploadImageReturn = await mobile.chartBed.uploadImage( chartBedUrl, chartBedAuthToken, chooseImageFiles[params[0]] ); if (uploadImageReturn["json_data"] != null) { let image_id_encoded = uploadImageReturn["json_data"]["image"]["id_encoded"]; let image_url = uploadImageReturn["json_data"]["image"]["url"]; let image_thumb_url = uploadImageReturn["json_data"]["image"]["thumb"]["url"]; let image_name = uploadImageReturn["json_data"]["image"]["filename"]; let image_uri = uploadImageReturn["imageUri"]; let uploadImageHTML = `
  • 插入
  • `; $jq("#imglist_z4a").append($jq(uploadImageHTML)); mobile.chartBed.storage.add( "z4a", image_id_encoded, image_url, image_thumb_url, image_name ); } }; let completeFunction = () => { popup2.mask_close(); $jq("#filedata_z4a").val(""); }; Utils.asyncArrayForEach( chooseImageFiles, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); }); $jq(document).on("click", "#imglist_z4a .delImg", async function (e) { e.preventDefault(); popup2.mask_loading_show(); popup2.toast("删除中,请稍后"); let id_encoded = e.currentTarget.getAttribute("id-encode"); if (!id_encoded) { popup2.mask_close(); popup2.toast("获取id_encoded失败,请自行去Z4A图床删除"); return; } let deleteStatus = await mobile.chartBed.deleteImage( chartBedUrl, chartBedAuthToken, id_encoded ); popup2.mask_close(); if (deleteStatus) { $jq(this).parent().remove(); mobile.chartBed.storage.delete("z4a", id_encoded); } }); } function chatHistoryChartBedImages() { /* 所有图床历史上传过的图片 */ let historyImages = mobile.chartBed.storage.get(); $jq.each(historyImages, (i) => { let _web = historyImages[i]["web"]; let _url = historyImages[i]["url"]; let _thumb_url = historyImages[i]["thumb_url"]; let _name = historyImages[i]["name"]; let _imageHTML = `
  • ${_web}
  • `; $jq("#imglist_history").append($jq(_imageHTML)); }); $jq("#menu_chartbed_history").on("click", function () { $jq.each($jq("#imglist_history li img"), (i, v) => { if (!v.getAttribute("src")) { v.setAttribute("src", v.getAttribute("data-src")); } }); }); $jq("#imglist_history").on("click", ".delImg", async (e) => { e.preventDefault(); let _t_index = e.currentTarget.getAttribute("t-index"); let imageItem = historyImages[_t_index]; let web = imageItem["web"]; let id_encoded = imageItem["id_encoded"]; e.currentTarget.parentElement.remove(); mobile.chartBed.storage.delete(web, id_encoded); }); } let imgBtn = ``; let menu = ``; $jq(".styli_tit.comiis_post_ico.f_c.cl").append($jq(imgBtn)); $jq("#comiis_post_tab").append($jq(menu)); let imgUploadBtn = ` `; let imgMenu = `
  • 康哥图床
  • hello图床
  • z4a图床
  • 历史图片
  • `; $jq("#comiis_img_chartbed_key").append($jq(imgMenu)); $jq(".comiis_minibq .imgboxlist").append($jq(imgUploadBtn)); $jq("#comiis_img_chartbed_key li").on("click", function () { $jq("#comiis_img_chartbed_key li").removeClass("bg_f"); $jq(this).addClass("bg_f"); $jq("#comiis_post_tab .imgboxlist .comiis_upbox") .hide() .eq($jq(this).index()) .fadeIn(); }); if (GM_getValue("chartBedsImagesHistory") == undefined) { GM_setValue("chartBedsImagesHistory", []); } Utils.tryCatch(chatKGChartBed); Utils.tryCatch(chatHelloChartBed); Utils.tryCatch(chatZ4AChartBed); Utils.tryCatch(chatHistoryChartBedImages); }, codeQuoteCopyBtn() { /* 代码块复制按钮 */ if ( !GM_getValue("v46") && !window.location.href.match(mt_config.rexp.forum_post) ) { return; } let comiis_blockcode = $jq(".comiis_blockcode.comiis_bodybg"); $jq.each(comiis_blockcode, (index, value) => { if (!value.getAttribute("data-copy")) { value.setAttribute("data-copy", true); let tempDivNode = document.createElement("div"); tempDivNode.setAttribute("style", "height: 34px;margin: 14px 0px;"); let btnSpanNode = document.createElement("span"); btnSpanNode.className = "reader-copy-button"; btnSpanNode.setAttribute( "style", "background: #000;background-size: cover;background-repeat: no-repeat;background-position: 0;color: #fff;line-height: 40px;display: block;position: absolute;text-align: center;border-radius: 5px;cursor: pointer;right: auto!important;font-size: 15px;width: 70px;user-select: none;" ); btnSpanNode.innerHTML = ` 复制按钮 复制`; tempDivNode.append(btnSpanNode); tempDivNode.onclick = () => { popup2.toast("已复制代码"); GM_setClipboard(value.outerText || value.innerText); }; value.before(tempDivNode); } else { console.log("已创建复制按钮"); } }); }, commentsAddReviews() { /* 评论区添加点评功能 */ if ( GM_getValue("v6") && window.location.href.match(mt_config.rexp.forum_post) ) { var hongbao = document.getElementsByClassName("bottom_zhan y"); if (hongbao.length == 0) { } else { var cishu2 = 0; var replyhref = hongbao[cishu2].getElementsByTagName("a")[0].href; var page = replyhref.match(mt_config.rexp.forum_post_page)[1]; /* console.log(page); */ for (cishu2 = 0; cishu2 < hongbao.length; cishu2++) { if (hongbao[cishu2].children.length == 1) { var rewardhref = hongbao[cishu2] .getElementsByTagName("a")[0] .href.replace("mod=post&", "mod=misc&"); rewardhref = rewardhref.replace( "action=reply&", "action=comment&" ); var reviews_href = rewardhref + "&extra=page%3D1&page=" + page; let reviews_pid = hongbao[ cishu2 ].parentElement.parentElement.id.replace("pid", "&pid="); reviews_href = reviews_href + reviews_pid; /* console.log(rewardhref) */ var oa = document.createElement("a"); var ob = document.createElement("i"); var lm = document.getElementsByClassName("bottom_zhan y")[cishu2]; oa.href = reviews_href; oa.className = "f_c dialog"; ob.style = "content: url(https://s1.ax1x.com/2020/04/26/Jcq8VU.png);height: 15px;"; ob.className = "comiis_font mt_review"; ob.innerHTML = ""; oa.appendChild(ob); let review_username = hongbao[ cishu2 ].parentElement.parentElement.getElementsByClassName( "top_user f_b" )[0].text; oa.onclick = function () { let click_time = Date.now(); var mt_interval = setInterval(function () { let run_time = parseInt((Date.now() - click_time) / 1000); if (run_time >= 5) { console.log("超时"); clearInterval(mt_interval); } else if ( document.querySelector( "div[id=ntcmsg_popmenu]>div>span.f_c" ) != null ) { console.log("存在,清理定时器"); console.log("点评用户:", review_username); console.log("该对象出现用时:", run_time); try { document.querySelector( "div[id=ntcmsg_popmenu]>div>span.f_c" ).innerText = "点评 " + review_username; } catch (err) { console.log("修改点评失败", err); } clearInterval(mt_interval); } }, 100); }; lm.insertAdjacentElement("afterBegin", oa); } else { console.log("已有点评按钮,无需再次添加"); } } } } }, customCollection() { /* 帖子快照 */ const urlBBSMatchStatus = window.location.href.match(mt_config.rexp.bbs); const forumPostMatchStatus = window.location.href.match( mt_config.rexp.forum_post ); const storageMatchStatus = GM_getValue("v54", false); if (!storageMatchStatus) { return; } const collectTime = Date.now(); const DB_NAME = "mt_db", DB_STORE_NAME = "custom_collection", DB_STORE_KEY_NAME = "forum_post_" + Utils.getFormatTime("yyyy_MM_dd_HH_mm_ss", collectTime); var db = new Utils.indexedDB(DB_NAME, DB_STORE_NAME); async function showView() { /* 显示-快照列表(dialog) */ 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: "确定", }, }, }); var matchRegexp = new RegExp("forum_post_", "gi"); db.regexpGet(matchRegexp).then((resolve) => { if (resolve["code"] !== 200) { popup2.toast({ text: resolve["msg"], }); return; } var customCollectionData = resolve["data"]; if (customCollectionData.length) { console.log(customCollectionData); customCollectionData.sort( Utils.sortListByProperty((item) => { return item["timestamp"]; }, false) ); console.log("排序后——快照:", customCollectionData); $jq(".msgcon").html(""); $jq(".msgcon").append(''); customCollectionData.forEach((item, index) => { var itemElement = $jq(`

    网址:${item["title"]}

    快照:${item["time"]}

    `); itemElement.find("a[t-blank]").on("click", function () { window.open(item["url"], "_blank"); }); itemElement.find("a[t-dialog]").on("click", function () { xtip.open({ type: "html", width: document.documentElement.clientWidth + "px", height: document.documentElement.clientHeight + "px", content: ``, title: "查看帖子快照", lock: true, zindex: parseInt($jq(".NZ-MsgBox-alert").css("z-index")) + 100, }); }); itemElement.find(".delsubjecttip").on("click", function () { var _this = this; popup2.confirm({ text: "

    确定删除该快照?

    ", mask: true, ok: { callback: () => { console.log("删除:", item["key"]); db.delete(item["key"]).then( (resolve) => { if (resolve["code"] !== 200) { popup2.toast({ text: resolve["msg"], }); popup2.confirm_close(); return; } customCollectionData.forEach((_item_, _index_) => { if (_item_["key"] === item["key"]) { customCollectionData.splice(_index_, 1); } }); console.log("移出后:", customCollectionData); popup2.toast({ text: "删除成功", }); var parentDOM = Utils.findParentDOM(_this, (dom) => { return dom.localName === "tr" ? true : false; }); $jq(parentDOM)?.next()?.remove(); parentDOM?.remove(); popup2.confirm_close(); }, (err) => { console.log(err); popup2.confirm_close(); popup2.toast({ text: "删除失败,原因请看控制台", }); } ); }, }, only: true, }); }); $jq(".msgcon #autolist").append(itemElement); }); } else { } }), (err) => { console.log(err); }; } function insertLeftButton() { /* 插入左边按钮 */ var collectLeftBtnElement = $jq(`
  • 查看快照
  • `); collectLeftBtnElement.find("a").on("click", function () { showView(); }); $jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append( collectLeftBtnElement ); } function insertTopButton() { /* 插入帖子内部快照按钮 */ var collectPageBtnElement = $jq( `
  • 快照
  • ` ); collectPageBtnElement.find("a").on("click", function () { $jq(".comiis_share_box_close")?.click(); popup2.mask_loading_show(); popup2.toast({ text: "正在处理网页转base64图片中", }); var pageHTML = document.documentElement; var html2canvasOptions = { allowTaint: true, logging: true, useCORS: true, ignoreElements: (element) => { /*遍历每个节点*/ if ( element.id === "comiis_bgbox" /* 点击右上角三个按钮的背景遮罩层 */ || element.id === "comiis_foot_more" /* 点击右上角三个按钮后出现的菜单栏 */ || element.id === "force-mask" /* popup2的遮罩层 */ || element.className === "popup2-toast" /* toast弹窗 */ || element.id === "comiis_foot_menu_beautify" /* 底部回复框 */ || element.id === "comiis_head" /* 顶部一栏 */ ) return true; }, }; html2canvas(pageHTML, html2canvasOptions).then((canvas) => { var base64Image = canvas.toDataURL("image/png"); popup2.toast({ text: "转换完毕,正在保存数据", }); var data = { type: "image", url: window.location.href, title: document.title.replace(" - MT论坛", ""), data: base64Image, time: Utils.getFormatTime("yyyy-MM-dd HH:mm:ss", collectTime), timestamp: collectTime, }; db.save(DB_STORE_KEY_NAME, data).then((resolve) => { console.log(resolve); if (resolve["code"] !== 200) { console.log(resolve); popup2.mask_close(); popup2.toast({ text: resolve["msg"], }); return; } popup2.mask_close(); popup2.toast({ text: "保存成功", }); }), (err) => { console.log(err); popup2.mask_close(); popup2.toast({ text: "保存数据失败", }); }; }); }); $jq("#comiis_foot_gobtn .comiis_shareul.swiper-wrapper").append( collectPageBtnElement ); } if (urlBBSMatchStatus) { console.log("插入查看快照按钮"); insertLeftButton(); } if (forumPostMatchStatus) { insertTopButton(); } }, editorChartBed() { /* 编辑器的图床 */ function chartbedByMT() { /* 论坛图床-修复点击上传和点击插入功能 */ GM_addStyle(` #imglist .p_img a{ float: left; height: 36px; } #imglist .del a{ padding: 0; } `); $jq("#imglist .up_btn").append($jq("#filedata")); $jq(document).on("click", "#imglist .up_btn a", function (e) { $jq(this).next().click(); }); $jq(document).on("click", "#imglist .p_img a", function (e) { let obj = $jq(this); if (obj.attr("onclick") == null) { let img_id = obj.find("img").attr("id").replace("aimg_", ""); comiis_addsmilies("[attachimg]" + img_id + "[/attachimg]"); } }); } function chartbedByKggzs() { /* 编辑器图片上传 康哥图床 */ GM_addStyle(` #imglist_kggzs .delImg{ position: absolute; top: -5px; left: -5px; } `); let chartBedUrl = "https://img.kggzs.cn/api/v1"; let chartBedUser = GM_getValue("KggzsChartBedUser"); let chartBedPwd = GM_getValue("KggzsChartBedPwd"); let chartBedToken = null; let code = { 401: "未登录或授权失败", 403: "管理员关闭了接口功能", 429: "超出请求配额,请求受限", 500: "服务端出现异常", }; function getToken() { return new Promise((res) => { let formData = new FormData(); formData.append("email", chartBedUser); formData.append("password", chartBedPwd); GM_xmlhttpRequest({ url: `${chartBedUrl}/tokens`, method: "POST", data: formData, headers: { Accept: "application/json", }, onload: (r) => { if (code[r.status] != null) { popup2.toast(code[r.status]); res(null); return; } let json_data = JSON.parse(r.responseText); if (json_data["status"]) { popup2.toast("token成功获取"); res(json_data["data"]["token"]); } else { popup2.toast(json_data["message"]); res(null); } }, onerror: () => { popup2.toast("网络异常"); res(null); }, }); }); } function uploadImage(imageFile) { let res_data = { imageUri: null, json_data: null, }; let form = new FormData(); form.append("strategy_id", 2); /* 存储策略 */ form.append("file", imageFile); return new Promise((res) => { GM_xmlhttpRequest({ url: `${chartBedUrl}/upload`, method: "POST", data: form, async: false, responseType: "json", headers: { Accept: "application/json", "User-Agent": Utils.getRandomPCUA(), Authorization: `Bearer ${chartBedToken}`, }, onload: (r) => { if (code[r.status] != null) { popup2.toast(code[r.status]); res(res_data); return; } if (r.responseText.match("502 Bad Gateway")) { popup2.toast("获取返回结果502失败"); res(res_data); return; } let json_data = JSON.parse(r.responseText); console.log(json_data); if (json_data["status"]) { popup2.toast("上传成功"); let file_reader = new FileReader(); /* FileReader主要用于将文件内容读入内存,通过一系列异步接口,可以在主线程中访问本地文件 */ file_reader.readAsDataURL( imageFile ); /* 读取图片的内容生成的base64编码的图 */ /* 读取完成后,执行该回调函数,它会返回读取的结果result */ file_reader.onload = function () { let imageUri = this.result; /* 此时的图片已经存储到了result中 */ res_data["imageUri"] = imageUri; res_data["json_data"] = json_data; res(res_data); }; } else { console.log(json_data); popup2.toast(json_data["message"]); res(res_data); } }, onerror: (r) => { popup2.toast("网络异常"); res(res_data); }, }); }); } function deleteImage(imageKey) { return new Promise((res) => { GM_xmlhttpRequest({ url: `${chartBedUrl}/images/:${imageKey}`, method: "DELETE", async: false, data: JSON.stringify({ key: "", }), responseType: "json", headers: { Accept: "application/json", "User-Agent": Utils.getRandomPCUA(), Authorization: `Bearer ${chartBedToken}`, }, onload: (r) => { if (code[r.status] != null) { popup2.toast(code[r.status]); res(res_data); return; } let json_data = JSON.parse(r.responseText); console.log(json_data); }, onerror: (r) => { popup2.toast("网络异常"); res(res_data); }, }); }); } function clearData() { chartBedUser = ""; chartBedPwd = ""; chartBedToken = null; GM_deleteValue("KggzsChartBedUser"); GM_deleteValue("KggzsChartBedPwd"); } function checkLogin() { return new Promise(async (res) => { if (!chartBedUser || !chartBedPwd) { let loginCallBack = () => { let user = $jq("#chartbed_user").val().trim(); let pwd = $jq("#chartbed_pwd").val().trim(); if (user && pwd) { GM_setValue("KggzsChartBedUser", user); GM_setValue("KggzsChartBedPwd", pwd); chartBedUser = user; chartBedPwd = pwd; popup2.toast("设置完毕,请重新点击"); popup2.confirm_close(); res(false); } else { popup2.toast("账号或密码不能为空"); } }; mobile.chartBed.popupUserPwd( "康哥图床", "https://img.kggzs.cn/register", loginCallBack ); } else if (chartBedToken == null) { popup2.mask_loading_show(); popup2.toast("正在配置token"); chartBedToken = await getToken(); popup2.mask_close(); console.log("token:" + chartBedToken); if (chartBedToken != null) { res(true); } else { clearData(); res(false); } } else { res(false); } }); } $jq(document).on( "click", "#imglist_kggzs .up_btn a", async function () { $jq("#filedata_kggzs").val(""); $jq("#filedata_kggzs").click(); } ); $jq(document).on("change", "#filedata_kggzs", async (e) => { let chooseImageFiles = e.currentTarget.files; if (chooseImageFiles.length == 0) { return; } let needUploadImageArray = []; let needUploadImageFileArray = []; let uploadFileAwaitFunction = async (params) => { let imageFile = chooseImageFiles[params[0]]; let uploadImageReturn = await uploadImage(imageFile); if (uploadImageReturn["json_data"] != null) { console.log(uploadImageReturn); let image_id_encoded = uploadImageReturn["json_data"]["data"]["key"]; let image_url = uploadImageReturn["json_data"]["data"]["links"]["url"]; let image_thumb_url = uploadImageReturn["json_data"]["data"]["links"][ "thumbnail_url" ]; let image_name = uploadImageReturn["json_data"]["data"]["origin_name"]; let image_uri = uploadImageReturn["imageUri"]; let uploadImageHTML = `
  • 插入
  • `; $jq("#imglist_kggzs").append($jq(uploadImageHTML)); mobile.chartBed.storage.add( "kggzs", image_id_encoded, image_url, image_thumb_url, image_name ); } }; let completeFunction = () => { popup2.mask_close(); $jq("#filedata_kggzs").val(""); }; let waterMarkAwaitFunction = async () => { popup2.mask_loading_show(); Promise.all( Array.from(chooseImageFiles).map(async (item, index) => { if (item.type === "image/gif") { /* 不支持对GIF添加水印 */ let image_base64 = await Utils.asyncFileToBase64(item); needUploadImageArray = needUploadImageArray.concat(image_base64); needUploadImageFileArray = needUploadImageFileArray.concat(item); } else { popup2.toast( `添加水印 ${index + 1}/${chooseImageFiles.length}` ); var watermark = new Watermark(); await watermark.setFile(item); watermark.addText({ text: [GM_getValue("chartBedWaterMarkText", "MT论坛")], fontSize: GM_getValue("chartBedWaterMarkFontSize"), color: GM_getValue("chartBedWaterMarkFontColor"), globalAlpha: GM_getValue("chartBedWaterGlobalAlpha"), rotateAngle: GM_getValue("chartBedWaterMarkRotationAngle"), xMoveDistance: GM_getValue("chartBedWaterXMoveDistance"), yMoveDistance: GM_getValue("chartBedWaterYMoveDistance"), }); needUploadImageArray = needUploadImageArray.concat( watermark.render("png") ); needUploadImageFileArray = needUploadImageFileArray.concat( Utils.base64ToFile( watermark.render("png"), "WaterMark_" + item.name ) ); } }) ).then(async () => { chooseImageFiles = needUploadImageFileArray; popup2.mask_close(); if (GM_getValue("chartBedWaterMarkAutoDefault")) { let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传水印图片中...请稍后"); console.log(`图片数量:${needUploadImageFileArray.length}`); Utils.asyncArrayForEach( needUploadImageFileArray, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); return null; } } let renderHTML = ""; Array.from(needUploadImageArray).forEach((item) => { renderHTML = renderHTML + ''; }); popup2.confirm({ text: `
    ${renderHTML}
    `, mask: true, only: true, ok: { text: "继续上传", callback: async () => { popup2.confirm_close(); let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传水印图片中...请稍后"); console.log( `图片数量:${needUploadImageFileArray.length}` ); Utils.asyncArrayForEach( needUploadImageFileArray, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); } }, }, other: { enable: true, text: "保存至本地", callback: () => { Array.from(needUploadImageFileArray).forEach( async (item, index) => { let base64Image = await Utils.asyncFileToBase64(item); Utils.downloadBase64(item.name, base64Image); } ); }, }, }); }); }; if (GM_getValue("chartBedAddWaterMark")) { Utils.tryCatch(waterMarkAwaitFunction); } else { let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传图片中...请稍后"); console.log(`图片数量:${chooseImageFiles.length}`); Utils.asyncArrayForEach( chooseImageFiles, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); } } }); $jq(document).on("click", "#imglist_kggzs .delImg", async (e) => { e.preventDefault(); e.currentTarget.parentElement.remove(); /* popup2.toast('删除中,请稍后'); let id_encoded = e.currentTarget.getAttribute("id-encode"); if(!id_encoded){ popup2.toast('获取id_encoded失败,请自行去Hello图床删除'); return; } let deleteStatus = await deleteImage(key); if(deleteStatus){ e.currentTarget.parentElement.remove(); mobile.chartBed.storage.delete("kggzs",id_encoded); } */ }); } function chartbedByHello() { /* 编辑器图片上传Hello图床 */ GM_addStyle(` #imglist_hello .delImg{ position: absolute; top: -5px; left: -5px; } `); let chartBedUrl = "https://www.helloimg.com"; let chartBedUser = GM_getValue("HelloChartBedUser"); let chartBedPwd = GM_getValue("HelloChartBedPwd"); let chartBedAuthToken = null; let loginStatus = false; /* 登录状态 */ let clearData = () => { GM_deleteValue("HelloChartBedUser"); GM_deleteValue("HelloChartBedPwd"); loginStatus = false; chartBedUser = ""; chartBedPwd = ""; chartBedAuthToken = null; }; function checkLogin() { return new Promise(async (res) => { if (!chartBedUser || !chartBedPwd) { let loginCallBack = () => { let user = $jq("#chartbed_user").val().trim(); let pwd = $jq("#chartbed_pwd").val().trim(); if (user && pwd) { GM_setValue("HelloChartBedUser", user); GM_setValue("HelloChartBedPwd", pwd); chartBedUser = user; chartBedPwd = pwd; popup2.toast("设置完毕,请重新点击"); popup2.confirm_close(); res(false); } else { popup2.toast("账号或密码不能为空"); } }; mobile.chartBed.popupUserPwd( "Hello图床", "https://www.helloimg.com/signup", loginCallBack ); } else if (chartBedAuthToken == null && !loginStatus) { popup2.mask_loading_show(); popup2.toast("正在配置auth_token"); chartBedAuthToken = await mobile.chartBed.getAuthToken( chartBedUrl ); console.log("auth_token:" + chartBedAuthToken); if (chartBedAuthToken != null) { popup2.toast("正在登录Hello图床"); let retloginStatus = await mobile.chartBed.login( chartBedUrl, chartBedUser, chartBedPwd, chartBedAuthToken ); popup2.mask_close(); if (retloginStatus) { loginStatus = true; res(true); return; } else { clearData(); res(false); return; } } popup2.mask_close(); res(false); } else { res(false); } }); } $jq(document).on( "click", "#imglist_hello .up_btn a", async function () { $jq("#filedata_hello").val(""); $jq("#filedata_hello").click(); } ); $jq(document).on("change", "#filedata_hello", async (e) => { let chooseImageFiles = e.currentTarget.files; if (chooseImageFiles.length == 0) { return; } let needUploadImageArray = []; let needUploadImageFileArray = []; let uploadFileAwaitFunction = async (params) => { let imageFile = chooseImageFiles[params[0]]; let uploadImageReturn = await mobile.chartBed.uploadImage( chartBedUrl, chartBedAuthToken, imageFile ); if (uploadImageReturn["json_data"] != null) { let image_id_encoded = uploadImageReturn["json_data"]["image"]["id_encoded"]; let image_url = uploadImageReturn["json_data"]["image"]["url"]; let image_thumb_url = uploadImageReturn["json_data"]["image"]["thumb"]["url"]; let image_name = uploadImageReturn["json_data"]["image"]["filename"]; let image_uri = uploadImageReturn["imageUri"]; let uploadImageHTML = `
  • 插入
  • `; $jq("#imglist_hello").append($jq(uploadImageHTML)); mobile.chartBed.storage.add( "hello", image_id_encoded, image_url, image_thumb_url, image_name ); } }; let completeFunction = () => { popup2.mask_close(); $jq("#filedata_hello").val(""); }; let waterMarkAwaitFunction = async () => { popup2.mask_loading_show(); Promise.all( Array.from(chooseImageFiles).map(async (item, index) => { if (item.type === "image/gif") { /* 不支持对GIF添加水印 */ let image_base64 = await Utils.asyncFileToBase64(item); needUploadImageArray = needUploadImageArray.concat(image_base64); needUploadImageFileArray = needUploadImageFileArray.concat(item); } else { popup2.toast( `添加水印 ${index + 1}/${chooseImageFiles.length}` ); var watermark = new Watermark(); await watermark.setFile(item); watermark.addText({ text: [GM_getValue("chartBedWaterMarkText", "MT论坛")], fontSize: GM_getValue("chartBedWaterMarkFontSize"), color: GM_getValue("chartBedWaterMarkFontColor"), globalAlpha: GM_getValue("chartBedWaterGlobalAlpha"), rotateAngle: GM_getValue("chartBedWaterMarkRotationAngle"), xMoveDistance: GM_getValue("chartBedWaterXMoveDistance"), yMoveDistance: GM_getValue("chartBedWaterYMoveDistance"), }); needUploadImageArray = needUploadImageArray.concat( watermark.render("png") ); needUploadImageFileArray = needUploadImageFileArray.concat( Utils.base64ToFile( watermark.render("png"), "WaterMark_" + item.name ) ); } }) ).then(async () => { chooseImageFiles = needUploadImageFileArray; popup2.mask_close(); if (GM_getValue("chartBedWaterMarkAutoDefault")) { let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传水印图片中...请稍后"); console.log(`图片数量:${needUploadImageFileArray.length}`); Utils.asyncArrayForEach( needUploadImageFileArray, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); return null; } } let renderHTML = ""; Array.from(needUploadImageArray).forEach((item) => { renderHTML = renderHTML + ''; }); popup2.confirm({ text: `
    ${renderHTML}
    `, mask: true, only: true, ok: { text: "继续上传", callback: async () => { popup2.confirm_close(); let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传水印图片中...请稍后"); console.log( `图片数量:${needUploadImageFileArray.length}` ); Utils.asyncArrayForEach( needUploadImageFileArray, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); } }, }, other: { enable: true, text: "保存至本地", callback: () => { Array.from(needUploadImageFileArray).forEach( async (item, index) => { let base64Image = await Utils.asyncFileToBase64(item); Utils.downloadBase64(item.name, base64Image); } ); }, }, }); }); }; if (GM_getValue("chartBedAddWaterMark")) { Utils.tryCatch(waterMarkAwaitFunction); } else { let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传图片中...请稍后"); console.log(`图片数量:${chooseImageFiles.length}`); Utils.asyncArrayForEach( chooseImageFiles, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); } } }); $jq(document).on("click", "#imglist_hello .delImg", async function (e) { e.preventDefault(); popup2.mask_loading_show(); popup2.toast("删除中,请稍后"); let id_encoded = e.currentTarget.getAttribute("id-encode"); if (!id_encoded) { popup2.mask_close(); popup2.toast("获取id_encoded失败,请自行去Hello图床删除"); return; } let deleteStatus = await mobile.chartBed.deleteImage( chartBedUrl, chartBedAuthToken, id_encoded ); popup2.mask_close(); if (deleteStatus) { $jq(this).parent().remove(); mobile.chartBed.storage.delete("hello", id_encoded); } }); } function chartbedByZ4a() { /* 编辑器图片上传z4a图床 */ GM_addStyle(` #imglist_z4a .delImg{ position: absolute; top: -5px; left: -5px; } `); let chartBedUrl = "https://www.z4a.net"; let chartBedUser = GM_getValue("Z4AChartBedUser"); let chartBedPwd = GM_getValue("Z4AChartBedPwd"); let chartBedAuthToken = null; let loginStatus = false; /* 登录状态 */ let clearData = () => { GM_deleteValue("Z4AChartBedUser"); GM_deleteValue("Z4AChartBedPwd"); loginStatus = false; chartBedUser = ""; chartBedPwd = ""; chartBedAuthToken = null; }; function checkLogin() { return new Promise(async (res) => { if (!chartBedUser || !chartBedPwd) { let loginCallBack = () => { let user = $jq("#chartbed_user").val().trim(); let pwd = $jq("#chartbed_pwd").val().trim(); if (user && pwd) { GM_setValue("Z4AChartBedUser", user); GM_setValue("Z4AChartBedPwd", pwd); chartBedUser = user; chartBedPwd = pwd; popup2.toast("设置完毕,请重新点击"); popup2.confirm_close(); res(false); } else { popup2.toast("账号或密码不能为空"); } }; mobile.chartBed.popupUserPwd( "Z4A图床", "https://www.z4a.net/signup", loginCallBack ); } else if (chartBedAuthToken == null && !loginStatus) { popup2.mask_loading_show(); popup2.toast("正在配置auth_token"); chartBedAuthToken = await mobile.chartBed.getAuthToken( chartBedUrl ); console.log("auth_token:" + chartBedAuthToken); if (chartBedAuthToken != null) { popup2.toast("正在登录Z4A图床"); let retloginStatus = await mobile.chartBed.login( chartBedUrl, chartBedUser, chartBedPwd, chartBedAuthToken ); popup2.mask_close(); if (retloginStatus) { console.log("登录成功"); loginStatus = true; res(true); return; } else { clearData(); res(false); return; } } popup2.mask_close(); res(false); } else { res(false); } }); } $jq(document).on("click", "#imglist_z4a .up_btn a", async function (e) { $jq("#filedata_z4a").val(""); $jq("#filedata_z4a").click(); }); $jq(document).on("change", "#filedata_z4a", async (e) => { let chooseImageFiles = e.currentTarget.files; if (chooseImageFiles.length == 0) { return; } let needUploadImageArray = []; let needUploadImageFileArray = []; let uploadFileAwaitFunction = async (params) => { let imageFile = chooseImageFiles[params[0]]; let uploadImageReturn = await mobile.chartBed.uploadImage( chartBedUrl, chartBedAuthToken, imageFile ); if (uploadImageReturn["json_data"] != null) { let image_id_encoded = uploadImageReturn["json_data"]["image"]["id_encoded"]; let image_url = uploadImageReturn["json_data"]["image"]["url"]; let image_thumb_url = uploadImageReturn["json_data"]["image"]["thumb"]["url"]; let image_name = uploadImageReturn["json_data"]["image"]["filename"]; let image_uri = uploadImageReturn["imageUri"]; let uploadImageHTML = `
  • 插入
  • `; $jq("#imglist_z4a").append($jq(uploadImageHTML)); mobile.chartBed.storage.add( "z4a", image_id_encoded, image_url, image_thumb_url, image_name ); } }; let completeFunction = () => { popup2.mask_close(); $jq("#filedata_z4a").val(""); }; let waterMarkAwaitFunction = async () => { popup2.mask_loading_show(); Promise.all( Array.from(chooseImageFiles).map(async (item, index) => { if (item.type === "image/gif") { /* 不支持对GIF添加水印 */ let image_base64 = await Utils.asyncFileToBase64(item); needUploadImageArray = needUploadImageArray.concat(image_base64); needUploadImageFileArray = needUploadImageFileArray.concat(item); } else { popup2.toast( `添加水印 ${index + 1}/${chooseImageFiles.length}` ); var watermark = new Watermark(); await watermark.setFile(item); watermark.addText({ text: [GM_getValue("chartBedWaterMarkText", "MT论坛")], fontSize: GM_getValue("chartBedWaterMarkFontSize"), color: GM_getValue("chartBedWaterMarkFontColor"), globalAlpha: GM_getValue("chartBedWaterGlobalAlpha"), rotateAngle: GM_getValue("chartBedWaterMarkRotationAngle"), xMoveDistance: GM_getValue("chartBedWaterXMoveDistance"), yMoveDistance: GM_getValue("chartBedWaterYMoveDistance"), }); needUploadImageArray = needUploadImageArray.concat( watermark.render("png") ); needUploadImageFileArray = needUploadImageFileArray.concat( Utils.base64ToFile( watermark.render("png"), "WaterMark_" + item.name ) ); } }) ).then(async () => { chooseImageFiles = needUploadImageFileArray; popup2.mask_close(); if (GM_getValue("chartBedWaterMarkAutoDefault")) { let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传水印图片中...请稍后"); console.log(`图片数量:${needUploadImageFileArray.length}`); Utils.asyncArrayForEach( needUploadImageFileArray, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); return null; } } let renderHTML = ""; Array.from(needUploadImageArray).forEach((item) => { renderHTML = renderHTML + ''; }); popup2.confirm({ text: `
    ${renderHTML}
    `, mask: true, only: true, ok: { text: "继续上传", callback: async () => { popup2.confirm_close(); let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传水印图片中...请稍后"); console.log( `图片数量:${needUploadImageFileArray.length}` ); Utils.asyncArrayForEach( needUploadImageFileArray, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); } }, }, other: { enable: true, text: "保存至本地", callback: () => { Array.from(needUploadImageFileArray).forEach( async (item, index) => { let base64Image = await Utils.asyncFileToBase64(item); Utils.downloadBase64(item.name, base64Image); } ); }, }, }); }); }; if (GM_getValue("chartBedAddWaterMark")) { Utils.tryCatch(waterMarkAwaitFunction); } else { let login_status = await checkLogin(); if (login_status) { popup2.mask_loading_show(); popup2.toast("上传图片中...请稍后"); console.log(`图片数量:${chooseImageFiles.length}`); Utils.asyncArrayForEach( chooseImageFiles, uploadFileAwaitFunction ).then(() => { Utils.tryCatch(completeFunction); }); } } }); $jq(document).on("click", "#imglist_z4a .delImg", async function (e) { e.preventDefault(); popup2.mask_loading_show(); popup2.toast("删除中,请稍后"); let id_encoded = e.currentTarget.getAttribute("id-encode"); if (!id_encoded) { popup2.toast("获取id_encoded失败,请自行去Z4A图床删除"); return; } let deleteStatus = await mobile.chartBed.deleteImage( chartBedUrl, chartBedAuthToken, id_encoded ); popup2.mask_close(); if (deleteStatus) { $jq(this).parent().remove(); mobile.chartBed.storage.delete("z4a", id_encoded); } }); } function chartbedByHistory() { /* 所有图床历史上传过的图片 */ GM_addStyle(` .comiis_post_imglist li .delImg { position: absolute; top: -5px; left: -5px; } `); if (GM_getValue("chartBedsImagesHistory") == undefined) { GM_setValue("chartBedsImagesHistory", []); } let historyImages = mobile.chartBed.storage.get(); let isAdd = false; if (historyImages == []) { return; } $jq(document).on("click", "#comiis_pictitle_tab_n_5", function (e) { if (isAdd) { $jq(document).off("click", "#comiis_pictitle_tab_n_5"); return; } isAdd = true; $jq.each(historyImages, (i) => { let _web = historyImages[i]["web"]; let _url = historyImages[i]["url"]; let _thumb_url = historyImages[i]["thumb_url"]; let _name = historyImages[i]["name"]; let _imageHTML = `
  • ${_web}
  • `; $jq("#imglist_history").append($jq(_imageHTML)); }); }); $jq(document).on("click", "#imglist_history .delImg", (e) => { e.preventDefault(); let _t_index = e.currentTarget.getAttribute("t-index"); let imageItem = historyImages[_t_index]; let web = imageItem["web"]; let id_encoded = imageItem["id_encoded"]; e.currentTarget.parentElement.remove(); mobile.chartBed.storage.delete(web, id_encoded); }); } let imgBtn = `图片`; let menu = ` `; GM_addStyle(` #filedata, #filedata_kggzs, #filedata_hello, #filedata_z4a{ display: none; } .comiis_tip dt p{ padding: 10px 0px; } .upload-image-water{ overflow-y: auto; } .upload-image-water img{ width: 100%; margin: 10px 0px; } `); let jqMenu = $jq(menu); jqMenu .find(".comiis_upbox.comiis_allowpostimg") .append( $jq( ".comiis_wzpost.comiis_input_style .comiis_upbox.comiis_allowpostimg" ).children() ); $jq(".swiper-wrapper.comiis_post_ico").append(imgBtn); $jq("#comiis_post_tab").append(jqMenu); Utils.tryCatch(chartbedByMT); Utils.tryCatch(chartbedByKggzs); Utils.tryCatch(chartbedByHello); Utils.tryCatch(chartbedByZ4a); Utils.tryCatch(chartbedByHistory); }, editorOptimization() { /* 编辑器优化-简略 */ if ( !GM_getValue("v49") || !window.location.href.match(mt_config.rexp.forum_post) ) { return; } GM_addStyle(` #comiis_foot_menu_beautify{ position: fixed; display: inline-flex; z-index: 90; left: 0; right: 0; bottom: 0; width: 100%; height: 48px; overflow: hidden; align-content: center; justify-content: center; align-items: center; } #comiis_foot_menu_beautify_big{ position: fixed; display: inline-flex; flex-direction: column; z-index: 90; left: 0; right: 0; bottom: 0; width: 100%; min-height: 120px; overflow: hidden; align-content: center; justify-content: center; align-items: center; } #comiis_foot_menu_beautify input.bg_e.f_c::-webkit-input-placeholder { padding-left:10px; color:#999999; } #comiis_foot_menu_beautify .reply_area ul li a{ display: block; width: 22px; height: 22px; padding: 4px 8px; margin: 8px 0; position: relative; } #comiis_foot_menu_beautify .reply_area ul{ display: inline-flex; align-content: center; align-items: center; justify-content: center; } #comiis_foot_menu_beautify .reply_area, #comiis_foot_menu_beautify .reply_area ul{ width: 100%; } #comiis_foot_menu_beautify .reply_area li a i { width: 22px; height: 22px; line-height: 22px; font-size: 22px; } #comiis_foot_menu_beautify .reply_area li a span { position: absolute; display: block; font-size: 10px; height: 14px; line-height: 14px; padding: 0 6px; right: -8px; top: 4px; overflow: hidden; border-radius: 20px; } #comiis_foot_menu_beautify li[data-attr="回帖"] input{ border: transparent; border-radius: 15px; height: 30px; width: 100%; } #comiis_foot_menu_beautify_big .reply_area{ margin: 10px 0px 5px 0px; } #comiis_foot_menu_beautify_big .reply_area ul{ display: inline-flex; align-content: center; justify-content: center; align-items: flex-end; } #comiis_foot_menu_beautify_big li[data-attr="回帖"]{ width: 75vw; margin-right: 15px; } #comiis_foot_menu_beautify_big .reply_user_content{ width: 75vw; word-wrap: break-word; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 8px 10px; } #comiis_foot_menu_beautify_big li[data-attr="发表"]{ } #comiis_foot_menu_beautify_big li[data-attr="发表"] .fastpostform_new{ text-align: center; margin-bottom: 28px; } #comiis_foot_menu_beautify_big li[data-attr="发表"] .fastpostform_new i{ font-size: 22px; } #comiis_foot_menu_beautify_big li[data-attr="发表"] input{ width: 60px; height: 30px; border: transparent; color: #ffffff; background: #d1c9fc; border-radius: 30px; margin-bottom: 6px; } #comiis_foot_menu_beautify_big li[data-attr="发表"] input[data-text='true']{ background: #7a61fb; } #comiis_foot_menu_beautify_big li[data-attr="回帖"] textarea{ padding: 10px 10px 10px 10px; border: transparent; border-radius: 6px; min-height: 70px; max-height: 180px; background: #e9e8ec; overflow-y: auto; width: -webkit-fill-available; } #comiis_foot_menu_beautify .reply_area li[data-attr="回帖"]{ width: 65%; margin: 0px 3%; text-align: center; } #comiis_foot_menu_beautify .reply_area li:not(first-child){ width: 7%; text-align: -webkit-center; text-align: center; } #comiis_foot_menu_beautify_big .other_area{ width: 100%; text-align: center; } #comiis_foot_menu_beautify_big .other_area .menu_icon a{ margin: 0px 20px; } #comiis_foot_menu_beautify_big .other_area i{ font-size: 24px; } #comiis_foot_menu_beautify_big .other_area #comiis_insert_ubb_tab i{ font-size: 16px; } #comiis_foot_menu_beautify_big .other_area .menu_body{ background: #f4f4f4; } #comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .comiis_optimization{ max-height: 140px; overflow-y: auto; flex-direction: column; } #comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .bqbox_t{ background: #fff; } #comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .bqbox_t ul#comiis_smilies_key li a.bg_f.b_l.b_r{ background: #f4f4f4 !important; } #comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #comiis_pictitle_key{ display: -webkit-box; top: 0px; left: 0px; height: 42px; line-height: 42px; overflow: hidden; overflow-x: auto; } #comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #comiis_pictitle_key li{ padding: 0px 10px; } #comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab .comiis_upbox, #comiis_foot_menu_beautify_big .menu_body #comiis_insert_ubb_tab .comiis_input_style{ height: 140px; overflow-y: auto; flex-direction: column; } #comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_kggzs, #comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_hello, #comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_z4a{ display:none; } `); let pl = $jq("#comiis_foot_memu .comiis_flex li")[1]; let dz = $jq("#comiis_foot_memu .comiis_flex li")[2]; let sc = $jq("#comiis_foot_memu .comiis_flex li")[3]; let form_action = $jq("#fastpostform").attr("action"); let form_serialize = $jq("#fastpostform").serialize(); let form_url = $jq("#fastpostform .header_y a").attr("href"); $jq("#needmessage[name='message']").remove(); $jq("#imglist").remove(); $jq("#fastpostsubmitline").remove(); $jq("#fastpostsubmit").remove(); $jq("#comiis_foot_memu").hide(); $jq("#comiis_foot_memu").after( $jq(`
    • ${pl.innerHTML}
    • ${dz.innerHTML}
    • ${sc.innerHTML}
    `, app: true, success: async (x) => { let localDataUser = lanzou.storage.getUser(); let localDataPwd = lanzou.storage.getPwd(); if (localDataUser != "" && localDataPwd != "") { x.xtipdiv.querySelector(".xinput.xful[type='text']").value = localDataUser; x.xtipdiv.querySelector(".xinput.xful[type='password']").value = localDataPwd; } x.xtipdiv.querySelector(".xbutton.xful.xblue").onclick = async () => { let inputUser = x.xtipdiv .querySelector(".xinput.xful[type='text']") .value.trim(); let inputPwd = x.xtipdiv .querySelector(".xinput.xful[type='password']") .value.trim(); if (inputUser != "" && inputPwd != "") { xtips.toast("登录中请稍后..."); let _formhash_ = await lanzou.login_getFormHash( inputUser, inputPwd ); console.log(_formhash_); if (_formhash_ == 4) { console.log("已登录"); lanzou.storage.setUser(inputUser); lanzou.storage.setPwd(inputPwd); if (lanzou.storage.getFormhash() == null) { console.log( "未知原因,已登录但本地未保存formhash,建立临时值" ); lanzou.storage.setFormhash(_formhash_); } xtip.close(x.mainid); showView(); return; } if (_formhash_ == null) { return; } let loginStatus = await lanzou.login( inputUser, inputPwd, _formhash_ ); if (loginStatus) { console.log("登录成功"); console.log(inputUser, inputPwd, _formhash_); lanzou.storage.setUser(inputUser); lanzou.storage.setPwd(inputPwd); lanzou.storage.setFormhash(_formhash_); xtip.close(x.mainid); showView(); } } else { xtips.toast("账号或密码不能为空"); } }; }, }); } async function showLanZouView(user, pwd) { lanZouViewShowLock = false; let sheet = null; let _formhash_ = lanzou.storage.getFormhash(); let loginStatus = await lanzou.login(user, pwd, _formhash_); if (!loginStatus) { xtips.toast("登录过期"); lanzou.storage.delFormhash(); showLoginView(); return; } sheet = xtip.sheet({ btn: [ `欢迎! ${user}`, '上传', "查看历史上传", ], }); $jq("#lanzouuploadfilebtn") .off("change") .change(async (e) => { let lanzouChooseFile = e.currentTarget.files[0]; console.log(lanzouChooseFile); let uploadFileInfo = await lanzou.uploadFile(lanzouChooseFile); if (uploadFileInfo) { let tempData = lanzou.storage.getUploadFiles(); tempData = tempData.concat(uploadFileInfo); GM_setClipboard( `${uploadFileInfo["is_newd"]}/${uploadFileInfo["f_id"]}` ); xtips.toast("已复制到剪贴板"); console.log(tempData); lanzou.storage.setUploadFiles(tempData); } }); let anyTouchNode = new AnyTouch(document.getElementById(sheet)); anyTouchNode.on("tap", (e) => { if ( document .getElementById(sheet) .querySelector(".xtiper_bg") .outerHTML.indexOf(e.target.outerHTML) != -1 ) { /* 点击背景不关闭小窗 */ return; } if ( document .querySelectorAll( ".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li" )[0] .outerHTML.indexOf(e.target.outerHTML) != -1 ) { /* 用户 */ xtip.confirm("确定退出登录吗?", { btn1: async function () { let logoutStatus = await lanzou.outLogin( lanzou.storage.getUser() ); if (logoutStatus) { xtips.toast("退出登录成功"); lanzou.storage.delFormhash(); anyTouchNode.off("tap"); xtip.close(sheet); lanZouViewShowLock = false; } else { xtips.toast("退出登录失败"); } }, }); return; } if ( document .querySelectorAll( ".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li" )[1] .outerHTML.indexOf(e.target.outerHTML) != -1 ) { /* 上传 */ $jq("#lanzouuploadfilebtn").val(""); $jq("#lanzouuploadfilebtn").click(); return; } if ( document .querySelectorAll( ".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li" )[2] .outerHTML.indexOf(e.target.outerHTML) != -1 ) { /* 查看历史上传 */ anyTouchNode.off("tap"); xtip.close(sheet); showUploadFiles(); return; } if ( document .querySelectorAll( ".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li" )[3] .outerHTML.indexOf(e.target.outerHTML) != -1 ) { /* 取消 */ anyTouchNode.off("tap"); xtip.close(sheet); lanZouViewShowLock = false; return; } }); } async function showView() { let user = lanzou.storage.getUser(); let pwd = lanzou.storage.getPwd(); let formhash = lanzou.storage.getFormhash(); if (user == "" || pwd == "" || formhash == null) { showLoginView(); } else { showLanZouView(user, pwd); } } function insertBtn() { let comiis_left_Touch = document.createElement("li"); comiis_left_Touch.className = "comiis_left_Touch"; let ANode = document.createElement("a"); ANode.setAttribute("href", "javascript:;"); ANode.className = "blacklist"; ANode.innerHTML = `
    蓝奏云
    `; ANode.onclick = () => { if (!lanZouViewShowLock) { showView(); lanZouViewShowLock = true; } else { console.log("重复点击"); } }; comiis_left_Touch.append(ANode); $jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append( comiis_left_Touch ); } insertBtn(); }, async loadCheckboxTipResource() { /* 加载checkbox值变化的显示的提示的资源 */ await GM_asyncLoadScriptContent( "https://whitesev.gitee.io/static_resource/ios_loading/js/iosOverlay.js" ); await GM_asyncLoadStyleSheet( "https://whitesev.gitee.io/static_resource/ios_loading/css/iosOverlay.css" ); }, loadNextComments() { /* 加载下一页的评论 */ function autoLoadNextPageComments(post_comments_list) { /* 自动加载下一页的评论 */ $jq("#loading-comment-tip")[0].parentElement.style.display = ""; let next_page_url = post_comments_list.children[2].href; console.log("预设,获取下一页url:", next_page_url); if (next_page_url.indexOf("javascript:;") != -1) { console.log(post_comments_list); console.log("无多页评论"); $jq("#loading-comment-tip")[0].parentElement.style.display = "none"; return; } function _loadNextComments_() { return new Promise((res) => { $jq("#loading-comment-tip").text("正在加载评论中..."); $jq("#loading-comment-tip")[0].parentElement.style.display = ""; let _url_ = next_page_url; $jq.get(_url_, function (data, status, xhr) { console.log("正在请求的下一页url", _url_); let postlist = $jq(data); let kqideSourceNode = $jq(".comiis_postlist.kqide"); let postDOM = postlist.find(".comiis_postlist.kqide").html(); let get_next_page_url = postlist.find(".nxt"); if (get_next_page_url.length != 0) { console.log("成功获取到下一页-评论"); next_page_url = get_next_page_url.attr("href"); let newURL = new URL(_url_); let setLocationUrl = `${newURL.pathname}${newURL.search}`; console.log( "设置当前的url为请求的下一页url", window.location.origin + setLocationUrl ); if (window === top.window) { window.history.pushState("forward", null, setLocationUrl); } $jq("#loading-comment-tip")[0].parentElement.style.display = "none"; } else { console.log("评论全部加载完毕,关闭监听事件"); let newURL = new URL(next_page_url); let setLocationUrl = `${newURL.pathname}${newURL.search}`; console.log("设置当前的url为请求的最后一页url", setLocationUrl); if (window === top.window) { window.history.pushState("forward", null, setLocationUrl); } $jq(".comiis_page.bg_f").remove(); $jq("#loading-comment-tip").text("已加载完所有评论"); $jq("#loading-comment-tip")[0].parentElement.style.display = ""; $jq("#loading-comment-tip").off("click", _loadNextComments_); $jq(window).off("scroll", scroll_loadNextComments); } kqideSourceNode.append(postDOM); mobile.needRepeatLoadingJSResource(); res(); }); }); } var lock = new Utils.lockFunction(_loadNextComments_); function scroll_loadNextComments() { if ( Math.ceil($jq(window).scrollTop() + $jq(window).height() + 150) >= $jq(document).height() ) { /* load data */ lock.run(); } } $jq(window).on("scroll", scroll_loadNextComments); $jq("#loading-comment-tip").text("请上下滑动或点击加载"); $jq("#loading-comment-tip").on("click", _loadNextComments_); } if ( GM_getValue("v21") && window.location.href.match(mt_config.rexp.forum_post) && document.title.indexOf("提示信息 - MT论坛") == -1 ) { let tip_html = `
    `; $jq(".comiis_bodybox").append($jq(tip_html)); let commentsEle = document.querySelector(".comiis_pltit span.f_d") || document.querySelector("#comiis_foot_memu .comiis_kmvnum"); if ( document.querySelector(".comiis_pltit h2") && document .querySelector(".comiis_pltit h2") .textContent.indexOf("暂无评论") != -1 ) { console.log("暂无评论"); $jq("#loading-comment-tip")[0].parentElement.style.display = "none"; return; } let commentsNum = parseInt(commentsEle.textContent); if (commentsNum >= 10) { Utils.waitForDOM(".comiis_page.bg_f").then((next_page_dom) => { console.log("找到下一页元素!"); autoLoadNextPageComments(next_page_dom[0]); }); } else { console.log("无多页评论"); $jq("#loading-comment-tip")[0].parentElement.style.display = "none"; } } }, loadPrevComments() { /* 加载上一页的评论 */ function autoLoadPrevPageComments() { /* 自动加载上一页的评论 */ let post_comments_list = document.querySelector(".comiis_page.bg_f"); let prev_page_url = post_comments_list.children[0].href; console.log("预设,获取上一页url:", prev_page_url); $jq("#loading-comment-tip-prev").text("请上下滑动或点击加载"); $jq("#loading-comment-tip-prev").on("click", _loadPrevComments_); function _loadPrevComments_() { return new Promise((res) => { $jq("#loading-comment-tip-prev").text("正在加载评论中..."); $jq("#loading-comment-tip-prev")[0].parentElement.style.display = ""; let _url_ = prev_page_url; $jq.get(_url_, function (data, status, xhr) { console.log("正在请求的上一页评论:", prev_page_url); let postlist = $jq(data); let kqideSourceNode = $jq(".comiis_postlist.kqide"); let postDOM = postlist.find(".comiis_postlist.kqide").html(); let get_pregv_page_url = postlist.find(".prev"); if (get_pregv_page_url.length != 0) { console.log("成功获取到上一页-评论"); prev_page_url = get_pregv_page_url.attr("href"); let newURL = new URL(_url_); let setLocationUrl = `${newURL.pathname}${newURL.search}`; console.log( "设置当前的url为请求的上一页url", window.location.origin + setLocationUrl ); if (window === top.window) { window.history.pushState("forward", null, setLocationUrl); } $jq( "#loading-comment-tip-prev" )[0].parentElement.style.display = "none"; kqideSourceNode.prepend(postDOM); mobile.needRepeatLoadingJSResource(); } else { kqideSourceNode.prepend(postDOM); let newURL = new URL(prev_page_url); let setLocationUrl = `${newURL.pathname}${newURL.search}`; console.log( "已到顶页,设置当前的url第一页url", window.location.origin + setLocationUrl ); if (window === top.window) { window.history.pushState("forward", null, setLocationUrl); } console.log("上一页评论全部加载完毕,关闭监听事件"); let page_title = postlist.find(".comiis_viewtit")[0].outerHTML; console.log($jq(page_title)); kqideSourceNode.prepend($jq(page_title)[0]); mobile.needRepeatLoadingJSResource(); /* $jq(".comiis_page.bg_f").remove(); */ $jq("#loading-comment-tip-prev").remove(); $jq("#loading-comment-tip-prev").off( "click", _loadPrevComments_ ); $jq(window).off("scroll"); } res(); }); }); } function scroll_loadPrevComments() { if ($jq(window).scrollTop() <= 50) { lock.run(); } } var lock = new Utils.lockFunction(_loadPrevComments_); $jq(window).on("scroll", scroll_loadPrevComments); } if ( GM_getValue("v32") && window.location.href.match(mt_config.rexp.forum_post) && document.title.indexOf("提示信息 - MT论坛") == -1 ) { if (!document.querySelector(".comiis_pltit span.f_d")) { console.log("当前不在第一页,加载上一页评论"); let tip_html = `
    `; $jq(".comiis_bodybox script")[0].after($jq(tip_html)[0]); if ( document.querySelector(".comiis_pltit h2") && document .querySelector(".comiis_pltit h2") .textContent.indexOf("暂无评论") != -1 ) { console.log("暂无上一页评论"); $jq("#loading-comment-tip-prev")[0].parentElement.style.display = "none"; return; } autoLoadPrevPageComments(); } } }, main() { /* 手机版按顺序加载的函数 */ Utils.tryCatch(mobile.commentsAddReviews); Utils.tryCatch(mobile.recoveryIMGWidth); Utils.tryCatch(mobile.identifyLinks); Utils.tryCatch(mobile.showUserUID); Utils.tryCatch(mobile.previewPictures); Utils.tryCatch(mobile.removeForumPostFontStyle); Utils.tryCatch(mobile.removeForumPostCommentFontStyle); Utils.tryCatch(mobile.autoSignIn); Utils.tryCatch(mobile.autoExpendFullTextByForumPost); Utils.tryCatch(mobile.searchHistory); Utils.tryCatch( mobile.loadNextComments, "", '$jq("#loading-comment-tip").text("加载评论失败")' ); Utils.tryCatch( mobile.loadPrevComments, "", '$jq("#loading-comment-tip-prev").text("加载评论失败")' ); Utils.tryCatch(mobile.repairClearSearchInput); Utils.tryCatch(mobile.repairUnableToEnterOtherSpaceCorrectly); Utils.tryCatch(mobile.chatChartBed); Utils.tryCatch(mobile.pageSmallWindowBrowsingForumPost); Utils.tryCatch(mobile.codeQuoteCopyBtn); Utils.tryCatch(mobile.editorOptimization); Utils.tryCatch(mobile.editorOptimizationFull); Utils.tryCatch(mobile.shieldUser); Utils.tryCatch(mobile.shieldPlate); Utils.tryCatch(mobile.userCheckBoxSettings); /* 选项主要界面内容 */ Utils.tryCatch(mobile.blackHome.insertMobileBlackHomeButton); Utils.tryCatch(mobile.lanzouFunction); Utils.tryCatch(mobile.paymentSubjectReminder); Utils.tryCatch(mobile.blacklistShieldUsersOrBlocks); Utils.tryCatch(mobile.showTodayStar); Utils.tryCatch(mobile.showSignInRanking); Utils.tryCatch(mobile.setDynamicAvatar); Utils.tryCatch(mobile.pageAfterDOMChangeRunFunction); Utils.tryCatch(mobile.showSpaceContreteReply); Utils.tryCatch(mobile.showLatestPostForm); Utils.tryCatch(mobile.customCollection); unsafeWindow.popup2 = popup2; popup2.init(); }, needRepeatLoadingJSResource() { /* 帖子内需要重复执行的js */ Utils.tryCatch(mobile.shieldUser); Utils.tryCatch(mobile.commentsAddReviews); Utils.tryCatch(mobile.identifyLinks); Utils.tryCatch(mobile.showUserUID); Utils.tryCatch(mobile.previewPictures); Utils.tryCatch(mobile.pageSmallWindowBrowsingForumPost); Utils.tryCatch(mobile.codeQuoteCopyBtn); Utils.tryCatch( mobile.editorOptimizationOffDefaultBottomReplyBtnClickEvent ); Utils.tryCatch(mobile.removeForumPostCommentFontStyle); popup.init(); }, pageAfterDOMChangeRunFunction() { /* 当本页面动态加载帖子需要重复加载的东西 */ if ( window.location.href.match(/bbs.binmt.cc\/forum/) || window.location.href.match( /bbs.binmt.cc\/home.php\?mod=space&do=thread&view=me/ ) || window.location.href.match( /home.php\?mod=space&uid=.+&do=thread&view=me/ ) ) { function beforeHookRun() { Utils.tryCatch(mobile.showUserUID); Utils.tryCatch(mobile.previewPictures); Utils.tryCatch(mobile.shieldUser); Utils.tryCatch(mobile.shieldPlate); Utils.tryCatch(mobile.pageSmallWindowBrowsingForumPost); Utils.tryCatch(mobile.codeQuoteCopyBtn); } document.body.addEventListener("DOMNodeInserted", (event) => { let ele = event.target; if ( ele.className != null && ele.className.indexOf("comiis_forumlist") != -1 ) { beforeHookRun(); } }); } }, pageSmallWindowBrowsingForumPost() { /* 页面小窗浏览帖子 */ if ( !GM_getValue("v45") && !( window.location.href.match(mt_config.rexp.forum_guide_url) || !window.location.href.match(mt_config.rexp.search_url) ) ) { return; } /* if (window != top.window) { console.log("当前在非top里,已禁用初始化小窗"); return; } */ let small_icon_width = 24; let small_right_btn_width = 115; let small_title_width = "calc(100% - " + (small_icon_width + small_right_btn_width) + "px)"; GM_addStyle(` .xtiper_sheet, .xtiper_sheet .xtiper_sheet_tit{ border-radius: 18px 18px 0px 0px; } /* title自定义美化 */ .xtiper_sheet_tit.xtiper_sheet_left{ display: block; background: #fff; width: 100%; box-sizing: border-box; } .xtiper_sheet_tit.xtiper_sheet_left img.xtiper_tit_ico{ background: #fff; filter: invert(100%); width: ${small_icon_width}px; height: ${small_icon_width}px; align-self: center; } .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content{ margin-left: 22px; width: ${small_title_width}; } .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content p{ word-wrap: break-word; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content .xtiper_tit_svg_lock{ display: flex; align-items: center; } .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content .xtiper_tit_svg_lock svg{ margin: 0px 6px 0px 2px; } .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_right { display: inline-flex; align-items: center; align-content: center; width: ${small_right_btn_width}px; justify-content: center; } .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_right_windowopen, .xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_right_windowclose{ width: 100%; text-align: center; margin: 0px 0px; height: 100%; display: flex; justify-content: center; align-items: center; } /* 底部高度不对等问题*/ .xtiper_content.xtit{ height: calc(100% - 80px); } /* 底部消息距离底部30px*/ .xtiper.xtiper_msg.xtiper_msg_bottom.xtiper_msg_black.xon{ margin-bottom: 30px; } /* 标题顶部拖拽*/ .xtiper_sheet_tit_top_drag{ width: 100%; position: relative; height: 10px; } .xtiper_sheet_tit_top_drag div{ width: 50px; margin: 0 auto; height: 4px; background: #d9d9d9; border-radius: 15px; bottom: 3px; position: relative; } `); function getFormList() { /* 获取当前页面所有帖子 */ let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : []; formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList; formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList; return formList; } let formlist = null; /* 帖子列表 */ let isFindFormList = false; /* 是否找到帖子 */ let findFormListNums = 0; /* 找到帖子的数量 */ let smallWindowId = null; /* 小窗对象 */ let waitFormListAppear = setInterval(function () { /* 等待页面加载出现帖子 */ if (isFindFormList) { formlist = getFormList(); main(); clearInterval(waitFormListAppear); } else { if (findFormListNums >= 10) { console.log("未出现帖子或寻找贴子超时,清理定时器"); clearInterval(waitFormListAppear); } isFindFormList = getFormList().length ? true : false; findFormListNums += 1; } }, 800); function popstateFunction() { window.history.pushState("forward", null, "#"); window.history.forward(1); resumeBack(); } function banBack() { /* 禁止浏览器后退按钮 */ if (window.history && window.history.pushState) { $jq(window).on("popstate", popstateFunction); } window.history.pushState( "forward", null, "#" ); /* 在IE中必须得有这两行 */ window.history.forward(1); } async function resumeBack() { /* 允许浏览器后退并关闭小窗 */ xtip.close(smallWindowId); smallWindowId = null; $jq(window).off("popstate", popstateFunction); while (1) { if (window.location.href == "https://bbs.binmt.cc/#") { console.log("back!"); await Utils.asyncSetTimeOut("window.history.back();", 100); await Utils.sleep(100); } else { return; } } } function getSmallPageBtn(forumPostTitle, forumPostUrl, isNew) { let prevNode = document.createElement("li"); let constructURL = new URL(forumPostUrl); let isHTTPS = constructURL.protocol.indexOf("https:") != -1 ? true : false; let safeIcon = ` `; let unsafeIcon = ` `; let blankOpenIcon = ` `; let closeIcon = ` `; let showWebsiteSafeIcon = isHTTPS ? safeIcon : unsafeIcon; let websiteTitle = `

    ${forumPostTitle}

    ${showWebsiteSafeIcon}

    ${constructURL.host}

    ${blankOpenIcon}
    ${closeIcon}
    `; prevNode.className = "f_c"; prevNode.setAttribute( "style", "display: flex;justify-content: center;align-items: center;" ); prevNode.innerHTML = ` `; prevNode.getElementsByClassName("tosmallwindowprev")[0].innerText = isNew ? "Win" : "浏览"; prevNode.onclick = () => { banBack(); let temp_id = xtip.open({ type: "url", content: forumPostUrl, title: websiteTitle, height: "88%", app: true, success: (e) => {}, end: () => { console.log("点击其它区域关闭小窗"); resumeBack(); }, }); if (typeof top.window.tampermonkeyByMT != "undefined") { console.log("当前执行为非油猴调用"); let iframe_id = temp_id + "_id"; document.getElementById(iframe_id).onload = () => { console.log(`子窗口: ${iframe_id}加载完毕`); let scriptNode = document.createElement("script"); scriptNode.innerHTML = top.window.tampermonkeyByMT; document .getElementById(iframe_id) .contentWindow.document.head.append(scriptNode); }; } smallWindowId = temp_id; console.log(smallWindowId); let dragNode = new AnyTouch(document.getElementById(temp_id)); let smallWidowNode = document .getElementById(temp_id) .querySelector("div.xtiper_sheet"); let smallWidowNormalHeight = parseInt( smallWidowNode.style["height"] ); /* 小窗原始高度 */ console.log("小窗原始高度", smallWidowNormalHeight); dragNode.on("pan", (e) => { if (e.phase == "move" && e.displacementY > 0) { /* 当前为向下移动 */ smallWidowNode.style["transition"] = "none"; smallWidowNode.style["height"] = Math.abs(smallWidowNormalHeight - e.distanceY) + "px"; } if (e.isEnd) { /* 当前为停止移动,松开手指,判断在哪个区域,一半以上回归上面,一般以下,关闭 */ smallWidowNode.style["transition"] = "0.2s ease-in"; if ( parseInt(smallWidowNode.style["height"]) > window.innerHeight / 2 ) { smallWidowNode.style["height"] = smallWidowNormalHeight + "px"; } else { resumeBack(); } } }); dragNode.on("tap", (e) => { if ( document .getElementById(temp_id) .querySelector(".xtiper_bg") .outerHTML.indexOf(e.target.outerHTML) != -1 ) { /* 点击背景关闭小窗 */ console.log("点击背景关闭小窗"); resumeBack(); dragNode.off("tap"); dragNode.off("pan"); return; } if ( document .getElementById(temp_id) .querySelector(".xtiper_tit_content") .outerHTML.indexOf(e.target.outerHTML) != -1 ) { GM_setClipboard(`『${forumPostTitle}』 - ${forumPostUrl}`); xtips.toast("已复制链接", { icon: "success", pos: "bottom", }); return; } if ( document .getElementById(temp_id) .querySelector(".xtiper_tit_right_windowopen svg") .outerHTML.indexOf(e.target.outerHTML) != -1 ) { window.open(forumPostUrl, "_blank"); return; } if ( document .getElementById(temp_id) .querySelector(".xtiper_tit_right_windowclose svg") .outerHTML.indexOf(e.target.outerHTML) != -1 ) { console.log("点击关闭按钮关闭小窗"); resumeBack(); dragNode.off("tap"); dragNode.off("pan"); return; } }); }; return prevNode; } async function main() { $jq.each(formlist, function (index, value) { let isNewUI = false; let formBottomEle = value.querySelectorAll( ".comiis_znalist_bottom.b_t.cl ul.cl li" ); if (!formBottomEle.length) { let tempFormBottomEle = value.querySelectorAll( ".comiis_xznalist_bottom.cl ul.cl li" ); /* 新版论坛UI */ if (!tempFormBottomEle.length) { return; } formBottomEle = tempFormBottomEle; isNewUI = true; } let clParentEle = formBottomEle[0].parentElement; if (clParentEle.querySelector(".tosmallwindowprev")) { console.log("已经插入过小窗浏览"); } else { let forumPostUrl = value .querySelector(".mmlist_li_box.cl a") .getAttribute("href"); let forumPostTitle = value.querySelector( ".mmlist_li_box.cl a" ).innerText; if (!forumPostUrl) { console.log("获取帖子url失败"); return; } if (!forumPostTitle) { console.log("获取帖子标题失败"); return; } let previewPicturesEle = getSmallPageBtn( forumPostTitle, forumPostUrl, isNewUI ? isNewUI : null ); if (previewPicturesEle != null) { clParentEle.append(previewPicturesEle); clParentEle.setAttribute( "style", "display: flex;height: inherit;" ); } } }); } }, paymentSubjectReminder() { /* 付费主题白嫖提醒 */ let urlForumPostMatchStatus = window.location.href.match( mt_config.rexp.forum_post ); let urlHomeSpaceMatchStatus = window.location.href.match( mt_config.rexp.home_space_url ); let urlGuideMatchStatus = window.location.href.match( mt_config.rexp.forum_guide_url ); let urlCommunityMatchStatus = window.location.href.match(mt_config.rexp.community_url) || window.location.href.match(mt_config.rexp.plate_url); let urlBBSMatchStatus = window.location.href.match(mt_config.rexp.bbs); let storageMatchStatus = GM_getValue("v44") != null; let setTipForumPostList = GM_getValue("tipToFreeSubjectForumPost") == null ? [] : GM_getValue("tipToFreeSubjectForumPost"); const paymentSubjectReminderHome = { getData() { /* 获取数据 */ return GM_getValue("tipToFreeSubjectForumPost") == null ? [] : GM_getValue("tipToFreeSubjectForumPost"); }, setData(data) { /* 设置数据 */ GM_setValue("tipToFreeSubjectForumPost", data); }, async insertButtonView() { /* 插入-底部导航-我的-付费主题白嫖列表(按钮) */ let comiis_left_Touch = document.createElement("li"); comiis_left_Touch.className = "comiis_left_Touch"; let paymentSubjectReminderHomeBtn = document.createElement("a"); paymentSubjectReminderHomeBtn.setAttribute("href", "javascript:;"); paymentSubjectReminderHomeBtn.className = "paymentsubjectreminder"; paymentSubjectReminderHomeBtn.innerHTML = `
    付费主题白嫖列表
    `; GM_addStyle(` .NZ-MsgBox-alert .msgcontainer .msgtitle { text-align: center !important; } #autolist .k_misign_lu img { width: 40px; height: 40px; -moz-border-radius: 20px; -webkit-border-radius: 20px; border-radius: 20px; } .k_misign_lc .f_c{ margin: 5px 0px; } details.subjectnotvisit, details.subjectcanvisit{ margin-left: 20px; } `); paymentSubjectReminderHomeBtn.onclick = () => { paymentSubjectReminderHome.showView(); }; comiis_left_Touch.append(paymentSubjectReminderHomeBtn); $jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append( comiis_left_Touch ); /* Array.from(document.querySelectorAll(".comiis_myinfo_list.bg_f.cl")).forEach((ele) => { if (ele.innerText.match(/消息提醒|资料设置|我的积分|我的勋章|我的道具/)) { ele.append(paymentSubjectReminderHomeBtn); return; } }) */ }, async showView() { /* 显示-付费主题白嫖列表(dialog) */ 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"); } } let data = paymentSubjectReminderHome.getData(); console.log("准备排序的数据: ", data); $jq.NZ_MsgBox.alert({ title: "付费主题白嫖列表", content: "
    获取中...
    ", type: "", location: "center", buttons: { confirm: { text: "确定", }, }, }); let notVisitedTipContent = ""; /* 可白嫖且未访问 */ let notVisitedNums = 0; /* 可白嫖且未访问的数量 */ let isFreeContent = ""; /* 可白嫖帖子-未读的加左上边红点 */ let isPaidContent = ""; /* 需付费帖子 */ let isFreeNotVisitedContentList = []; let isFreeContentList = []; let isPaidContentList = []; $jq.each(data, (i, v) => { let timeColor = "#f91212"; let leftRedBtn = ""; if (new Date().getTime() > v["expirationTimeStamp"]) { /* 可白嫖 */ timeColor = "#1e90ff"; if (v["isVisited"] == false) { leftRedBtn = ''; notVisitedNums = notVisitedNums + 1; } else { console.log(v); console.log("该帖子已经访问过"); } } let concatList = { content: `
    ${leftRedBtn}
    ${v["title"]}
  • ${v["expirationTime"]}
  • `, timestamp: v["expirationTimeStamp"], }; if (new Date().getTime() > v["expirationTimeStamp"]) { /* 可白嫖 */ if (leftRedBtn != "") { isFreeNotVisitedContentList = [ ...isFreeNotVisitedContentList, concatList, ]; } else { isFreeContentList = [...isFreeContentList, concatList]; } } else { isPaidContentList = [...isPaidContentList, concatList]; } }); console.log("可白嫖但未访问:", isFreeNotVisitedContentList); console.log("可白嫖:", isFreeContentList); console.log("未到白嫖时间:", isPaidContentList); isFreeNotVisitedContentList.sort( Utils.sortListByProperty((item) => { return item["expirationTimeStamp"]; }, false) ); isFreeContentList.sort( Utils.sortListByProperty((item) => { return item["timestamp"]; }, false) ); isPaidContentList.sort( Utils.sortListByProperty((item) => { return item["timestamp"]; }, false) ); console.log("排序后——可白嫖但未访问:", isFreeNotVisitedContentList); console.log("排序后——可白嫖:", isFreeContentList); console.log("排序后——未到白嫖时间:", isPaidContentList); isFreeContent = Utils.mergeArrayToString(isFreeNotVisitedContentList, "content") + Utils.mergeArrayToString(isFreeContentList, "content"); isPaidContent = Utils.mergeArrayToString( isPaidContentList, "content" ); if (notVisitedNums > 0) { notVisitedTipContent = `${notVisitedNums}`; } let dialogIsFreeContent = '
    可白嫖' + notVisitedTipContent + '' + isFreeContent + "
    "; let dialogIsPaidContent = '
    需付费' + isPaidContent + "
    "; $jq(".msgcon").html(""); $jq(".msgcon").append(dialogIsFreeContent); $jq(".msgcon").append(dialogIsPaidContent); $jq(".msgcon").css("height", "400px"); $jq(".delsubjecttip i.comiis_font").on("click", (e) => { var t_index = e.target.parentElement.getAttribute("t-index"); popup2.confirm({ text: "

    确定移出付费主题白嫖列表?

    ", mask: true, ok: { callback: () => { data.splice(t_index, 1); console.log(data); paymentSubjectReminderHome.setData(data); Utils.deleteParentDOM(e.target, (dom) => { return dom.localName === "tr" ? true : false; }); popup2.confirm_close(); }, }, only: true, }); }); $jq("#paymentSubjectReminderIsFreeList").on("click", "a", (e) => { var t_index = e.target.getAttribute("t-index"); var t_href = e.target.getAttribute("t-href"); console.log(t_index, t_href); data[t_index]["isVisited"] = true; paymentSubjectReminderHome.setData(data); window.open(t_href, "_blank"); e.target.setAttribute("style", "color: #000000;"); if ( e.target.parentElement.parentElement.children[0].className != "icon_msgs bg_del" ) { return; } e.target.parentElement.parentElement.children[0].remove(); $jq("#paymentSubjectReminderIsFreeList").append( e.target.parentElement.parentElement.parentElement.parentElement .parentElement ); let notVisitedNums = $jq( ".subjectcanvisit summary span.icon_msgs.bg_del.f_f" ).text(); notVisitedNums = parseInt(notVisitedNums) - 1; if (notVisitedNums > 0) { $jq(".subjectcanvisit summary span.icon_msgs.bg_del.f_f").html( notVisitedNums ); } else { $jq( ".subjectcanvisit summary span.icon_msgs.bg_del.f_f" ).remove(); } }); $jq("#paymentSubjectReminderIsPaidList").on("click", "a", (e) => { var t_index = e.target.getAttribute("t-index"); var t_href = e.target.getAttribute("t-href"); console.log(t_index, t_href); window.open(t_href, "_blank"); e.target.setAttribute("style", "color: #000000;"); }); }, }; if (storageMatchStatus && urlForumPostMatchStatus) { /* 帖子内部-添加进提醒的按钮或者已添加进提醒的按钮点击移出 */ let paySubjectTip = $jq("span.kmren"); /* 购买主题的元素 */ if (paySubjectTip.length != 0) { log.success("当前帖子存在需要购买主题"); let isAddTip = false; let tipBtnHTML = ""; Array.from(setTipForumPostList).forEach((item, index) => { if (window.location.href.match(item["url"])) { isAddTip = true; return; } }); if (isAddTip) { log.success("已设置提醒"); tipBtnHTML = $jq( `` ); tipBtnHTML.on("click", function () { popup2.confirm({ text: "

    确定移出付费主题白嫖列表?

    ", ok: { callback: function () { let isRemove = false; Array.from(setTipForumPostList).forEach((item, index) => { if (window.location.href.match(item["url"])) { setTipForumPostList.splice(index, 1); GM_setValue( "tipToFreeSubjectForumPost", setTipForumPostList ); isRemove = true; Utils.asyncSetTimeOut("window.location.reload()", 1500); return; } }); if (!isRemove) { popup2.toast("移出失败"); } else { popup2.confirm_close(); popup2.toast({ text: "移出成功", }); } }, }, mask: true, }); }); } else { log.success("未设置提醒"); tipBtnHTML = $jq( `` ); tipBtnHTML.on("click", () => { let expirationTimeMatch = $jq(".kmren") .parent() .text() .replace(/\t|\n/g, "") .match( /[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}[\s]{1}[0-9]{1,2}:[0-9]{1,2}/ ); if (expirationTimeMatch.length == 0) { popup2.toast({ text: "获取付费主题到期时间失败", }); return; } let expirationTime = expirationTimeMatch[0]; let expirationTimeStamp = Utils.formatTextToTimeStamp(expirationTime); setTipForumPostList = setTipForumPostList.concat({ url: window.location.href, title: document.title.replace(" - MT论坛", ""), expirationTime: expirationTime, expirationTimeStamp: expirationTimeStamp, isVisited: false, }); GM_setValue("tipToFreeSubjectForumPost", setTipForumPostList); popup2.toast({ text: "添加成功", }); setTimeout(function () { window.location.reload(); }, 1500); }); } $jq(".comiis_head.f_top .header_y").append(tipBtnHTML); } } if (storageMatchStatus && urlBBSMatchStatus) { /* 底部导航-我的-提供类似小黑屋这种可查看设置提醒的帖子 */ paymentSubjectReminderHome.insertButtonView(); } if (storageMatchStatus) { /* 设置提醒小红点 */ function getTipNums() { let needTipNums = 0; Array.from(paymentSubjectReminderHome.getData()).forEach( (item, index) => { if ( new Date().getTime() > item["expirationTimeStamp"] && item["isVisited"] == false ) { needTipNums += 1; } } ); return needTipNums; } if ( urlHomeSpaceMatchStatus || urlGuideMatchStatus || urlCommunityMatchStatus ) { /* 当前网页为,底部导航-我的 */ let redBtn = $jq( ".icon_msgs.bg_del.f_f" ); /* 底部导航-我的-右上角小红点 */ let tipNums = 0; if (redBtn.length) { tipNums = parseInt(redBtn.text()); $jq(".icon_msgs.bg_del.f_f").html(tipNums + getTipNums()); $jq(".comiis_head .header_z .kmuser em").append( $jq(``) ); } else { let tipnums = getTipNums(); if (tipnums) { /* $jq("ul.comiis_flex li.flex a[title='我的'] i.comiis_font").append($jq(`${tipnums}`)); */ $jq(".comiis_head .header_z .kmuser em").append( $jq(``) ); } } } if (urlBBSMatchStatus) { /* 当前网页为,全部 */ let redBtn = $jq( ".sidenv_num.bg_del.f_f" ); /* 侧边栏-头像-右上角小红点 */ let tipNums = 0; if (redBtn.length) { tipNums = parseInt(redBtn.text()); $jq(".sidenv_num.bg_del.f_f").html(tipNums + getTipNums()); } else { let tipnums = getTipNums(); if (tipnums) { $jq(".sidenv_user em").before( $jq(`${tipnums}`) ); } } if (getTipNums()) { /* 当前网页为,侧边slider,付费白嫖列表 */ /* $jq(".comiis_left_Touch .paymentsubjectreminder div.flex").append($jq(``)); */ $jq(".comiis_left_Touch .paymentsubjectreminder div.flex").append( $jq(``) ); } } } }, async previewPictures() { /* 贴外预览图片-使用github项目https://github.com/fengyuanchen/viewerjs */ if ( !GM_getValue("v34") && !( window.location.href.match(mt_config.rexp.forum_guide_url) || /* !(window.location.href.match(mt_config.rexp.forum_post)) || !(window.location.href.match(mt_config.rexp.plate_url)) || */ !window.location.href.match(mt_config.rexp.search_url) ) ) { return; } function getFormList() { let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : []; formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList; formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList; return formList; } let formlist = null; /* 帖子列表 */ let isFindFormList = false; let findFormListNums = 0; let waitFormListAppear = setInterval(function () { if (isFindFormList) { formlist = getFormList(); main(); clearInterval(waitFormListAppear); } else { if (findFormListNums >= 10) { console.log("未出现帖子或寻找贴子超时,清理定时器"); clearInterval(waitFormListAppear); } isFindFormList = getFormList().length ? true : false; findFormListNums += 1; } }, 800); function getPreviewBtn(node, isNew) { let prevNode = document.createElement("li"); prevNode.className = "f_c"; let imageDOM = node.querySelectorAll(".comiis_pyqlist_img").length ? node.querySelectorAll(".comiis_pyqlist_img") : node.querySelectorAll(".comiis_pyqlist_imgs"); if (imageDOM.length == 0) { return null; } prevNode.setAttribute( "style", "display: flex;justify-content: center;" ); prevNode.innerHTML = ``; Array.from(imageDOM).forEach((item) => { let needPrevImages = item.querySelectorAll("img"); let postForumImageNodeDiv = document.createElement("div"); let postForumImageNodeUl = document.createElement("ul"); postForumImageNodeUl.className = "postforumimages"; postForumImageNodeUl.setAttribute("style", "display:none;"); Array.from(needPrevImages).forEach((_img_) => { let tempLi = document.createElement("li"); let tempImg = document.createElement("img"); tempImg.setAttribute("data-src", _img_.getAttribute("src")); tempLi.append(tempImg); postForumImageNodeUl.append(tempLi); }); postForumImageNodeDiv.append(postForumImageNodeUl); prevNode.append(postForumImageNodeDiv); }); let canPrevImageNums = prevNode.getElementsByTagName("img").length; prevNode.getElementsByClassName("topreimg")[0].innerText = isNew ? canPrevImageNums : "预览"; prevNode.onclick = (e) => { let imageList = e.target.parentElement.children[2].children[0]; let viewer = new Viewer(imageList, { inline: false, url: "data-src", hidden: () => { viewer.destroy(); }, }); viewer.zoomTo(1); viewer.show(); }; return prevNode; } async function main() { $jq.each(formlist, function (index, value) { let isNewUI = false; let formBottomEle = value.querySelectorAll( ".comiis_znalist_bottom.b_t.cl ul.cl li" ); if (!formBottomEle.length) { let tempFormBottomEle = value.querySelectorAll( ".comiis_xznalist_bottom.cl ul.cl li" ); /* 新版论坛UI */ if (!tempFormBottomEle.length) { return; } formBottomEle = tempFormBottomEle; isNewUI = true; } let clParentEle = formBottomEle[0].parentElement; if (clParentEle.querySelector(".topreimg")) { console.log("已经插入过预览图片"); } else { let previewPicturesEle = getPreviewBtn( value, isNewUI ? isNewUI : null ); if (previewPicturesEle != null) { clParentEle.append(previewPicturesEle); clParentEle.setAttribute("style", "display: flex;"); } } }); } }, previewPostForum() { /* 发帖、回复、编辑预览功能 */ GM_addStyle(` #comiis_mh_sub{ height:40px; } .gm_plugin_previewpostforum svg{ } .gm_plugin_previewpostforum_html .comiis_message_table{ margin-top: 10px; font-weight: initial; line-height: 24px; } .gm_plugin_previewpostforum_html .comiis_message_table a{ height: auto; float: unset; color: #507daf !important; } .gm_plugin_previewpostforum_html .comiis_message_table i{ text-align: unset; font-size: unset; line-height: unset; padding-top: unset; display: unset; } .comiis_postli.comiis_list_readimgs.nfqsqi{ width: 100vw; } .gm_plugin_previewpostforum_html.double-preview{ width: 50vw; } .gm_plugin_previewpostforum_html.double-preview .comiis_over_box.comiis_input_style{ border-left: 1px solid; } `); let open_double = GM_getValue("preview_post_forum_by_double"); function addMenu_preview() { /* 添加底部菜单-预览 */ $jq("#comiis_mh_sub .swiper-wrapper.comiis_post_ico").append( $jq( `预览` ) ); } function addMenu_doubleColumnPreview() { /* 添加底部菜单-高级-使用双列预览 */ $jq("#htmlon") .parent() .append( $jq(`
  • 使用双列预览
  • `) ); $jq("#postformdouble").on("click", function () { let obj = $jq(this); let code_obj = obj.parent().find(".comiis_checkbox"); if (code_obj.hasClass("comiis_checkbox_close")) { GM_setValue("preview_post_forum_by_double", true); } else { GM_setValue("preview_post_forum_by_double", false); } }); } function addMenu_immersiveInput() { /* 添加底部菜单-高级-使用沉浸输入 */ $jq("#htmlon") .parent() .append( $jq(`
  • 使用沉浸输入
  • `) ); $jq("#immersiveinput").on("click", function () { let obj = $jq(this); let code_obj = obj.parent().find(".comiis_checkbox"); console.log(code_obj.attr("class")); if (code_obj.hasClass("comiis_checkbox_close")) { $jq(".comiis_wzpost ul li.comiis_flex").hide(); /* 板块、标题 */ $jq( ".comiis_wzpost ul li.comiis_styli.kmquote" ).hide(); /* 回复别人的quote */ $jq("#pollchecked") .parent() .parent() .hide(); /* 投票,最多可填写 20 个选项 */ $jq("#pollm_c_1").hide(); /* 投票,增加一项 */ $jq( ".comiis_polloption_add+div.f_0" ).hide(); /* 投票,增加一项(编辑状态下) */ $jq( ".comiis_wzpost ul li.comiis_thread_content:contains('内容')" ).hide(); /* 投票,内容 */ } else { $jq(".comiis_wzpost ul li.comiis_flex").show(); $jq(".comiis_wzpost ul li.comiis_styli.kmquote").show(); $jq("#pollchecked").parent().parent().show(); $jq("#pollm_c_1").show(); $jq(".comiis_polloption_add+div.f_0").show(); $jq( ".comiis_wzpost ul li.comiis_thread_content:contains('内容')" ).show(); } window.dispatchEvent(new Event("resize")); }); } const smiliesDictionaries = { /* 表情字典 */ "[呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq001.gif", "[撇嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq002.gif", "[色]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq003.gif", "[发呆]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq004.gif", "[得意]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq005.gif", "[流泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq006.gif", "[害羞]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq007.gif", "[闭嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq008.gif", "[睡]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq009.gif", "[大哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq010.gif", "[尴尬]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq011.gif", "[发怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq012.gif", "[调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq013.gif", "[呲牙]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq014.gif", "[惊讶]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq015.gif", "[难过]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq016.gif", "[酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq017.gif", "[冷汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq018.gif", "[抓狂]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq019.gif", "[吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq020.gif", "[偷笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq021.gif", "[可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq022.gif", "[白眼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq023.gif", "[傲慢]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq024.gif", "[饥饿]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq025.gif", "[困]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq026.gif", "[惊恐]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq027.gif", "[流汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq028.gif", "[憨笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq029.gif", "[装逼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq030.gif", "[奋斗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq031.gif", "[咒骂]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq032.gif", "[疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq033.gif", "[嘘]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq034.gif", "[晕]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq035.gif", "[折磨]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq036.gif", "[衰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq037.gif", "[骷髅]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq038.gif", "[敲打]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq039.gif", "[再见]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq040.gif", "[擦汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq041.gif", "[抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq042.gif", "[鼓掌]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq043.gif", "[糗大了]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq044.gif", "[坏笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq045.gif", "[左哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq046.gif", "[右哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq047.gif", "[哈欠]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq048.gif", "[鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq049.gif", "[委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq050.gif", "[快哭了]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq051.gif", "[阴脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq052.gif", "[亲亲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq053.gif", "[吓]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq054.gif", "[可怜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq055.gif", "[眨眼睛]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq056.gif", "[笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq057.gif", "[dogeQQ]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq058.gif", "[泪奔]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq059.gif", "[无奈]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq060.gif", "[托腮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq061.gif", "[卖萌]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq062.png", "[斜眼笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq063.gif", "[喷血]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq064.gif", "[惊喜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq065.gif", "[骚扰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq066.gif", "[小纠结]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq067.gif", "[我最美]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq068.gif", "[菜刀]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq069.gif", "[西瓜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq070.gif", "[啤酒]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq071.gif", "[篮球]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq072.gif", "[乒乓]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq073.gif", "[咖啡]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq074.gif", "[饭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq075.gif", "[猪]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq076.gif", "[玫瑰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq077.gif", "[凋谢]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq078.gif", "[示爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq079.gif", "[爱心]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq080.gif", "[心碎]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq081.gif", "[蛋糕]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq082.gif", "[闪电]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq083.gif", "[炸弹]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq084.gif", "[刀]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq085.gif", "[足球]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq086.gif", "[瓢虫]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq087.gif", "[便便]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq088.gif", "[月亮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq089.gif", "[太阳]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq090.gif", "[礼物]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq091.gif", "[抱抱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq092.gif", "[喝彩]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq93.gif", "[祈祷]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq94.gif", "[棒棒糖]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq95.gif", "[药]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq96.gif", "[赞]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq097.gif", "[差劲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq098.gif", "[握手]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq099.gif", "[胜利]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq100.gif", "[抱拳]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq101.gif", "[勾引]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq102.gif", "[拳头]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq103.gif", "[差劲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq104.gif", "[爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq105.gif", "[NO]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq106.gif", "[OK]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq107.gif", "[#呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_1.png", "[#滑稽]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_10.png", "[#吐舌]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_3.png", "[#哈哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_2.png", "[#啊]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_23.png", "[#酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_22.png", "[#怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_13.png", "[#开心]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_39.png", "[#汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_14.png", "[#泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_16.png", "[#黑线]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_15.png", "[#鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_21.png", "[#不高兴]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_12.png", "[#真棒]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_17.png", "[#钱]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_40.png", "[#疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_26.png", "[#阴险]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_20.png", "[#吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_34.png", "[#咦]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_41.png", "[#委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_29.png", "[#花心]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_6.png", "[#呼~]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_42.png", "[#激动]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_5.png", "[#冷]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_43.png", "[#可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_4.png", "[#What?]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_25.png", "[#勉强]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_38.png", "[#狂汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_24.png", "[#酸爽]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_27.png", "[#乖]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_8.png", "[#雅美蝶]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_28.png", "[#睡觉]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_31.png", "[#惊哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_19.png", "[#哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_44.png", "[#笑尿]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_32.png", "[#惊讶]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_30.png", "[#小乖]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_7.png", "[#喷]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_18.png", "[#抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_33.png", "[#捂嘴笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_9.png", "[#你懂的]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_11.png", "[#犀利]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_35.png", "[#小红脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_36.png", "[#懒得理]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_37.png", "[#爱心]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_45.png", "[#心碎]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_46.png", "[#玫瑰]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_47.png", "[#礼物]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_48.png", "[#彩虹]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_49.png", "[#太阳]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_50.png", "[#月亮]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_51.png", "[#钱币]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_52.png", "[#咖啡]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_53.png", "[#蛋糕]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_54.png", "[#大拇指]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_55.png", "[#胜利]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_56.png", "[#爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_57.png", "[#OK]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_58.png", "[#弱]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_59.png", "[#沙发]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_60.png", "[#纸巾]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_61.png", "[#香蕉]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_62.png", "[#便便]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_63.png", "[#药丸]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_64.png", "[#红领巾]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_65.png", "[#蜡烛]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_66.png", "[#三道杠]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_67.png", "[#音乐]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_68.png", "[#灯泡]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_69.png", "[doge]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/1.png", "[doge思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/2.png", "[doge再见]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/3.png", "[doge生气]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/4.png", "[doge气哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/5.png", "[doge笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/7.png", "[doge调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/6.png", "[doge啊哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/8.png", "[doge原谅TA]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/9.png", "[miao]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/10.png", "[miao思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/11.png", "[miao拜拜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/12.png", "[miao生气]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/13.png", "[miao气哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/14.png", "[二哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/15.png", "[摊手]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/19.png", "[w并不简单]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/20.png", "[w滑稽]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/21.png", "[w色]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/22.png", "[w爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/23.png", "[w拜拜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/24.png", "[w悲伤]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/25.png", "[w鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/26.png", "[w馋嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/27.png", "[w冷汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/28.png", "[w打哈欠]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/29.png", "[w打脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/30.png", "[w敲打]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/31.png", "[w生病]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/32.png", "[w闭嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/33.png", "[w鼓掌]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/34.png", "[w哈哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/35.png", "[w害羞]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/36.png", "[w呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/37.png", "[w黑线]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/38.png", "[w哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/39.png", "[w调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/40.png", "[w可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/41.png", "[w可怜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/42.png", "[w酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/43.png", "[w困]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/44.png", "[w懒得理你]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/45.png", "[w流泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/46.png", "[w怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/47.png", "[w怒骂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/48.png", "[w钱]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/49.png", "[w亲亲]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/50.png", "[w傻眼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/51.png", "[w便秘]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/52.png", "[w失望]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/53.png", "[w衰]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/54.png", "[w睡觉]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/55.png", "[w思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/56.png", "[w开心]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/57.png", "[w色舔]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/58.png", "[w偷笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/59.png", "[w吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/60.png", "[w抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/61.png", "[w委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/62.png", "[w笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/63.png", "[w嘻嘻]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/64.png", "[w嘘]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/65.png", "[w阴险]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/66.png", "[w疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/67.png", "[w抓狂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/70.png", "[w晕]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/69.png", "[w右哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/68.png", "[w左哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/71.png", "[w肥皂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/77.png", "[w奥特曼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/78.png", "[w草泥马]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/79.png", "[w兔子]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/80.png", "[w熊猫]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/81.png", "[w猪头]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/82.png", "[w→_→]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/83.png", "[w给力]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/84.png", "[w囧]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/85.png", "[w萌]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/86.png", "[w神马]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/87.png", "[w威武]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/88.png", }; function clickEvent(e) { /* 预览按钮点击事件 */ if ($jq("#polldatas").length) { /* 当前是投票帖子 */ replaceVote(); } if (!$jq(this).find("i.comiis_font").hasClass("f_0")) { $jq(".gm_plugin_previewpostforum_html").css("display", "block"); let replaecdText = replaceText($jq("#needmessage").val()); $jq( ".gm_plugin_previewpostforum_html .comiis_message_table" )[0].innerHTML = replaecdText; if (open_double) { $jq( ".gm_plugin_previewpostforum_html.double-preview .comiis_over_box.comiis_input_style" ).css("height", $jq("#needmessage").css("height")); } } else { $jq(".gm_plugin_previewpostforum_html").hide(); } } function replaceText(text) { /* 替换内容 */ let attachimgmatch = text.match( /\[attachimg\]([\s\S]+?)\[\/attachimg\]/g ); if (attachimgmatch) { attachimgmatch.forEach((item) => { let aimgidMatch = item.match( /\[attachimg\]([\s\S]+?)\[\/attachimg\]/ ); let aimg_id = aimgidMatch ? aimgidMatch[aimgidMatch.length - 1] : ""; let imgtitle = $jq(`#aimg_${aimg_id}`).attr("title"); let imgsrc = $jq(`#aimg_${aimg_id}`).attr("src"); if (!imgsrc) { imgtitle = "该图片不存在"; } text = text.replace( item, `${imgtitle}` ); }); } let code = text.match(/\[code\]([\s\S]*?)\[\/code\]/g); if (code) { code.forEach((item) => { let match_content = item.match(/\[code\]([\s\S]*?)\[\/code\]/); let contentAll = match_content ? match_content[match_content.length - 1] : ""; let content = ""; let brSplit = contentAll.split("\n"); if (brSplit.length == 1) { content = "
  • " + contentAll + "
  • "; } else { Array.from(brSplit).forEach((item, index) => { if (index == brSplit.length - 1) { content = `${content}
  • ${item}
  • `; } else { content = `${content}
  • ${item}
  • `; } }); } text = text.replace( item, `
      ${content}
    ` ); }); } let url = text.match(/\[url\=[\s\S]*?\]([\s\S]*?)\[\/url\]/g); if (url) { url.forEach((item) => { let urlMatch = item.match(/\[url=([\s\S]*?)\][\s\S]*\[\/url\]/); let urlNameMatch = item.match( /\[url=[\s\S]*?\]([\s\S]*?)\[\/url\]/ ); let _url_ = urlMatch ? urlMatch[urlMatch.length - 1] : ""; let _url_name_ = urlNameMatch ? urlNameMatch[urlNameMatch.length - 1] : ""; text = text.replace( item, `${_url_name_}` ); }); } let color = text.match(/\[color\=[\s\S]*?\]([\s\S]*?)\[\/color\]/g); if (color) { color.forEach((item) => { let colorValueMatch = item.match( /\[color=([\s\S]*?)\][\s\S]*\[\/color\]/ ); let colorTextMatch = item.match( /\[color=[\s\S]*?\]([\s\S]*?)\[\/color\]/ ); let colorValue = colorValueMatch ? colorValueMatch[colorValueMatch.length - 1] : ""; let colorText = colorTextMatch ? colorTextMatch[colorTextMatch.length - 1] : ""; text = text.replace( item, `${colorText}` ); }); } let size = text.match(/\[size\=[\s\S]*?\]([\s\S]*?)\[\/size\]/g); if (size) { console.log(size); size.forEach((item) => { let sizeValueMatch = item.match( /\[size=([\s\S]*?)\][\s\S]*\[\/size\]/ ); let sizeTextMatch = item.match( /\[size=[\s\S]*?\]([\s\S]*?)\[\/size\]/ ); let sizeValue = sizeValueMatch ? sizeValueMatch[sizeValueMatch.length - 1] : ""; let sizeText = sizeTextMatch ? sizeTextMatch[sizeTextMatch.length - 1] : ""; text = text.replace( item, `${sizeText}` ); }); } let img = text.match(/\[img(|\=[\s\S]+?)\]([\s\S]*?)\[\/img\]/g); if (img) { img.forEach((item) => { let widthInfo = null; let heightInfo = null; let img_size_match = item.match( /\[img\=([\s\S]+?)\][\s\S]*?\[\/img\]/ ); if (img_size_match) { img_size_match = img_size_match[img_size_match.length - 1].split(","); widthInfo = img_size_match[0]; heightInfo = img_size_match[1]; } widthInfo = widthInfo ? widthInfo : ""; heightInfo = heightInfo ? heightInfo : ""; let match_content = item.match( /\[img\]([\s\S]*?)\[\/img\]|\[img=[\s\S]*?\]([\s\S]*?)\[\/img\]/ ); let content = ""; if (match_content) { if (match_content[match_content.length - 1] == null) { content = match_content[match_content.length - 2]; } else { content = match_content[match_content.length - 1]; } } text = text.replace( item, `` ); }); } let hide = text.match(/\[hide\]([\s\S]*?)\[\/hide\]/g); if (hide) { hide.forEach((item) => { let match_content = item.match(/\[hide\]([\s\S]*?)\[\/hide\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace( item, `

    本帖隐藏的内容:

    ${content}
    ` ); }); } let hide2 = text.match(/\[hide=[\s\S]*?\]([\s\S]*?)\[\/hide\]/g); if (hide2) { hide2.forEach((item) => { let match_content = item.match( /\[hide=([\s\S]*?)\]([\s\S]*?)\[\/hide\]/ ); let other_info = match_content ? match_content[match_content.length - 2] : ""; other_info = other_info.split(","); let integral_big_can_see = other_info.length == 2 ? other_info[1] : ""; text = text.replace( item, `
    以下内容需要积分高于 ${integral_big_can_see} 才可浏览
    ` ); }); } let quote = text.match(/\[quote\]([\s\S]*?)\[\/quote\]/g); if (quote) { quote.forEach((item) => { let match_content = item.match(/\[quote\]([\s\S]*?)\[\/quote\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace( item, `
    回复 ${content}
    ` ); }); } let free = text.match(/\[free\]([\s\S]*?)\[\/free\]/g); if (free) { free.forEach((item) => { let match_content = item.match(/\[free\]([\s\S]*?)\[\/free\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace( item, `
    ${content}
    ` ); }); } let strong = text.match(/\[b\]([\s\S]*?)\[\/b\]/g); if (strong) { strong.forEach((item) => { let match_content = item.match(/\[b\]([\s\S]*?)\[\/b\]/i); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace(item, `${content}`); }); } let xhx = text.match(/\[u\]([\s\S]*?)\[\/u\]/g); if (xhx) { xhx.forEach((item) => { let match_content = item.match(/\[u\]([\s\S]*?)\[\/u\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace(item, `${content}`); }); } let qx = text.match(/\[i\]([\s\S]*?)\[\/i\]/g); if (qx) { qx.forEach((item) => { let match_content = item.match(/\[i\]([\s\S]*?)\[\/i\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace(item, `${content}`); }); } let strike = text.match(/\[s\]([\s\S]*?)\[\/s\]/g); if (strike) { strike.forEach((item) => { let match_content = item.match(/\[s\]([\s\S]*?)\[\/s\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace(item, `${content}`); }); } let smilies = text.match(/\[([\s\S]+?)\]/g); if (smilies) { smilies.forEach((item) => { console.log(item); let smiliesMatchSrc = smiliesDictionaries[item]; if (smiliesMatchSrc) { text = text.replace( item, `` ); } }); } let media = text.match(/\[media=[\s\S]+?\][\s\S]+?\[\/media\]/g); if (media) { media.forEach((item) => { console.log(item); let match_content = item.match( /\[media=[\s\S]*?\]([\s\S]*?)\[\/media\]/ ); let content = match_content ? match_content[match_content.length - 1] : ""; if (content) { text = text.replace( item, `` ); } }); } let email = text.match(/\[email=[\s\S]+?\][\s\S]+?\[\/email\]/g); if (email) { email.forEach((item) => { console.log(item); let email_match = item.match( /\[email=([\s\S]*?)\][\s\S]*?\[\/email\]/ ); let content_match = item.match( /\[email=[\s\S]*?\]([\s\S]*?)\[\/email\]/ ); let _email_ = email_match.length ? email_match[email_match.length - 1] : ""; let _content_ = content_match.length ? content_match[content_match.length - 1] : ""; if (_email_ || _content_) { text = text.replace( item, `${_content_}` ); } }); } let align = text.match(/\[align=[\s\S]+?\][\s\S]+?\[\/align\]/g); if (align) { align.forEach((item) => { console.log(item); let align_match = item.match( /\[align=([\s\S]*?)\][\s\S]+?\[\/align\]/ ); let content_match = item.match( /\[align=[\s\S]*?\]([\s\S]+?)\[\/align\]/ ); let _align_ = align_match.length ? align_match[align_match.length - 1] : ""; let _content_ = content_match.length ? content_match[content_match.length - 1] : ""; if (_align_ || _content_) { text = text.replace( item, `
    ${_content_}
    ` ); } }); } let qq = text.match(/\[qq\][\s\S]*?\[\/qq\]/g); if (qq) { qq.forEach((item) => { console.log(item); let match_content = item.match(/\[qq\]([\s\S]*?)\[\/qq\]/); let content = match_content ? match_content[match_content.length - 1] : ""; /* 这个是以前的wpa协议,现在是tencent协议,mt的discuz没有更新,如:tencent://message/?uin=xxx&site=bbs.binmt.cc&menu=yes */ text = text.replace( item, `` ); }); } let td = text.match(/\[td\][\s\S]+?\[\/td\]/g); if (td) { td.forEach((item) => { console.log(item); let match_content = item.match(/\[td\]([\s\S]*?)\[\/td\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace(item, `${content}`); }); } let tr = text.match(/\[tr\][\s\S]+?\[\/tr\]/g); if (tr) { tr.forEach((item) => { console.log(item); let match_content = item.match(/\[tr\]([\s\S]*?)\[\/tr\]/); let content = match_content ? match_content[match_content.length - 1] : ""; text = text.replace(item, `${content}`); }); } let table = text.match(/\[table\][\s\S]+?\[\/table\]/g); if (table) { table.forEach((item) => { console.log(item); let match_content = item.match(/\[table\]([\s\S]*?)\[\/table\]/); let content = match_content ? match_content[match_content.length - 1] : ""; content = content.replace(/\n/g, ""); text = text.replace(item, `${content}
    `); }); } let list = text.match(/\[list=[\s\S]+?\][\s\S]+?\[\/list\]/g); if (list) { list.forEach((item) => { console.log(item); let list_model_match = item.match( /\[list=([\s\S]*?)\][\s\S]*?\[\/list\]/ ); let list_content_match = item.match( /\[list=[\s\S]*?\]([\s\S]*?)\[\/list\]/ ); let list_model = list_model_match ? list_model_match[list_model_match.length - 1] : ""; let list_type = ""; if (list_model === "a") { list_type = "litype_2"; } else if (list_model === "A") { list_type = "litype_3"; } else if ( list_model.length === 1 && list_model.match(/[0-9]{1}/) ) { list_type = "litype_1"; } let content = list_content_match ? list_content_match[list_content_match.length - 1] : ""; let li_split = content.split("[*]"); if (li_split.length > 1) { let newContent = ""; if (li_split[0].replace(/[\s]*/, "") == "") { li_split = li_split.slice(1); } Array.from(li_split).forEach((item) => { newContent = newContent + "
  • " + item + "
  • "; }); content = newContent; } content = content.replace(/\n/g, ""); text = text.replace( item, `
      ${content}
    ` ); }); } $jq( ".gm_plugin_previewpostforum_html .comiis_quote.comiis_qianglou" ).remove(); let password = text.match(/\[password\](.*?)\[\/password\]/gi); if (password) { password.forEach((item) => { console.log(item); text = item.replace(/\[password\](.*?)\[\/password\]/gi, ""); $jq( ".gm_plugin_previewpostforum_html .comiis_message_table" ).before( $jq(`
     付费主题, 价格: ${$jq( "#price" ).val()} 金币 记录
    `) ); }); } let every_reward = parseInt($jq("#replycredit_extcredits").val()); let total_reward = parseInt($jq("#replycredit_times").val()); let getreward_menbertimes = parseInt( $jq("#replycredit_membertimes").val() ); let getreward_random = parseInt($jq("#replycredit_random").val()); $jq(".gm_plugin_previewpostforum_html .comiis_htjl").remove(); if ( !isNaN(every_reward) && !isNaN(total_reward) && every_reward > 0 && total_reward > 0 ) { $jq(".gm_plugin_previewpostforum_html .comiis_message_table").before( $jq(`
    总共奖励 ${total_reward} 金币
    回复本帖可获得 ${every_reward} 金币奖励! 每人限 ${getreward_menbertimes} 次 ${ getreward_random != 100 ? "(中奖概率 " + getreward_random + "%)" : "" }
    `) ); } text = text.replace(/\[hr\]/g, '
    '); text = text.replace(/\[\*\]/g, "
  • "); text = text.replace(/\n/g, "
    "); return text; } function replaceVote() { /* 替换预览投票 */ let chooseColor = [ "rgb(233, 39, 37)", "rgb(242, 123, 33)", "rgb(242, 166, 31)", "rgb(90, 175, 74)", "rgb(66, 196, 245)", "rgb(0, 153, 204)", "rgb(51, 101, 174)", "rgb(42, 53, 145)", "rgb(89, 45, 142)", "rgb(219, 49, 145)", "rgb(233, 39, 37)", "rgb(242, 123, 33)", "rgb(242, 166, 31)", "rgb(90, 175, 74)", "rgb(66, 196, 245)", "rgb(0, 153, 204)", "rgb(51, 101, 174)", "rgb(42, 53, 145)", "rgb(89, 45, 142)", "rgb(219, 49, 145)", ]; /* 选择的背景 */ let chooseContent = $jq( ".comiis_polloption_add ul li:first-child div.flex .comiis_input.kmshow[type='text']" ); /* 选项,最多20个 */ let maxchoices = parseInt($jq("input#maxchoices").val()); /* 最多可选 */ maxchoices = isNaN(maxchoices) ? 0 : maxchoices; maxchoices = maxchoices > 0 ? maxchoices : 0; maxchoices = maxchoices > chooseContent.length ? chooseContent.length : maxchoices; /* 大于当前选项数量的话为当前最大选项数量 */ let polldatas = parseInt($jq("input#polldatas").val()); /* 记票天数 */ polldatas = isNaN(polldatas) ? 0 : polldatas; let visibilitypoll = $jq("input#visibilitypoll") .parent() .find(".comiis_checkbox") .hasClass("comiis_checkbox_close") ? false : true; /* 投票后结果可见 */ let overt = $jq("input#overt") .parent() .find(".comiis_checkbox") .hasClass("comiis_checkbox_close") ? false : true; /* 公开投票参与人 */ let html = ""; let choosehtml = ""; console.log(chooseContent); chooseContent.each((i, v) => { if (i >= 20) { /* 最多20个 */ return; } choosehtml = choosehtml + `
  • 0% (0)
  • `; }); html = `

    ${ maxchoices > 1 ? "多选投票" + ' 最多可选 ' + maxchoices + " 项" : "单选投票" }

    共有 0 人参与投票

    ${ polldatas > 0 ? `

    距结束还有: ${ polldatas > 1 ? '' + (polldatas - 1) + " 天 " : "" }23 小时 59 分钟

    ` : "" }
      ${choosehtml}
    ${ overt ? '
    此为公开投票,其他人可看到您的投票项目
    ' : "" }
    `; $jq(".gm_plugin_previewpostforum_html .postforum_vote").remove(); $jq( ".gm_plugin_previewpostforum_html .comiis_messages.comiis_aimg_show" ) .children() .eq(0) .before($jq(html)); } function keyUpEvent(e) { /* 内容输入事件 */ let userInputText = e.target.value; let replaecdText = replaceText(userInputText); $jq( ".gm_plugin_previewpostforum_html .comiis_message_table" )[0].innerHTML = replaecdText; } if (typeof unsafeWindow.comiis_addsmilies == "function") { /* 替换全局函数添加图片到里面触发input */ unsafeWindow.comiis_addsmilies = (a) => { unsafeWindow.$("#needmessage").comiis_insert(a); unsafeWindow.$("#needmessage")[0].dispatchEvent(new Event("input")); }; } addMenu_doubleColumnPreview(); addMenu_preview(); addMenu_immersiveInput(); if (open_double) { /* box-shadow: -1px 0px 8px; */ $jq("#needmessage").parent().css("display", "flex"); $jq("#needmessage").after( $jq(` `) ); } else { $jq("#comiis_post_tab").append( $jq(` `) ); } $jq("#needmessage").on("propertychange input", keyUpEvent); $jq(".gm_plugin_previewpostforum").on("click", clickEvent); }, quickUBB: { code: { rainbow1: { key: "转普通彩虹", value: "", isFunc: true, num: 1, }, rainbow2: { key: "转黑白彩虹", value: "", isFunc: true, num: 2, }, rainbow3: { key: "转黑红彩虹", value: "", isFunc: true, num: 3, }, rainbow4: { key: "转蓝绿彩虹", value: "", isFunc: true, num: 4, }, size: { key: "size", value: "[size=][/size]", tagL: "=", tagR: "]", L: "[size=]", R: "[/size]", cursorL: "[size=", cursorLength: 6, quickUBBReplace: "[size=14]replace[/size]", }, color: { key: "color", value: "[color=][/color]", tagL: "=", tagR: "]", L: "[color=]", R: "[/color]", cursorL: "[color=", cursorLength: 7, quickUBBReplace: "[color=#000]replace[/color]", }, b: { key: "加粗", value: "[b][/b]", tagL: "]", tagR: "[", L: "[b]", R: "[/b]", cursorR: "[/b]", cursorLength: 4, quickUBBReplace: "[b]replace[/b]", }, u: { key: "下划线", value: "[u][/u]", tagL: "]", tagR: "[", L: "[u]", R: "[/u]", cursorR: "[/u]", cursorLength: 4, quickUBBReplace: "[u]replace[/u]", }, i: { key: "倾斜", value: "[i][/i]", tagL: "]", tagR: "[", L: "[i]", R: "[/i]", cursorR: "[/i]", cursorLength: 4, quickUBBReplace: "[i]replace[/i]", }, s: { key: "中划线", value: "[s][/s]", tagL: "]", tagR: "[", L: "[s]", R: "[/s]", cursorR: "[/s]", cursorLength: 4, quickUBBReplace: "[s]replace[/s]", }, lineFeed: { key: "换行", value: "[*]", L: "", R: "[*]", cursorL: "[*]", cursorLength: 3, quickUBBReplace: "replace[*]", }, longHorizontalLine: { key: "水平线", value: "[hr]", L: "", R: "[hr]", cursorL: "[hr]", cursorLength: 4, quickUBBReplace: "replace[hr]", }, link: { key: "链接", value: "[url=][/url]", tagL: "=", tagR: "]", L: "[url=]", R: "[/url]", cursorL: "[url=", cursorLength: 5, quickUBBReplace: "[url=replace]replace[/url]", }, hide: { key: "隐藏", value: "[hide][/hide]", tagL: "]", tagR: "[", L: "[hide]", R: "[/hide]", cursorR: "[/hide]", cursorLength: 7, quickUBBReplace: "[hide]replace[/hide]", }, quote: { key: "引用", value: "[quote][/quote]", tagL: "]", tagR: "[", L: "[quote]", R: "[/quote]", cursorR: "[/quote]", cursorLength: 8, quickUBBReplace: "[quote]replace[/quote]", }, email: { key: "邮件", value: "[email=][/email]", tagL: "=", tagR: "]", L: "[email=]", R: "[/email]", cursorL: "[email=", cursorLength: 7, quickUBBReplace: "[email=replace]replace[/email]", }, }, insertQuickReplyUBB: () => { /* 快捷回复 */ $jq.each(mobile.quickUBB.code, function (index, value) { let ubbs = $jq( `
  • ${value["key"]}
  • ` ); ubbs.on("click", function () { $jq( "#comiis_insert_ubb_tab div.comiis_post_urlico ul li.quickUBBs a.comiis_xifont" ) .removeClass("f_0") .addClass("f_d"); $jq(this).find(".comiis_xifont").removeClass("f_d").addClass("f_0"); popup2.confirm({ text: ` `, mask: true, only: true, ok: { callback: () => { let userInput = $jq(".quickinsertbbsdialog").val().trim(); if (userInput == null || userInput.trim() == "") { return; } if (value["isFunc"]) { comiis_addsmilies( mobile.quickUBB.set_rainbow(value["num"], userInput) ); /* 插入贴内 */ } else if (value["quickUBBReplace"]) { comiis_addsmilies( value["quickUBBReplace"].replaceAll("replace", userInput) ); /* 插入贴内 */ } else { comiis_addsmilies(userInput); /* 插入贴内 */ } popup2.confirm_close(); /* if (value["isFunc"]) { userInput = mobile.quickUBB.set_rainbow(value["num"], userInput); }*/ }, }, }); }); $jq("#comiis_insert_ubb_tab div.comiis_post_urlico ul").append( ubbs[0] ); }); }, insertReplayUBB: () => { /* 具体回复 */ let insertDOM = $jq(".comiis_post_urlico"); if (!insertDOM) { console.log("未找到插入元素"); return; } GM_addStyle(` #comiis_post_tab .comiis_input_style .comiis_post_urlico li a.f_0{ color: #53bcf5 !important; } `); let parentEle = $jq(".comiis_post_urlico > ul")[0]; let contentEle = $jq("#comiis_post_qydiv > ul"); let childNums = $jq("#comiis_post_qydiv ul li").length; mobile.quickUBB.jqueryExtraFunction(); $jq("#comiis_post_tab .comiis_input_style .comiis_post_urlico li").on( "click", function () { $jq( "#comiis_post_tab .comiis_input_style .comiis_post_urlico li a" ).removeClass("f_0"); $jq( "#comiis_post_tab .comiis_input_style .comiis_post_urlico li a" ).addClass("f_d"); $jq(this).find("a").attr("class", "comiis_xifont f_0"); $jq("#comiis_post_qydiv ul li") .hide() .eq($jq(this).index()) .fadeIn(); } ); $jq.each(mobile.quickUBB.code, function (key, value) { let ubbs = $jq( `
  • ${value["key"]}
  • ` ); ubbs.on("click", (e) => { let bottomEle = $jq( `#comiis_post_qydiv li[data-key='${value.key}']` ); if (!bottomEle.length) { console.log("未找到该元素"); return; } let contentIndex = childNums + Object.keys(mobile.quickUBB.code).indexOf(key); console.log(contentIndex); $jq("#comiis_post_qydiv ul li").hide().eq(contentIndex).fadeIn(); $jq.each( $jq( "#comiis_post_tab div.comiis_post_urlico ul li a.comiis_xifont" ), (i, v) => { v.className = "comiis_xifont f_d"; if (v == e.target) { v.className = "comiis_xifont f_0"; } } ); }); parentEle.append(ubbs[0]); let ubbs_content = document.createElement("li"); ubbs_content.setAttribute("style", "display: none;"); ubbs_content.setAttribute("data-key", value["key"]); ubbs_content.innerHTML = `
    `; contentEle.append(ubbs_content); $jq(`.comiis_sendbtn[data-keyI="${key}"]`).on("click", () => { let text = $jq(`#comiis_input_${key}`).val(); if (text == "") { popup2.toast("请输入需要插入的内容"); return; } if (mobile.quickUBB.code[key]["isFunc"]) { text = mobile.quickUBB.set_rainbow( mobile.quickUBB.code[key]["num"], text ); } if (mobile.quickUBB.code[key].hasOwnProperty("L")) { text = mobile.quickUBB.code[key]["L"] + text + mobile.quickUBB.code[key]["R"]; } $jq("#needmessage").insertAtCaret(text); /* if (mobile.quickUBB.code[key]["tagL"] != undefined || mobile.quickUBB.code[key]["tagR"] != undefined) { $jq("#needmessage").moveCursorInCenterByText(mobile.quickUBB.code[key]["tagL"], mobile.quickUBB.code[key]["tagR"]); }*/ if (mobile.quickUBB.code[key].hasOwnProperty("cursorL")) { $jq("#needmessage").moveCursorToCenterByTextWithLeft( mobile.quickUBB.code[key]["cursorL"], mobile.quickUBB.code[key]["cursorLength"] ); } if (mobile.quickUBB.code[key].hasOwnProperty("cursorR")) { $jq("#needmessage").moveCursorToCenterByTextWithRight( mobile.quickUBB.code[key]["cursorR"], mobile.quickUBB.code[key]["cursorLength"] ); } }); }); }, set_rainbow: (num, text) => { if (text == "") { return ""; } var wr_text = text; var wr_code, wr_rgb, r, g, b, i, j, istep; var wr_rgb1, wr_rgb2, r1, g1, b1, r2, g2, b2; r1 = g1 = b1 = r2 = g2 = b2 = 0; r = 0; g = 0; b = 0; istep = 0; wr_code = ""; if (num == 1) { istep = 40; r = 255; i = 1; j = 0; do { if (wr_text.charCodeAt(j) != 32) { if (g + istep < 256) { if (i == 1) g += istep; } else if (i == 1) { i = 2; g = 255; } if (r - istep > -1) { if (i == 2) r -= istep; } else if (i == 2) { i = 3; r = 0; } if (b + istep < 256) { if (i == 3) b += istep; } else if (i == 3) { i = 4; b = 255; } if (g - istep > -1) { if (i == 4) g -= istep; } else if (i == 4) { i = 5; g = 0; } if (r + istep < 256) { if (i == 5) r += istep; } else if (i == 5) { i = 6; r = 255; } if (b - istep > -1) { if (i == 6) b -= istep; } else if (i == 6) { i = 1; b = 0; } wr_rgb = ""; wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16); wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16); wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16); wr_rgb = wr_rgb.toUpperCase(); wr_code += "[color=#" + wr_rgb + "]" + wr_text.charAt(j) + "[/color]"; } else { wr_code += wr_text.charAt(j); } j++; } while (j < wr_text.length); } else if (num == 2) { istep = 255 / wr_text.length; for (i = 1; i < wr_text.length + 1; i++) { if (wr_text.charCodeAt(i - 1) != 32) { r += istep; g += istep; b += istep; if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255; wr_rgb = ""; wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16); wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16); wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16); wr_rgb = wr_rgb.toUpperCase(); wr_code += "[color=#" + wr_rgb + "]" + wr_text.charAt(i - 1) + "[/color]"; } else { wr_code += wr_text.charAt(i - 1); } } } else if (num == 3) { istep = 255 / wr_text.length; for (i = 1; i < wr_text.length + 1; i++) { if (wr_text.charCodeAt(i - 1) != 32) { r += istep; g = 29; b = 36; if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255; wr_rgb = ""; wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16); wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16); wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16); wr_rgb = wr_rgb.toUpperCase(); wr_code += "[color=#" + wr_rgb + "]" + wr_text.charAt(i - 1) + "[/color]"; } else { wr_code += wr_text.charAt(i - 1); } } } else if (num == 4) { istep = 255 / wr_text.length; for (i = 1; i < wr_text.length + 1; i++) { if (wr_text.charCodeAt(i - 1) != 32) { r = 0; g = 174; b += istep; if (r > 255) r = 255; if (g > 255) g = 255; if (b > 255) b = 255; wr_rgb = ""; wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16); wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16); wr_rgb += parseInt(255 - b).toString(16).length == 1 ? 0 + parseInt(255 - b).toString(16) : parseInt(255 - b).toString(16); wr_rgb = wr_rgb.toUpperCase(); wr_code += "[color=#" + wr_rgb + "]" + wr_text.charAt(i - 1) + "[/color]"; } else { wr_code += wr_text.charAt(i - 1); } } } return wr_code; }, jqueryExtraFunction: () => { $jq.fn.extend({ insertAtCaret: function (myValue) { var $t = $jq(this)[0]; if (document.selection) { this.focus(); var sel = document.selection.createRange(); sel.text = myValue; this.focus(); } else if ($t.selectionStart || $t.selectionStart == "0") { var startPos = $t.selectionStart; var endPos = $t.selectionEnd; var scrollTop = $t.scrollTop; $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length); this.focus(); $t.selectionStart = startPos + myValue.length; $t.selectionEnd = startPos + myValue.length; $t.scrollTop = scrollTop; } else { this.value += myValue; this.focus(); } }, selectRange: function (start, end) { if (end === undefined) { end = start; } return this.each(function () { if ("selectionStart" in this) { this.selectionStart = start; this.selectionEnd = end; } else if (this.setSelectionRange) { this.setSelectionRange(start, end); } else if (this.createTextRange) { var range = this.createTextRange(); range.collapse(true); range.moveEnd("character", end); range.moveStart("character", start); range.select(); } }); }, getCursorPosition: function () { var el = $jq(this)[0]; var pos = 0; if ("selectionStart" in el) { pos = el.selectionStart; } else if ("selection" in document) { el.focus(); var Sel = document.selection.createRange(); var SelLength = document.selection.createRange().text.length; Sel.moveStart("character", -el.value.length); pos = Sel.text.length - SelLength; } return pos; }, moveCursorInCenterByText: function (leftTextFlag, rightTextFlag) { var el = $jq(this)[0]; var el_text = el.value; for (let i = el.selectionStart - 1; i > 0; i--) { let LText = el_text[i - 1]; let currentText = el_text[i]; if (LText == leftTextFlag && currentText == rightTextFlag) { this.selectRange(i); break; } } }, moveCursorToCenterByTextWithLeft: function (leftMatchText, _length_) { var el = $jq(this)[0]; var el_text = el.value; for (let i = el.selectionStart - 1; i > 0; i--) { let lTexts = el_text.substring(i - _length_, i); if (lTexts == leftMatchText) { this.selectRange(i); break; } } }, moveCursorToCenterByTextWithRight: function ( rightMatchText, _length_ ) { var el = $jq(this)[0]; var el_text = el.value; for (let i = el.selectionStart - 1; i > 0; i--) { let rTexts = el_text.substring(i, i + _length_); if (rTexts == rightMatchText) { this.selectRange(i + _length_); break; } } }, }); }, }, recoveryIMGWidth() { /* 修复图片宽度 */ if ( GM_getValue("v16") && window.location.href.match(mt_config.rexp.forum_post) ) { GM_addStyle(` .comiis_messages img{ max-width: 100% !important; } `); } }, removeForumPostCommentFontStyle() { /* 移除评论区字体效果 */ if ( GM_getValue("v3") && window.location.href.match(mt_config.rexp.forum_post) ) { var hide = document.getElementsByTagName("font"); var postForumMain = document.querySelector(".comiis_ordertype") ? document.querySelector(".comiis_postlist.kqide .comiis_postli") .innerHTML : ""; for (let i = 0; i < hide.length; i++) { if (postForumMain.indexOf(hide[i].innerHTML) == -1) { console.log(hide[i].innerHTML); hide[i].removeAttribute("color"); hide[i].removeAttribute("style"); hide[i].removeAttribute("size"); } } var content = document.getElementsByClassName( "comiis_message bg_f view_all cl message" ); for (let i = 0; i < content.length; i++) { if (postForumMain.indexOf(content[i].innerHTML) == -1) { content[i].innerHTML = content[i].innerHTML.replace( mt_config.rexp.font_special, "" ); if (content[i].nextElementSibling.localName === "strike") { console.log("影响后面出现下划线的罪魁祸首", content[i]); content[i].nextElementSibling.outerHTML = content[ i ].nextElementSibling.outerHTML .replace(/^(\n|)/g, "") .replace(/<\/strike>$/g, ""); } } } document .querySelectorAll(".comiis_postli.comiis_list_readimgs.nfqsqi") .forEach((item) => { if (item.parentElement.localName === "strike") { try { item.parentElement.outerHTML = item.parentElement.outerHTML .replace(/^(\n|)/g, "") .replace(/<\/strike>$/g, ""); } catch (error) {} } }); } }, removeForumPostFontStyle() { /* 移除帖子内的字体style */ if ( GM_getValue("v1") && window.location.href.match(mt_config.rexp.forum_post) ) { if ($jq(".comiis_a.comiis_message_table.cl").eq(0).html()) { $jq(".comiis_a.comiis_message_table.cl") .eq(0) .html( $jq(".comiis_a.comiis_message_table.cl") .eq(0) .html() .replace(mt_config.rexp.font_special, "") ); } } }, repairClearSearchInput() { /* 修复搜索的清空按钮 */ if ( GM_getValue("v36") && window.location.href.match(mt_config.rexp.search_url) ) { let $search_input = $jq(".ssclose.bg_e.f_e"); if ($search_input) { $search_input.click(function (e) { e.preventDefault(); $jq("#scform_srchtxt").val(""); }); } else { log.error("搜索界面: 获取清空按钮失败"); } } }, repairUnableToEnterOtherSpaceCorrectly() { /* 修复无法正确进入别人的空间 */ if (!GM_getValue("v37")) { return; } if (window.location.href.match(mt_config.rexp.home_url_brief)) { let href_params = window.location.href.match(/home.php\?(.+)/gi); href_params = href_params[href_params.length - 1]; let params_split = href_params.split("&"); if ( params_split.length == 2 && href_params.indexOf("uid=") != -1 && href_params.indexOf("mod=space") != -1 ) { window.location.href = window.location.href + "&do=profile"; } } if (window.location.href.match(mt_config.rexp.home_url_at)) { let href_params = window.location.href.match(/space-uid-(.+).html/i); href_params = href_params[href_params.length - 1]; window.location.href = `https://bbs.binmt.cc/home.php?mod=space&uid=${href_params}&do=profile`; } }, async searchHistory() { /* 搜索历史 */ class searchSelect { constructor(config) { this.parentDOM = config.parentDOM ? config.parentDOM : null; this.list = this.arrayDistinct( config.list ? config.list : [] ); /* 用于搜索的数组 */ this.showList = this.list.length ? this.list : []; /* 用于显示在界面上的数组 */ this.inputValueChangeEvent = config.inputValueChangeEvent ? config.inputValueChangeEvent : () => { return []; }; this.css = { falInDuration: config?.css?.falInDuration ? config?.css?.falInDuration : 0.5, falInTiming: config?.css?.falInTiming ? config?.css?.falInTiming : "linear", falOutDuration: config?.css?.falOutDuration ? config?.css?.falOutDuration : 0.5, falOutTiming: config?.css?.falOutTiming ? config?.css?.falOutTiming : "linear", PaddingTop: config?.css?.PaddingTop ? config?.css?.PaddingTop : 8 /* 选择框距离输入框距离 */, }; this.searchSelectClassName = config.searchSelectClassName ? config.searchSelectClassName : "WhiteSevsSearchSelect"; /* 可修改div */ this.searchSelectHintClassName = config.searchSelectHintClassName ? config.searchSelectHintClassName : "whiteSevSearchHint"; /* 可修改ul */ this.searchSelectHTMLNoData = config.searchSelectHTMLNoData ? `
  • ${config.searchSelectHTMLNoData}
  • ` : '
  • 暂无其它数据
  • '; this.searchSelectHTML = ``; this.searchSelectDeleteItemHTML = ` `; this.searchSelectDeleteItemClicked = false; this.searchSelectCss = ``; if ( document.querySelector(`.${this.searchSelectClassName}`) == null ) { document.body.appendChild( this.parseTextToDOM(this.searchSelectHTML) ); document.body.appendChild( this.parseTextToDOM(this.searchSelectCss) ); } this.setParentEvent(); this.setItemEvent(); if (this.showList.length !== 0) { this.update(this.showList); } } parseTextToDOM(arg) { arg = arg .replace(/^[\n|\s]*/g, "") .replace(/[\n|\s]*$/g, ""); /* 去除前后的换行和空格 */ var objE = document.createElement("div"); objE.innerHTML = arg; var result = objE.childNodes.length == 1 ? objE.childNodes[0] : objE.childNodes; return result; } addSearching() { document .querySelector(`ul.${this.searchSelectHintClassName}`) .appendChild( this.parseTextToDOM(`
  • 正在搜索中...
  • `) ); } removeSearching() { document .querySelector(`ul.${this.searchSelectHintClassName} .searching`) ?.remove(); } update(data) { /* 更新页面显示的搜索结果 */ if (!(data instanceof Array)) { console.log(data); throw "传入的数据不是数组"; } this.showList = this.arrayDistinct(data); document .querySelectorAll(`ul.${this.searchSelectHintClassName} li`) .forEach((item) => { item?.remove(); }); let that = this; var parentUlDOM = document.querySelector( `ul.${this.searchSelectHintClassName}` ); if (this.showList.length === 0) { this.clear(); if (this.parentDOM.value === "") { document .querySelectorAll(`ul.${this.searchSelectHintClassName} li`) .forEach((item) => { item?.remove(); }); this.list.forEach((item, index) => { parentUlDOM.appendChild( this.parseTextToDOM( `
  • ${item}${that.searchSelectDeleteItemHTML}
  • ` ) ); }); this.setItemEvent(); } else { this.parentDOM.dispatchEvent(new Event("focus")); } } else { this.showList.forEach((item, index) => { parentUlDOM.appendChild( this.parseTextToDOM( `
  • ${item}${that.searchSelectDeleteItemHTML}
  • ` ) ); }); this.setItemEvent(); } } arrayDistinct(data) { /* 数组去重 */ var result = []; data = new Set(data); for (let item of data.values()) { result = [item, ...result]; } return result; } clear() { this.showList = []; document .querySelectorAll(`ul.${this.searchSelectHintClassName} li`) .forEach((item) => { item?.remove(); }); document .querySelector(`ul.${this.searchSelectHintClassName}`) ?.appendChild(this.parseTextToDOM(this.searchSelectHTMLNoData)); } hide() { document .querySelector(`div.${this.searchSelectClassName}`) ?.setAttribute("style", "display: none;"); } show() { document .querySelector(`div.${this.searchSelectClassName}`) ?.removeAttribute("style"); } setParentValue(value) { this.parentDOM.value = value; } setParentEvent() { let that = this; function _focus_event_(event) { // event.stopPropagation(); document .querySelector(`div.${that.searchSelectClassName}`) .setAttribute( "style", ` -moz-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming}; -webkit-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming}; -o-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming}; -ms-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming}; ` ); } function _blur_event_(event) { setTimeout(() => { if (that.searchSelectDeleteItemClicked) { return; } if ( getComputedStyle( document.querySelector(`div.${that.searchSelectClassName}`) ).display === "none" ) { return; } document .querySelector(`div.${that.searchSelectClassName}`) .setAttribute( "style", ` -moz-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming}; -webkit-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming}; -o-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming}; -ms-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming}; ` ); setTimeout(() => { document .querySelector(`div.${that.searchSelectClassName}`) .setAttribute("style", "display:none;"); }, that.falOutDuration * 1000); }, 100); } async function _propertychange_event_(event) { that.parentDOM.dispatchEvent(new Event("focus")); var getListResult = await that.getList(event.target.value); that.update(getListResult); } this.parentDOM?.setAttribute( "autocomplete", "off" ); /* 禁用输入框自动提示 */ this.parentDOM.addEventListener( "focus", function (event) { _focus_event_(event); }, true ); this.parentDOM.addEventListener( "click", function (event) { event.target.dispatchEvent(new Event("focus")); }, true ); this.parentDOM.addEventListener( "blur", function (event) { _blur_event_(event); }, false ); this.parentDOM.addEventListener( "input", function (event) { _propertychange_event_(event); }, true ); document.addEventListener("click", function () { var checkDOM = document.querySelector( "ul." + that.searchSelectHintClassName ); var mouseClickPosX = Number( window.event.clientX ); /* 鼠标相对屏幕横坐标 */ var mouseClickPosY = Number( window.event.clientY ); /* 鼠标相对屏幕纵坐标 */ var elementPosXLeft = Number( checkDOM.getBoundingClientRect().left ); /* 要检测的元素的相对屏幕的横坐标最左边 */ var elementPosXRight = Number( checkDOM.getBoundingClientRect().right ); /* 要检测的元素的相对屏幕的横坐标最右边 */ var elementPosYTop = Number( checkDOM.getBoundingClientRect().top ); /* 要检测的元素的相对屏幕的纵坐标最上边 */ var elementPosYBottom = Number( checkDOM.getBoundingClientRect().bottom ); /* 要检测的元素的相对屏幕的纵坐标最下边 */ if ( !( mouseClickPosX >= elementPosXLeft && mouseClickPosX <= elementPosXRight && mouseClickPosY >= elementPosYTop && mouseClickPosY <= elementPosYBottom ) && !( checkDOM.innerHTML.indexOf(window.event.target.innerHTML) !== -1 ) ) { that.searchSelectDeleteItemClicked = false; that.parentDOM.dispatchEvent(new Event("blur")); } }); } setItemEvent() { let that = this; document .querySelectorAll( `div.${this.searchSelectClassName} ul.${this.searchSelectHintClassName} li` ) .forEach((item, index) => { ((v, i) => { v.addEventListener( "click", function (event) { event.stopPropagation(); that.searchSelectDeleteItemClicked = false; that.parentDOM.dispatchEvent(new Event("focus")); if (event.target.localName === "li") { that.parentDOM.value = this.innerText; that.parentDOM.dispatchEvent(new Event("blur")); } else { that.searchSelectDeleteItemClicked = true; var dataId = parseInt(v.getAttribute("data-id")); console.log("删除 " + that.showList[dataId]); that.list.forEach((item, index) => { if (item === this.innerText) { that.list.splice(index, 1); return; } }); that.showList.splice(dataId, 1); v.remove(); document .querySelectorAll( `ul.${that.searchSelectHintClassName} li` ) .forEach((item, index) => { item.setAttribute("data-id", index); }); that.list = that.list; that.showList = that.showList; GM_setValue("search_history", that.list); if (that.list.length === 0) { that.clear(); } } }, true ); })(item, index); }); } getList(text) { var event = {}; var that = this; event.userInputText = text; event.target = this.parentDOM; event.list = this.list; event.showList = this.showList; this.addSearching(); return new Promise((res) => { var result = that.inputValueChangeEvent(event); if (this.parentDOM.value !== "" && result.length == 0) { this.parentDOM.dispatchEvent(new Event("focus")); } that.removeSearching(); res(result); }); } } if ( GM_getValue("v19") && location.href.match(mt_config.rexp.search_url) ) { GM_addStyle(` #comiis_search_noe{ display: none !important; } #comiis_search_two{ display: block !important; } `); var searchHistoryList = await GM_getValue("search_history", []); new searchSelect({ parentDOM: document.querySelector("#scform_srchtxt"), list: searchHistoryList, inputValueChangeEvent: (event) => { var result = []; event.userInputText = event.userInputText.trim(); if (event.userInputText == "") { return result; } event.list.forEach((item) => { if ( item.match( event.userInputText.replace( /[\-\/\\\^\$\*\+\?\.\(\)\|\[\]\{\}]/g, "\\$&" ) ) ) { result = [item, ...result]; } }); return result; }, }); function search_event() { /* 搜索历史事件 */ /* 搜索界面增加关闭按钮事件,清空input内容 */ /* 点击搜索保存搜索记录 */ $jq("#scform_submit").click(function () { let getsearchtext = $jq("#scform_srchtxt").val(); if (getsearchtext != null && getsearchtext != "") { let search_history_array = new Array(getsearchtext); let has_history = GM_getValue("search_history"); if (has_history != null) { if ($jq.inArray(getsearchtext, has_history) != -1) { console.log("已有该搜索历史记录"); search_history_array = has_history; } else { console.log("无该记录,追加"); search_history_array = search_history_array.concat(has_history); } } else { console.log("空记录,添加"); } GM_setValue("search_history", search_history_array); } }); } function add_search_history() { /* 搜索界面添加搜索历史记录 */ $jq("#scform_srchtxt").attr("list", "search_history"); var search_history_list = GM_getValue("search_history"); var dom_datalist = document.createElement("datalist"); dom_datalist.id = "search_history"; var option_text = ""; if (search_history_list) { for (var i = 0; i < search_history_list.length; i++) { option_text = option_text + ' `, }, 建议反馈: { className: "gm_user_select_feedback", optionHTML: ` `, }, 站务专区: { className: "gm_user_select_depot", optionHTML: ` `, }, }; if (classifyClassNameDict[section_dict[fid]]) { if ($jq(".comiis_post_from .styli_tit:contains('分类')").length) { $jq(".comiis_post_from .styli_tit:contains('分类')") .parent() .remove(); } $jq(".comiis_stylino.comiis_needmessage").before( $jq(`
  • 分类
  • `) ); } else { Object.keys(classifyClassNameDict).forEach(function (key) { $jq( ".comiis_post_from ." + classifyClassNameDict[key]["className"] ).remove(); }); } $jq("#postform").attr("action", postSection); }); } else { selectNode.attr("disabled", true); } selectNode.val(currentSection).trigger("change"); }, setDynamicAvatar() { /* 设置动态头像 */ if ( !window.location.href.match(mt_config.rexp.data_setting_url) || !GM_getValue("v51", false) ) { return; } let formhash = $jq(".sidenv_exit a:nth-child(1)") .attr("href") .match(/formhash=([0-9a-zA-Z]+)/); let uid = $jq(".sidenv_exit a:nth-child(2)") .attr("href") .match(/uid=([0-9]+)/); let bigStatus = false; let mediumStatus = false; let smallStatus = false; formhash = formhash[formhash.length - 1]; uid = uid[uid.length - 1]; let dynamicAvater = $jq(`
    修改动态头像
    `); function getStatus() { return bigStatus && mediumStatus && smallStatus; } function getPCUploadNewAvater() { return new Promise((res) => { GM_xmlhttpRequest({ url: "https://bbs.binmt.cc/home.php?mod=spacecp&ac=avatar", method: "GET", headers: { "User-Agent": Utils.getRandomPCUA(), }, onload: function (resp) { res(resp.responseText); }, onerror: function () { popup2.toast("网络异常,请重新获取"); res(""); }, }); }); } $jq(".comiis_edit_avatar").after(dynamicAvater); dynamicAvater.on("click", () => { popup2.confirm({ text: `

    修改动态头像

    1. 电脑版帖内头像: 200×250

    🤡请先上传图片

    2. 一般通用的头像: 120×120

    🤡请先上传图片

    3. 电脑版右上角小头像: 48×48

    🤡请先上传图片

    `, mask: true, only: true, ok: { text: "上传", callback: async () => { if (!getStatus()) { popup2.toast("图片校验不通过"); return; } popup2.mask_loading_show(); popup2.toast("正在处理数据中..."); let baseBig = await Utils.asyncFileToBase64( $jq("#comiis_file_dynamic_avater_big").prop("files")[0] ); let baseMedium = await Utils.asyncFileToBase64( $jq("#comiis_file_dynamic_avater_medium").prop("files")[0] ); let baseSmall = await Utils.asyncFileToBase64( $jq("#comiis_file_dynamic_avater_small").prop("files")[0] ); let base64Arr = [baseBig, baseMedium, baseSmall]; const dataArr = base64Arr.map((str) => str.substr(str.indexOf(",") + 1) ); //拿到3个头像的Base64字符串 let data_resp = await getPCUploadNewAvater(); if (data_resp == "") { popup2.toast("获取PC数据失败"); popup2.mask_close(); return; } let data = data_resp.match(/var[\s]*data[\s]*=[\s]*"(.+?)"/); if (data == null || data.length != 2) { popup2.toast("获取变量-data失败"); popup2.mask_close(); return; } data = data[data.length - 1]; let data_split = data.split(","); let uploadUrl = data_split[data_split.indexOf("src") + 1].replace( "images/camera.swf?inajax=1", "index.php?m=user&a=rectavatar&base64=yes" ); let formData = new FormData(); formData.append("Filedata", ""); formData.append("avatar1", dataArr[0]); formData.append("avatar2", dataArr[1]); formData.append("avatar3", dataArr[2]); formData.append("formhash", formhash); GM_xmlhttpRequest({ url: uploadUrl, method: "POST", data: formData, headers: { origin: "https://bbs.binmt.cc", referer: "https://bbs.binmt.cc/home.php?mod=spacecp&ac=avatar", accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "User-Agent": Utils.getRandomPCUA(), }, onload: function (resp) { let text = resp.responseText; if ( text.indexOf("window.parent.postMessage('success','*')") != -1 ) { popup2.toast("上传成功"); popup2.confirm_close(); setTimeout(() => { window.location.reload(); }, 1500); } else { popup2.toast(text); } }, onerror: function () { popup2.toast("网络异常,请重新获取"); }, }); }, }, }); }); $jq(document).on( "change", "#popup2-confirm input[type='file']", function () { let fileObj = $jq(this); if (fileObj.prop("files").length == 0) { return; } let statusObj = fileObj.parent().find(".status"); let maxWidth = parseInt(fileObj.attr("data-maxwidth")); let maxHeight = parseInt(fileObj.attr("data-maxheight")); statusObj.text("🤡获取尺寸大小中..."); let uploadImageFile = fileObj.prop("files")[0]; let tmpImage = new Image(); let reader = new FileReader(); reader.readAsDataURL(uploadImageFile); reader.onload = function (e) { tmpImage.src = e.target.result; tmpImage.onload = function () { if (fileObj.attr("id") == "comiis_file_dynamic_avater_big") { if (this.width > maxWidth || this.height > maxHeight) { bigStatus = false; fileObj.val(""); statusObj.text( "🤡校验失败,图片尺寸不符合 " + this.width + "×" + this.height ); return; } bigStatus = true; } else if ( fileObj.attr("id") == "comiis_file_dynamic_avater_medium" ) { if (this.width > maxWidth || this.height > maxHeight) { mediumStatus = false; fileObj.val(""); statusObj.text( "🤡校验失败,图片尺寸不符合 " + this.width + "×" + this.height ); return; } mediumStatus = true; } else { if (this.width > maxWidth || this.height > maxHeight) { smallStatus = false; fileObj.val(""); statusObj.text( "🤡校验失败,图片尺寸不符合 " + this.width + "×" + this.height ); return; } smallStatus = true; } statusObj.text("🤣 通过 " + this.width + "×" + this.height); }; }; } ); $jq("#comiis_file_dynamic_avater_big").on("change", function () { let maxWidth = 200; let maxHeight = 250; let uploadImageFile = this.files[0]; let tmpImage = new Image(); let reader = new FileReader(); reader.readAsDataURL(uploadImageFile); reader.onload = function (e) { tmpImage.src = e.target.result; tmpImage.onload = function () { if (this.width > maxWidth || this.height > maxHeight) { $jq("#comiis_file_dynamic_avater_big").val(""); popup2.toast({ text: "图片尺寸超出,当前宽:" + this.width + " 高:" + this.height, delayTime: 4000, }); return; } }; }; }); $jq("#comiis_file_dynamic_avater_medium").on("change", function () { let maxWidth = 120; let maxHeight = 120; let uploadImageFile = this.files[0]; let tmpImage = new Image(); let reader = new FileReader(); reader.readAsDataURL(uploadImageFile); reader.onload = function (e) { tmpImage.src = e.target.result; tmpImage.onload = function () { if (this.width > maxWidth || this.height > maxHeight) { $jq("#comiis_file_dynamic_avater_medium").val(""); popup2.toast({ text: "图片尺寸超出,当前宽:" + this.width + " 高:" + this.height, delayTime: 4000, }); return; } }; }; }); $jq("#comiis_file_dynamic_avater_small").on("change", function () { let maxWidth = 48; let maxHeight = 48; let uploadImageFile = this.files[0]; let tmpImage = new Image(); let reader = new FileReader(); reader.readAsDataURL(uploadImageFile); reader.onload = function (e) { tmpImage.src = e.target.result; tmpImage.onload = function () { if (this.width > maxWidth || this.height > maxHeight) { $jq("#comiis_file_dynamic_avater_small").val(""); popup2.toast({ text: "图片尺寸超出,当前宽:" + this.width + " 高:" + this.height, delayTime: 4000, }); return; } }; }; }); }, shieldPlate() { /* 屏蔽板块 */ if (window.location.href.match(mt_config.rexp.forum_guide_url)) { let infos = document.querySelectorAll( ".comiis_forumlist .forumlist_li" ); let black_list = GM_getValue("blacklistplate") || ""; let black_list_array = black_list.split("、"); Array.from(infos).forEach((info) => { let from_plate = ( info.querySelector(".forumlist_li_time a.f_d") || info.querySelector(".comiis_xznalist_bk.cl") ).outerText; from_plate = from_plate.replace(//g, ""); from_plate = from_plate.replace(/\s*/g, ""); from_plate = from_plate.replace("来自", ""); if (black_list_array.indexOf(from_plate) != -1) { console.log("屏蔽目标板块:" + from_plate); info.setAttribute("style", "display:none !important;"); } }); } }, shieldUser() { /* 屏蔽用户 */ if ( window.location.href.match(mt_config.rexp.forum_guide_url) || window.location.href.match(mt_config.rexp.plate_url) || window.location.href.match(mt_config.rexp.forum_post) ) { let infos = document.querySelectorAll( ".comiis_forumlist .forumlist_li" ); /* 帖子外 */ if (!infos.length) { /* 帖子内 */ infos = document.querySelectorAll(".comiis_postlist .comiis_postli"); if (!infos.length) { return; } } let black_list = GM_getValue("blacklistuid") ? GM_getValue("blacklistuid") : ""; let black_list_array = black_list.split(","); Array.from(infos).forEach((info) => { let usr = info.getElementsByClassName("wblist_tximg"); if (!usr.length) { usr = info.getElementsByClassName("postli_top_tximg"); if (!usr.length) { return; } } usr = usr[0].href; let usr_uid = usr.match(mt_config.rexp.mt_uid)[1]; if (black_list_array.indexOf(usr_uid) != -1) { console.log("屏蔽用户:" + usr_uid); info.setAttribute("style", "display:none !important;"); } }); } }, showLatestPostForm() { /* 导读新增显示最新帖子 */ if ( !window.location.href.match(mt_config.rexp.navigation_url) || !GM_getValue("v53", false) ) { return; } function getLatestPostForm() { /* 获取轮播的最新的帖子 */ return new Promise((res) => { GM_xmlhttpRequest({ url: "https://bbs.binmt.cc/forum.php?mod=guide&view=hot", method: "get", timeout: 5000, async: false, headers: { accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "user-agent": Utils.getRandomAndroidUA(), }, onload: function (resp) { var respHTML = $jq(resp.responseText); var postFormList = respHTML.find( 'div.comiis_mh_kxtxt div[id*="comiis_mh_kxtxt"] ul' ); if (postFormList.length === 0) { popup2.toast("获取轮播失败"); res([]); } else { var result = []; postFormList[postFormList.length - 1] .querySelectorAll("a") .forEach((item) => { result = [ { href: item.getAttribute("href"), title: item.getAttribute("title"), }, ...result, ]; }); res(result); } }, onerror: function (resp) { console.log(resp); popup2.toast("网络异常,获取轮播失败"); res([]); }, }); }); } getLatestPostForm().then((result) => { if (result.length) { GM_addStyle(` div.comiis_mh_kxtxt{ margin-top: 10px; } div.comiis_mh_kxtxt li{ height: 30px; width: 100%; display: flex; align-items: center; padding: 0px 10px; } div.comiis_mh_kxtxt span{ background: #FF705E; color: #fff; float: left; height: 18px; line-height: 18px; padding: 0 3px; margin-top: 2px; margin-right: 10px; overflow: hidden; border-radius: 2px; } div.comiis_mh_kxtxt a{ display: block; font-size: 14px; font-weight: 400; height: 22px; line-height: 22px; overflow: hidden; } `); var latestPostFormHTML = ""; console.log(result); result.sort( Utils.sortListByProperty((item) => { var forumPostNum = item["href"].match(/thread-(.+?)-/i); forumPostNum = forumPostNum[forumPostNum.length - 1]; forumPostNum = parseInt(forumPostNum); return forumPostNum; }, true) ); console.log(result); result.forEach((item) => { latestPostFormHTML += `
  • 新帖 ${item.title}
  • `; }); $jq(".comiis_forumlist.comiis_xznlist").before( $jq( `
      ${latestPostFormHTML}
    ` ) ); } }); }, showSignInRanking() { /* 显示签到的最先几个人,最多10个,和顶部的今日签到之星 */ if (window.location.href.match(mt_config.rexp.k_misign_sign)) { let today_ranking_ele = document.querySelector( ".comiis_topnv .comiis_flex .flex" ); today_ranking_ele.after( $jq( `
  • 今日最先
  • ` )[0] ); let getMaxPage = (urlextra) => { return new Promise((res) => { GM_xmlhttpRequest({ url: "https://bbs.binmt.cc/k_misign-sign.html?operation=" + urlextra, async: false, responseType: "html", headers: { "User-Agent": Utils.getRandomPCUA(), }, onload: function (resp) { let last_page = $jq(resp.responseText).find( "#J_list_detail .pg span" ); if ( last_page.length && typeof last_page[0].title != "undefined" ) { let last_page_match = last_page[0].title.match(/([0-9]+)/); if (last_page_match.length == 2) { res(last_page_match[last_page_match.length - 1]); } else { popup2.toast("获取页失败"); res(0); } } else { popup2.toast("请求最先签到的页失败"); res(0); } }, onerror: function (resp) { console.log(resp); popup2.toast("网络异常,请重新获取"); res(0); }, }); }); }; let getPagePeople = (page) => { return new Promise((res) => { GM_xmlhttpRequest({ url: "https://bbs.binmt.cc/k_misign-sign.html?operation=list&op=&page=" + page, async: false, responseType: "html", headers: { "User-Agent": Utils.getRandomPCUA(), }, onload: function (resp) { let peoples = $jq(resp.responseText).find( "#J_list_detail tbody tr" ); let ret_array = []; if ( peoples.length == 2 && peoples[0].textContent.indexOf("暂无内容") != -1 ) { res(ret_array); return; } for (let i = 1; i <= peoples.length - 2; i++) { let people = peoples[i]; let ret_json = {}; let user_name = people.children[0].getElementsByTagName("a")[0].textContent; let space_url = people.children[0].getElementsByTagName("a")[0].href; let uid = space_url.match(/space-uid-([0-9]*)/)[1]; let sign_all_days = people.children[1].textContent; let sign_month_days = people.children[2].textContent; let sign_time = people.children[3].textContent; let sign_reward = people.children[5].textContent; ret_json["user"] = user_name; ret_json["uid"] = uid; ret_json["avatar"] = "https://avatar-bbs.mt2.cn/uc_server/avatar.php?uid=" + uid + "&size=small"; ret_json["days"] = sign_all_days; ret_json["monthDays"] = sign_month_days; ret_json["time"] = sign_time; ret_json["reward"] = sign_reward; ret_array = ret_array.concat(ret_json); } res(ret_array); }, onerror: function (resp) { console.log(resp); res({}); }, }); }); }; function changeRankList(data, listtype) { $jq("#ranklist").html(data); $jq("#ranklist").attr("listtype", listtype); } ajaxlist = async (listtype) => { listtype = listtype; if (listtype == "today") { loadingdelay = false; urlextra = "list&op=today"; } else if (listtype == "month") { loadingdelay = false; urlextra = "list&op=month"; } else if (listtype == "zong") { loadingdelay = false; urlextra = "list&op=zong"; } else if (listtype == "calendar") { loadingdelay = true; urlextra = "calendar"; } else { loadingdelay = false; urlextra = "list"; } /* alert(loadingdelay); */ if (listtype == "todayLatest") { loadingdelay = false; urlextra = "list&op=&page=0"; let maxPage = await getMaxPage(urlextra); if (maxPage == 0) { return; } let latestPeople = await getPagePeople(maxPage); latestPeople.reverse(); if (latestPeople.length < 10) { let latestPeople_2 = await getPagePeople(maxPage - 1); latestPeople_2.reverse(); latestPeople = latestPeople.concat(latestPeople_2); latestPeople.reverse(); } let peopleHTML = ""; latestPeople.reverse(); console.log(latestPeople); latestPeople.forEach((people) => { peopleHTML = peopleHTML + `

    ` + people["user"] + `` + people["time"] + `总天数 ` + people["days"] + `天

    月天数 ` + people["monthDays"] + ` 天 , 上次奖励 ` + people["reward"] + `

    `; }); let latestHTML = `
  • ` + peopleHTML + `
    `; changeRankList(latestHTML, listtype); } else { $jq.ajax({ type: "GET", url: "plugin.php?id=k_misign:sign&operation=" + urlextra, async: false, dataType: "html", success: function (data) { /* console.log(data); */ data = data.replace( `今日排行`, `今日排行
  • 今日最先
  • ` ); changeRankList(data, listtype); }, complete: function (XHR, TS) { XHR = null; }, }); } }; } }, showTodayStar() { /* 显示今日之星,在签到页上 */ if ( GM_getValue("v33") && window.location.href.match(mt_config.rexp.k_misign_sign) ) { let todayStarParent = $jq(".pg_k_misign .comiis_qdinfo"); let todayStar = document.createElement("ul"); GM_xmlhttpRequest({ url: "/k_misign-sign.html", method: "get", async: false, headers: { "User-Agent": Utils.getRandomPCUA(), }, onload: (r) => { let html = $jq(r.responseText); let todatastarele = html.find("#pt span.xg1"); if (!todatastarele.length) { return; } let todaypeople = todatastarele[0].textContent.replace( "今日签到之星:", "" ); todayStar.innerHTML = '
  • 今日签到之星' + todaypeople + "
  • "; let comiis_space_box_height = getComputedStyle( $jq(".comiis_space_box")[0], null )["height"].replace("px", ""); let comiis_space_box_padding_bottom = getComputedStyle( $jq(".comiis_space_box")[0], null )["padding-bottom"].replace("px", ""); comiis_space_box_height = parseInt(comiis_space_box_height); comiis_space_box_padding_bottom = parseInt( comiis_space_box_padding_bottom ); let total_height = comiis_space_box_height + comiis_space_box_padding_bottom + 50; GM_addStyle(` .comiis_space_box{ height: ${total_height}px; background-size: 100% 100%; } .pg_k_misign .comiis_qdinfo{ height: 110px !important; }`); todayStarParent.append(todayStar); }, onerror: (r) => { console.log(r); log.error("请求今日之星失败"); }, }); } }, showUserUID() { /* 显示用户的uid */ if ( GM_getValue("v15") && (window.location.href.match(mt_config.rexp.forum_post_guide_url) || window.location.href.match(mt_config.rexp.forum_post) || window.location.href.match(mt_config.rexp.plate_url) || window.location.href.match(mt_config.rexp.search_url) || window.location.href.match( /bbs.binmt.cc\/home.php\?mod=space&do=thread&view=me/ ) || window.location.href.match( /home.php\?mod=space&uid=.+&do=thread&view=me/ )) ) { if (!window.GM_isaddShowUidCss) { window.GM_isaddShowUidCss = true; GM_addStyle(` .postli_top_tximg + h2{ height: auto; } `); } window.findUserFormList = false; window.findUserFormListNums = 0; let findSetInval = setInterval(function () { let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : []; formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList; formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList; window.findUserFormList = formList.length ? true : false; if (findUserFormListNums >= 16) { console.log("已循环16次,未找到帖子"); clearInterval(findSetInval); } if (window.findUserFormList) { GM_addStyle(` .comiis_postli_top.bg_f.b_t h2{ height: auto; }`); function matchUIDByArray(data) { for (let i = 0; i < data.length; i++) { let url = data[i].href; let uid = url.match(mt_config.rexp.mt_uid); if (uid) { return uid[1]; } } return null; } $jq.each(formList, (index, value) => { let mtUIDOM = value.getElementsByClassName("mt_uid_set"); if (!mtUIDOM.length) { let childrenByATagetElement = value.getElementsByTagName("a"); let mt_uid = null; mt_uid = matchUIDByArray(childrenByATagetElement); if (mt_uid != null) { let uid_control = document.createElement("a"); let mtUidDomInsertElement = value.getElementsByClassName("top_lev")[0]; let uid_control_height = getComputedStyle( mtUidDomInsertElement, null )["height"]; let uid_control_margin = getComputedStyle( mtUidDomInsertElement, null )["margin"]; let uid_control_padding = getComputedStyle( mtUidDomInsertElement, null )["padding"]; let uid_control_line_height = getComputedStyle( mtUidDomInsertElement, null )["line-height"]; let uid_control_font = getComputedStyle( mtUidDomInsertElement, null )["font"]; let uid_control_bg_color = "#FF7600"; uid_control.className = "mt_uid_set"; uid_control.style = ` font: ${uid_control_font}; background: ${uid_control_bg_color}; color: white; float: left; margin: ${uid_control_margin}; padding: ${uid_control_padding}; height: ${uid_control_height}; line-height: ${uid_control_line_height}; border-radius: 1.5px;`; uid_control.innerHTML = "UID:" + mt_uid; uid_control.onclick = function () { try { GM_setClipboard(mt_uid); popup2.toast(`${mt_uid}已复制`); console.log("复制:", mt_uid); } catch (err) { popup2.toast(`${mt_uid}复制失败`); console.log("复制失败:" + mt_uid, err); } }; mtUidDomInsertElement.parentElement.append(uid_control); } } }); console.log("成功找到帖子DOM"); clearInterval(findSetInval); } else { findUserFormListNums += 1; } }, 800); } }, async showSpaceContreteReply() { /* 显示空间-帖子-具体回复 */ if ( !window.location.href.match(mt_config.rexp.space_post) || !GM_getValue("v52") ) { return; } function getPCReply() { /* 获取PC端的回复内容 */ return new Promise((res) => { GM_xmlhttpRequest({ url: window.location.href, method: "get", async: false, headers: { "User-Agent": Utils.getRandomPCUA(), }, onload: (r) => { let pageHTML = $jq(r.responseText); let form = pageHTML.find("#delform tr.bw0_all+tr"); let arrayData = []; Array.from(form).forEach((v, i) => { let replyData = []; let tdHTML = $jq($jq(v).find("td")); let value = tdHTML?.html().replace(/^ /, ""); replyData = replyData.concat(value); let nextHTML = $jq(v).next(); for (let j = 0; j < pageHTML.find("#delform tr")?.length; j++) { if ( nextHTML.attr("class") === "bw0_all" || nextHTML.length == 0 ) { break; } let nextTdHTML = nextHTML?.find("td"); let nextValue = nextTdHTML?.html().replace(/^ /, ""); replyData = replyData.concat(nextValue); nextHTML = nextHTML.next(); } arrayData.push(replyData); }); res(arrayData); }, onerror: () => { console.log("网络异常,获取PC回复失败"); popup2.toast("网络异常,获取PC回复失败"); res(null); }, }); }); } function getFormList() { /* 获取当前页面所有帖子 */ let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : []; formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList; formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList; return formList; } var pcReplyArray = await getPCReply(); if (pcReplyArray == null) { return; } let formList = getFormList(); GM_addStyle(` div.contrete-reply{ padding: 5px 10px; border-top: 1px solid #f3f3f3; } div.contrete-reply a{ margin: 0px 10px; } `); Array.from(formList).forEach((v, i) => { Array.from(pcReplyArray[i]).forEach((v2, i2) => { $jq(v).append($jq(`
    ${v2}
    `)); }); }); }, userCheckBoxSettings() { /* 侧边栏配置项 */ function checkboxNode() { return $jq(".whitesevcheckbox"); } function selectedNodeText() { let selectedVal = selectNode().val(); return $jq(`.beauty-select option[value='${selectedVal}']`).text(); } function selectNode() { return $jq(".beauty-select"); } function setCodeNodeCheckedStatus(status) { /* 设置 开关的状态 */ status ? checkboxNode().removeClass("comiis_checkbox_close") : checkboxNode().addClass("comiis_checkbox_close"); } function setLastClickItem() { /* 初始化设置上次点击的select内容 */ let selectNodeNormalVal = GM_getValue("last") == null ? "v2" : GM_getValue("last"); selectNode().val(selectNodeNormalVal); setCodeNodeCheckedStatus( GM_getValue(selectNodeNormalVal) != null ? true : false ); } function setSelectNodeChangeEvent() { /* 设置选项的change事件 */ selectNode().change(function () { let selected_value = $jq(".beauty-select").val(); GM_setValue("last", selected_value); let check_value = GM_getValue(selected_value) != null ? true : false; setCodeNodeCheckedStatus(check_value); }); } function setCodeNodeClickEvent() { /* 设置开关的click事件 */ checkboxNode().on("click", (e) => { let selected_value = selectNode().val(); let check_value = GM_getValue(selected_value) != null ? false : true; check_value ? GM_setValue(selected_value, true) : GM_deleteValue(selected_value); let showText = check_value ? "设置-开启" : "设置-关闭"; popup2.toast(showText); setCodeNodeCheckedStatus(check_value); }); } function setSelectNodeCSS() { GM_addStyle(` .beauty-select{ background-color: #fff; height:28px; width: 160px; line-height:28px; border: 1px solid #ececec; background: url(w.png) no-repeat; background-position: 95% 50%; -webkit-appearance: none; /*去掉样式 for chrome*/ appearance:none;/*去掉样式*/ -moz-appearance:none;/*去掉样式*/ }`); } if (window.location.href.match(mt_config.rexp.bbs)) { var setting_content = document.createElement("li"); setting_content.className = "comiis_left_Touch"; setting_content.innerHTML = '
    " + '' + "
    "; GM_addStyle(` .comiis_sidenv_box ul.comiis_left_Touch.bdew li:nth-last-child(1) { margin-bottom: 10px; } `); $jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append( setting_content ); Utils.tryCatch(setSelectNodeCSS); Utils.tryCatch(setLastClickItem); Utils.tryCatch(setCodeNodeClickEvent); Utils.tryCatch(setSelectNodeChangeEvent); /* tryCatch(loadCheckboxTipResource); */ } }, }; function Hooks() { /* hook?用不到 */ return { initEnv: function () { Function.prototype.hook = function (realFunc, hookFunc, context) { var _context = null; /* 函数上下文 */ var _funcName = null; /* 函数名 */ _context = context || window; _funcName = getFuncName(this); _context["realFunc_" + _funcName] = this; console.log(window); if ( _context[_funcName].prototype && _context[_funcName].prototype.isHooked ) { console.log("Already has been hooked,unhook first"); return false; } function getFuncName(fn) { /* 获取函数名 */ var strFunc = fn.toString(); var _regex = /function\s+(\w+)\s*\(/; var patten = strFunc.match(_regex); if (patten) { return patten[1]; } return ""; } try { eval( "_context[_funcName] = function " + _funcName + "(){\n" + "var args = Array.prototype.slice.call(arguments,0);\n" + "var obj = this;\n" + "hookFunc.apply(obj,args);\n" + "return _context['realFunc_" + _funcName + "'].apply(obj,args);\n" + "};" ); _context[_funcName].prototype.isHooked = true; return true; } catch (e) { console.log("Hook failed,check the params."); return false; } }; Function.prototype.unhook = function (realFunc, funcName, context) { var _context = null; var _funcName = null; _context = context || window; _funcName = funcName; if (!_context[_funcName].prototype.isHooked) { console.log("No function is hooked on"); return false; } _context[_funcName] = _context["realFunc" + _funcName]; delete _context["realFunc_" + _funcName]; return true; }; }, cleanEnv: function () { if (Function.prototype.hasOwnProperty("hook")) { delete Function.prototype.hook; } if (Function.prototype.hasOwnProperty("unhook")) { delete Function.prototype.unhook; } return true; }, }; } function entrance() { /* 这是入口 */ if (!envIsMobile()) { console.log("PC端显示"); Utils.tryCatch(pc.repairPCNoLoadResource); $jq(document).ready(function () { Utils.tryCatch(pc.main); }); } else { console.log("移动端显示"); $jq(document).ready(function () { Utils.tryCatch(mobile.main); }); } } if (envCheck()) { $jq(document).ready(function () { entrance(); console.log(`执行完毕,耗时${Date.now() - mt_config.GMRunStartTime}ms`); }); } })();