// ==UserScript== // @name MT论坛 // @namespace http://tampermonkey.net/ // @description MT论坛效果增强,如自动签到、自动展开帖子、自动展开评论、显示uid、屏蔽用户、手机版小黑屋、今日签到之星、今日签到排名、帖外预览图片、搜索框清空按钮修复、个人空间正确进入等 // @version 2.4.2.1 // @author WhiteSevs // @icon https://bbs.binmt.cc/favicon.ico // @match *://bbs.binmt.cc/* // @compatible edge Beta/Dev/Candy 测试通过 // @compatible 火狐 测试通过 // @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 // @run-at document-start // @supportURL https://github.com/893177236/Monkey_script // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.4.1/jquery.min.js // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/jquery.nanogallery2.min.js // @require https://greasyfork.org/scripts/441331-md5/code/md5.js?version=1026891 // @downloadURL none // ==/UserScript== (function () { 'use strict'; const log = { success: (str) => { console.log("%c" + str, "color: #81b453"); }, error: (str) => { console.trace("%c" + str, "color: #f20000"); } } let mt_config = { dom_obj: { beauty_select: function () { //下拉列表对象 return document.getElementsByClassName("beauty-select")[0]; }, combobox_switch: function () { //复选框对象 return document.getElementsByClassName("switch_1")[0]; }, comiis_verify: function () { //帖子内各个人的信息节点【list】 return document.getElementsByClassName("comiis_verify"); }, comiis_formlist: function () { //导航中最新、热门、精华、恢复、抢沙发的各个帖子【list】 return document.getElementsByClassName("forumlist_li"); }, comiis_mmlist: function () { return document.getElementsByClassName("comiis_mmlist"); }, comiis_postli: function () { //帖子内评论,包括帖子内容主体,第一个就是主体【list】 return document.getElementsByClassName("comiis_postli comiis_list_readimgs nfqsqi") }, post_bottom_controls: function () { // 帖子底部一栏控件 return document.getElementsByClassName("comiis_znalist_bottom b_t cl") }, post_list_of_comments: function () { //帖子内评论列表 return $(".comiis_postlist.kqide"); }, post_next_commect: function () { //帖子内评论下一页的按钮 return document.querySelector("div.comiis_page.bg_f>a:nth-child(3)"); } }, rexp: { 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_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/g, //【我的】 个人信息页链接 home_space_pc_uid_url: /space-uid-(.*?).html/, //PC 个人空间链接uid reply_url: /bbs.binmt.cc\/forum.php\?mod=post&action=reply/g, // 回复的界面url sign_url: "", navigation_url: "", forum_post: /(bbs.binmt.cc\/thread-|bbs.binmt.cc\/forum.php\?mod=viewthread)/g, //帖子链接 forum_post_pc: /.*:\/\/bbs.binmt.cc\/thread.*/, //帖子链接-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=(.*)&/, //论坛账号的凭证 font_special: /| ||<\/font>|||||align=".*?"/g, //帖子内特殊字体格式 forum_post_guide_url: /bbs.binmt.cc\/page-[1-5].html|bbs.binmt.cc\/forum.php\?mod=guide/g, //帖子链接和导航链接 mt_uid: /uid=(\d+)/, nologin: /member.php\?mod=logging&action=login(|&mobile=2)/g, //未登录 pc_useragent: 'Windows', //pc识别 k_misign_sign: "bbs.binmt.cc\/k_misign-sign.html", } } function Latest_publication() { var ele = document.createElement('li'); var url = window.location.href; ele.id = "latest_publication"; ele.innerHTML = '最新发表<\/a>'; document.getElementsByClassName("wp comiis_nvbox cl")[0].children[1].appendChild(ele); if (url == 'https:\/\/bbs.binmt.cc\/forum.php?mod=guide&view=newthread') { document.getElementById("mn_forum_10").children[0].style = "background: url("; ele.style.cssText = 'background: url("https:\/\/cdn2.bbs.binmt.cc\/template\/comiis_mi\/img\/nv_a.png") repeat-x 50% -50px;'; } } function removeFontStyle() { // 移除帖子内容特殊字体 if (window.localStorage.getItem("v1") && location.href.match(mt_config.rexp.forum_post)) { var rule = mt_config.rexp.font_special; var h_content = document.getElementsByClassName("comiis_a comiis_message_table cl"); h_content[0].innerHTML = h_content[0].innerHTML.replace(rule, ''); } } function getLocalTime() { let GM_myDate = new Date; let GM_year = GM_myDate.getFullYear(); //获取当前年 let GM_mon = GM_myDate.getMonth() + 1; //获取当前月 let GM_date = GM_myDate.getDate(); let GM_alldate = GM_year.toString() + GM_mon.toString() + GM_date.toString(); GM_alldate = parseInt(GM_alldate); return GM_alldate } function getFormHash() { // 获取账号的formhash return document.querySelector("input[name=formhash]") ? document.querySelector("input[name=formhash]").value : document.querySelector("div[class=sidenv_exit]>a").href.match(mt_config.rexp.formhash)[1]; } function autoSignIn() { //mt签到 if (!window.localStorage.getItem("v17")) { console.log("尚未开启每日签到"); return; } if (GM_getValue("mt_sign") == getLocalTime()) { console.log("今日已签到"); return; } if ((document.querySelector("div[class=comiis_dlq]>a") != null) || (document.getElementsByClassName("sidenv_user")[0].href.match(mt_config.rexp.nologin) != null)) { console.log("当前账号尚未登录"); return; } let mtFormHash = getFormHash(); if (mtFormHash == null) { console.log("获取账号formhash失败"); return; } $.get("/k_misign-sign.html?operation=qiandao&format=button&formhash=" + mtFormHash + "&inajax=1&ajaxtarget=midaben_sign", function (data, status) { console.log(data.responseText); GM_setValue("mt_sign", getLocalTime()); window.location.reload(); }); } function searchHistory() { if (window.localStorage.getItem("v19") && location.href.match(mt_config.rexp.search_url)) { search_event(); add_search_history(); add_clear_history(); } } function search_event() { //搜索界面增加关闭按钮事件,清空input内容 //点击搜索保存搜索记录 $("#scform_submit").click(function () { let getsearchtext = $("#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 ($.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() { //搜索界面添加搜索历史记录 $("#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 + ''; } dom_datalist.innerHTML = option_text; $(".comiis_flex").append(dom_datalist); } } function add_clear_history() { //搜索界面添加清理历史记录和历史记录个数 let search_history_list = GM_getValue("search_history"); let search_history_nums = 0; if (search_history_list != null) { search_history_nums = search_history_list.length; } let clear_history_innerHTML = `搜索记录个数: ` + search_history_nums + `清理记录`; let insertdom = $(".comiis_p12.f14.bg_f.f_c.b_b.cl,.comiis_tagtit.b_b.f_c"); insertdom.before(clear_history_innerHTML); $(".btn_clear_search_history").click(function () { GM_deleteValue("search_history"); window.location.reload(); }) } function showTodayStar() { // 显示今日之星,在签到页上 if (window.localStorage.getItem("v33") && window.location.href.match(mt_config.rexp.k_misign_sign)) { let todayStarParent = $(".pg_k_misign .comiis_qdinfo"); let todayStar = document.createElement("ul"); GM_xmlhttpRequest({ url: "/k_misign-sign.html", method: 'get', async: false, headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" }, onload: (r) => { let html = $(r.response); let todatastarele = html.find("#pt span.xg1"); let todaypeople = todatastarele[0].textContent.replace("今日签到之星:", ''); todayStar.innerHTML = '今日签到之星' + todaypeople + ''; let comiis_space_box_height = getComputedStyle($(".comiis_space_box")[0], null)["height"].replace("px", ""); let comiis_space_box_padding_bottom = getComputedStyle($(".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("请求今日之星失败"); } }) } } function show_latest_sign() { // 显示签到的最先几个人,最多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($(`今日最先`)[0]); let getMaxPage = (urlextra) => { return new Promise(res => { GM_xmlhttpRequest({ url: "https://bbs.binmt.cc/k_misign-sign.html?operation=" + urlextra, async: false, dataType: 'html', headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" }, onload: function (resp) { let last_url = $(resp.response).find("#J_list_detail .pg .last")[0].href; let last_page = last_url.match(/page=([0-9]*)/)[1]; res(last_page); // console.log(data); // $("#ranklist").html(data); // $('#ranklist').attr('listtype', listtype); }, onerror: function (resp) { console.log(resp); 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, dataType: 'html', headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" }, onload: function (resp) { let peoples = $(resp.response).find("#J_list_detail tbody tr"); let ret_array = []; if (peoples.length == 2 && peoples[0].textContent.indexOf("暂无内容") != -1) { res(ret_array) } 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) { $("#ranklist").html(data); $('#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); 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 { $.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 } }); } } } } function setCheckBoxCSS() { var checkBox_css_ = document.createElement("style"); checkBox_css_.innerHTML = ` body{background:#000;margin:0;padding:0;} .wrapper{ display: -webkit-box; display: -ms-flexbox; display: flex; width: 400px; margin: 50vh auto 0; -ms-flex-wrap: wrap; flex-wrap: wrap; -webkit-transform: translateY(-50%); transform: translateY(-50%); } .switch_box{ display: -webkit-box; display: -ms-flexbox; display: flex; max-width: 200px; min-width: 200px; height: 200px; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; } /* Switch 1 Specific Styles Start */ .box_1{ background: #eee; } input[type="checkbox"].switch_1{ font-size: 14px; -webkit-appearance: none; -moz-appearance: none; appearance: none; width: 3.5em; height: 1.5em; background: #ddd; border-radius: 3em; position: relative; cursor: pointer; outline: none; -webkit-transition: all .2s ease-in-out; transition: all .2s ease-in-out; } input[type="checkbox"].switch_1:checked{ background: #0ebeff; } input[type="checkbox"].switch_1:after{ position: absolute; content: ""; width: 1.5em; height: 1.5em; border-radius: 50%; background: #fff; -webkit-box-shadow: 0 0 .25em rgba(0,0,0,.3); box-shadow: 0 0 .25em rgba(0,0,0,.3); -webkit-transform: scale(.7); transform: scale(.7); left: 0; -webkit-transition: all .2s ease-in-out; transition: all .2s ease-in-out; } input[type="checkbox"].switch_1:checked:after{ left: calc(100% - 1.5em); } /* Switch 1 Specific Style End */ /* Switch 4 Specific Style Start */ .box_4{ background: #eee; } .input_wrapper{ width: 80px; height: 40px; position: relative; cursor: pointer; } .input_wrapper input[type="checkbox"]{ width: 80px; height: 40px; cursor: pointer; -webkit-appearance: none; -moz-appearance: none; appearance: none; background: #315e7f; border-radius: 2px; position: relative; outline: 0; -webkit-transition: all .2s; transition: all .2s; } .input_wrapper input[type="checkbox"]:after{ position: absolute; content: ""; top: 3px; left: 3px; width: 34px; height: 34px; background: #dfeaec; z-index: 2; border-radius: 2px; -webkit-transition: all .35s; transition: all .35s; } .input_wrapper svg{ position: absolute; top: 50%; -webkit-transform-origin: 50% 50%; transform-origin: 50% 50%; fill: #fff; -webkit-transition: all .35s; transition: all .35s; z-index: 1; } .input_wrapper .is_checked{ width: 18px; left: 18%; -webkit-transform: translateX(190%) translateY(-30%) scale(0); transform: translateX(190%) translateY(-30%) scale(0); } .input_wrapper .is_unchecked{ width: 15px; right: 10%; -webkit-transform: translateX(0) translateY(-30%) scale(1); transform: translateX(0) translateY(-30%) scale(1); } /* Checked State */ .input_wrapper input[type="checkbox"]:checked{ background: #23da87; } .input_wrapper input[type="checkbox"]:checked:after{ left: calc(100% - 37px); } .input_wrapper input[type="checkbox"]:checked + .is_checked{ -webkit-transform: translateX(0) translateY(-30%) scale(1); transform: translateX(0) translateY(-30%) scale(1); } .input_wrapper input[type="checkbox"]:checked ~ .is_unchecked{ -webkit-transform: translateX(-190%) translateY(-30%) scale(0); transform: translateX(-190%) translateY(-30%) scale(0); } .beauty-select{ background-color: #fff; height:28px; width:180px; padding:0 10px; 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;/*去掉样式*/ } `; document.head.appendChild(checkBox_css_); } function set_select_clicked() { // document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").onclick = function () { mt_config.dom_obj.beauty_select().onclick = function (e) { // console.log(e); // var b = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").value; var selected_value = e.target.value; if (window.localStorage.getItem(selected_value)) { mt_config.dom_obj.combobox_switch().checked = true; } else { mt_config.dom_obj.combobox_switch().checked = false; } } } function set_select_change_clicked() { $('.beauty-select').change(function () { var select_value = $('.beauty-select').val(); // var a = document.getElementsByClassName("switch_1")[0]; window.localStorage.setItem("last", select_value); if (window.localStorage.getItem(select_value)) { mt_config.dom_obj.combobox_switch().checked = true; } else { mt_config.dom_obj.combobox_switch().checked = false; } }); } function set_checked_clicked() { //设置复选框点击事件特效 mt_config.dom_obj.combobox_switch().onclick = function () { // var a = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").value; var a = mt_config.dom_obj.beauty_select().value; var b = window.localStorage.getItem(a); if (b) { window.localStorage.removeItem(a); } else { window.localStorage.setItem(a, "true"); } var c = window.localStorage.getItem(a); // var d = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").selectedIndex; //当前索引值 // var e = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").options[d].text; //当前索引对应的文本 var d = mt_config.dom_obj.beauty_select().selectedIndex; var e = mt_config.dom_obj.beauty_select().options[d].text; if (c) { iosOverlay({ text: e + "已开启", duration: 1500, icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png" }); } else { iosOverlay({ text: e + "已关闭", duration: 1500, icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png" }); } } } function set_display_last_click() { //初始化设置上次点击的select内容 console.log("修改内容"); // var a = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select"); var last_select_value = window.localStorage.last; var combobox_switch = mt_config.dom_obj.combobox_switch(); mt_config.dom_obj.beauty_select().value = last_select_value; console.log("上次点击的选项是:" + mt_config.dom_obj.beauty_select().value) if (window.localStorage.getItem(last_select_value)) { combobox_switch.checked = true; } else { combobox_switch.checked = false; } } const blackHome = { httpGetSrc: async (url) => { return new Promise(res => { GM_xmlhttpRequest({ url: url, method: "GET", async: false, timeout: 5000, onload: (r) => { res(r.response); }, onerror: (r) => { console.log(r); res(); } }) }) }, loadJS: async (url) => { let ret = await blackHome.httpGetSrc(url); await eval(ret); }, loadCSS: async (url) => { let ret = await blackHome.httpGetSrc(url); GM_addStyle(ret); }, showBlackHomeView: async () => { // 显示小黑屋界面 $.NZ_MsgBox.alert({ title: "小黑屋名单", content: "获取中", type: "", location: "center", buttons: { confirm: { text: "确定" } } }); let blacklistret = await blackHome.getBlackList(''); let blacklist = eval('(' + blacklistret + ')'); let blackContent = ''; function sortByProperTyName(data, propertyname) { let _list_ = []; $.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)[0]; date = date.substring(0, 19); date = date.replace(/-/g, '/'); let timestamp = new Date(date).getTime(); value["time"] = timestamp; _list_ = _list_.concat(value); }); function compareDesc(propertyName) { return function (object1, object2) { var value1 = object1[propertyName]; var value2 = object2[propertyName]; if (value2 < value1) { return -1; } else if (value2 > value1) { return 1; } else { return 0; } } } _list_.sort(compareDesc("time")); return _list_; } let newBlacklist = sortByProperTyName(blacklist["data"], "time"); $.each(newBlacklist, function (index, value) { let blackreson = (value["reason"] == "") ? "无" : value["reason"]; blackContent = blackContent + ` ` + value["username"] + ` 操作时间: ` + value["dateline"] + ` 操作行为: ` + value["action"] + ` 过期时间: ` + value["groupexpiry"] + ` 操作人员: ` + value["operator"] + ` 操作理由: ` + blackreson + ` `; // console.log(value); }) let mainBlackContent = '' + blackContent + ""; $(".msgcon").html(mainBlackContent); $(".NZ-MsgBox-alert.NZ-MsgBox--motion").css("top", "100px"); $(".msgcon").css("height", "350px"); }, insertMobileBlackHomeButton: function () { // 插入手机版查看小黑屋的按钮 if ((window.location.href.match(mt_config.rexp.home_space_url) != null) && (window.localStorage.getItem("v30"))) { // @require https://cdn.bootcdn.net/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.js // @require https://cdn.bootcdn.net/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushJScript.js // gitee需要公开仓库,那我只能引用资源站的js和css了 // this.loadJS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/NZ-Plugin/Js/NZ-MsgBox.min.js"); // this.loadJS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/NZ-Plugin/Js/NZ-Drag.min.js"); blackHome.loadJS("https://www.jq22.com/demo/NZ-Plugin-MsgBox202201130154/Js/NZ-Plugin/Js/NZ-MsgBox.min.js"); blackHome.loadJS("https://www.jq22.com/demo/NZ-Plugin-MsgBox202201130154/Js/NZ-Plugin/Js/NZ-Drag.min.js"); // this.loadJS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/spin/spin.js"); // this.loadCSS("https://cdn.bootcdn.net/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCoreRDark.min.css"); // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/NZ-Plugin/Css/NZ-MsgBox.min.css"); blackHome.loadCSS("https://www.jq22.com/demo/NZ-Plugin-MsgBox202201130154/Js/NZ-Plugin/Css/NZ-MsgBox.min.css"); // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Css/fontawesome-free-5.11.2-web/css/all.min.css"); // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Css/animate.min.css"); // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/spin/spin.css"); let black_home_ele = document.createElement("a"); black_home_ele.setAttribute("href", "javascript:;"); black_home_ele.className = "comiis_flex comiis_styli bg_f b_t cl 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; }`) black_home_ele.onclick = () => { blackHome.showBlackHomeView(); } let parent_ele = document.querySelectorAll(".comiis_myinfo_list.bg_f.cl"); parent_ele[parent_ele.length - 1].append(black_home_ele); } }, getBlackList: async (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": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53" }, onload: (r) => { res(r.responseText); }, onerror: (r) => { console.log(r); res({}); } }) }) } } const 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 }, "color": { "key": "color", "value": "[color=][/color]", "tagL": "=", "tagR": "]", "L": "[color=]", "R": "[/color]", "cursorL": "[color=", "cursorLength": 7 }, "b": { "key": "加粗", "value": "[b][/b]", "tagL": "]", "tagR": "[", "L": "[b]", "R": "[/b]", "cursorR": "[/b]", "cursorLength": 4 }, "u": { "key": "下划线", "value": "[u][/u]", "tagL": "]", "tagR": "[", "L": "[u]", "R": "[/u]", "cursorR": "[/u]", "cursorLength": 4 }, "i": { "key": "倾斜", "value": "[i][/i]", "tagL": "]", "tagR": "[", "L": "[i]", "R": "[/i]", "cursorR": "[/i]", "cursorLength": 4 }, "s": { "key": "中划线", "value": "[s][/s]", "tagL": "]", "tagR": "[", "L": "[s]", "R": "[/s]", "cursorR": "[/s]", "cursorLength": 4 }, "lineFeed": { "key": "换行", "value": "[*]", "L": "", "R": "[*]", "cursorL": "[*]", "cursorLength": 3 }, "longHorizontalLine": { "key": "长横线", "value": "[hr]", "L": "", "R": "[hr]", "cursorL": "[hr]", "cursorLength": 4 }, "link": { "key": "链接", "value": "[url=][/url]", "tagL": "=", "tagR": "]", "L": "[url=]", "R": "[/url]", "cursorL": "[url=", "cursorLength": 5 }, "hide": { "key": "隐藏", "value": "[hide][/hide]", "tagL": "]", "tagR": "[", "L": "[hide]", "R": "[/hide]", "cursorR": "[/hide]", "cursorLength": 7 }, "quote": { "key": "引用", "value": "[quote][/quote]", "tagL": "]", "tagR": "[", "L": "[quote]", "R": "[/quote]", "cursorR": "[/quote]", "cursorLength": 8 } }, insertQuickReplyUBB: () => { if (window.localStorage.getItem("v31") && (window.location.href.match(mt_config.rexp.forum_post) != null)) { quickUBB.jqueryExtraFunction(); let message_ele = $("#needmessage"); let fastpostsubmitline_ele = $("#fastpostsubmitline"); if (message_ele && fastpostsubmitline_ele) { GM_addStyle(` .quickUBBs{ display: flex; flex-wrap: wrap; } .quickUBBs .quickUBB{ width: 100px; text-align: center; color: #999999; padding: 15px 0px; } .quickUBBs .quickUBB em{ font-size: calc(20px/1.2); font-weight: bold; }`); let ubbs = document.createElement("div"); ubbs.className = "quickUBBs"; $.each(quickUBB.code, function (index, value) { let ubb_ele = document.createElement("a"); ubb_ele.className = "quickUBB"; ubb_ele.setAttribute("href", "javascript:;"); ubb_ele.setAttribute("data-id", index) ubb_ele.innerHTML = "" + value["key"] + ""; ubb_ele.onclick = (e) => { let data_id = e.target.parentElement.getAttribute("data-id"); let text = quickUBB.code[data_id]["value"]; if (quickUBB.code[data_id]["isFunc"]) { text = quickUBB.set_rainbow(quickUBB.code[data_id]["num"], $("#needmessage").val()); $("#needmessage").val(text); } else { $("#needmessage").insertAtCaret(text); } if (quickUBB.code[data_id]["tagL"] != undefined || quickUBB.code[data_id]["tagR"] != undefined) { $("#needmessage").moveCursorInCenterByText(quickUBB.code[data_id]["tagL"], quickUBB.code[data_id]["tagR"]); } }; ubbs.appendChild(ubb_ele); }) $(".comiis_post_ico.comiis_minipost_icot").after(ubbs); } else { console.log("未找到快捷回复框"); } } }, insertReplayUBB: () => { if (!window.localStorage.getItem("v35")) { console.log("v35未开启"); return; } if (window.location.href.match(mt_config.rexp.reply_url) == null) { console.log("未在回复界面"); return; } let insertDOM = $(".comiis_post_urlico"); if (!insertDOM) { console.log("未找到插入元素"); return; } let parentEle = $(".comiis_post_urlico > ul")[0]; let contentEle = $("#comiis_post_qydiv > ul"); quickUBB.jqueryExtraFunction(); $.each(quickUBB.code, function (key, value) { let ubbs = $(`${value["key"]}`); ubbs.on("click", (e) => { let bottomEle = $(`#comiis_post_qydiv li[data-key='${value.key}']`); if (!bottomEle.length) { console.log("未找到该元素"); return } let contentIndex = 7 + Object.keys(quickUBB.code).indexOf(key); $("#comiis_post_qydiv ul li").hide().eq(contentIndex).fadeIn(); }) 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); $(`.comiis_sendbtn[data-keyI="${key}"]`).on("click", () => { let text = $(`#comiis_input_${key}`).val(); if (text == '') { popup.open('请输入需要插入的内容', 'alert'); return; } if (quickUBB.code[key]["isFunc"]) { text = quickUBB.set_rainbow(quickUBB.code[key]["num"], text); } if (quickUBB.code[key].hasOwnProperty("L")) { text = quickUBB.code[key]['L'] + text + quickUBB.code[key]['R']; } $("#needmessage").insertAtCaret(text); // if (quickUBB.code[key]["tagL"] != undefined || quickUBB.code[key]["tagR"] != undefined) { // $("#needmessage").moveCursorInCenterByText(quickUBB.code[key]["tagL"], quickUBB.code[key]["tagR"]); // } if (quickUBB.code[key].hasOwnProperty("cursorL")) { $("#needmessage").moveCursorToCenterByTextWithLeft(quickUBB.code[key]["cursorL"], quickUBB.code[key]["cursorLength"]); } if (quickUBB.code[key].hasOwnProperty("cursorR")) { $("#needmessage").moveCursorToCenterByTextWithRight(quickUBB.code[key]["cursorR"], 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: () => { $.fn.extend({ insertAtCaret: function (myValue) { var $t = $(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 = $(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 = $(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 = $(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 = $(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; } } } }); } } function insert_checked_select() { if (location.href.match(mt_config.rexp.home_space_url) != null) { var setting_content = document.createElement("li"); // var setting_combobox = document.createElement("li"); setting_content.className = "f_b"; setting_content.innerHTML = '' + '识别链接<\/option>' + '自动签到<\/option>' + '自动展开帖子<\/option>' + '自适应帖子内图片的宽度<\/option>' + '显示用户的UID<\/option>' + '显示搜索历史<\/option>' + '移除帖子字体效果<\/option>' + '移除评论区字体效果<\/option>' + '评论区开启点评<\/option>' + '自动加载上一页评论<\/option>' + '自动加载下一页评论<\/option>' + '小黑屋<\/option>' + '快捷回复UBB代码<\/option>' + '完整回复UBB代码<\/option>' + '今日签到之星<\/option>' + '帖外预览图片<\/option>' + '修复搜索的清空按钮<\/option>' + '修复无法正确进入别人的空间<\/option>' + '' + '<\/select>'; setting_content.style = " top;padding: 8px 0px 8px 8px;margin: 0px 15px;border-top:1px solid #efefef !important;"; let mt_commis_menu = document.getElementsByClassName("comiis_myinfo_list bg_f cl")[1]; mt_commis_menu.appendChild(setting_content); var setting_selectValue = mt_config.dom_obj.beauty_select().value; if (window.localStorage.getItem(setting_selectValue) != null) { mt_config.dom_obj.combobox_switch().checked = true; } else { mt_config.dom_obj.combobox_switch().checked = false; } } } function insert_blacklist() { if (location.href.match(mt_config.rexp.home_space_url) != null) { 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 = localStorage.blacklistuid ? localStorage.blacklistuid : ""; document.getElementById("blacklistplate").textContent = localStorage.blacklistplate ? localStorage.blacklistplate : ""; document.getElementById("blacklistsave").onclick = () => { let blackListUIDValue = document.getElementById("blacklistuid").value; let blackListPlateValue = document.getElementById("blacklistplate").value; localStorage.setItem("blacklistuid", blackListUIDValue); localStorage.setItem("blacklistplate", blackListPlateValue); iosOverlay({ text: "保存成功", duration: 2000, icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png" }); } } } function link() { if (window.localStorage.getItem("v2")) { /*TEXT link to Clickable Hyperlink From Via*/ var clearLink, excludedTags, filter, linkMixInit, linkPack, linkify, observePage, observer, setLink, url_regexp, xpath; url_regexp = /((https?:\/\/|www\.)[\x21-\x7e]+[\w\/]|(\w[\w._-]+\.(com|cn|org|net|info|tv|cc))(\/[\x21-\x7e]*[\w\/])?|ed2k:\/\/[\x21-\x7e]+\|\/|thunder:\/\/[\x21-\x7e]+=)/gi; clearLink = function (a) { var b; a = null != (b = a.originalTarget) ? b : a.target; if (null != a && "a" === a.localName && -1 !== a.className.indexOf("texttolink") && (b = a.getAttribute("href"), 0 !== b.indexOf("http") && 0 !== b.indexOf("ed2k://") && 0 !== b.indexOf("thunder://"))) return a.setAttribute("href", "http://" + b) }; document.addEventListener("mouseover", clearLink); setLink = function (a) { if (null != a && typeof (a.parentNode.className) === "string" && -1 === a.parentNode.className.indexOf("texttolink") && "#cdata-section" !== a.nodeName) { var b = a.textContent.replace(url_regexp, '$1'); if (a.textContent.length !== b.length) { var c = document.createElement("span"); c.innerHTML = b; return a.parentNode.replaceChild(c, a) } } }; excludedTags = "a svg canvas applet input button area pre embed frame frameset head iframe img option map meta noscript object script style textarea code".split(" "); xpath = "//text()[not(ancestor::" + excludedTags.join(") and not(ancestor::") + ")]"; filter = new RegExp("^(" + excludedTags.join("|") + ")$", "i"); linkPack = function (a, b) { var c, d; if (b + 1E4 < a.snapshotLength) { var e = c = b; for (d = b + 1E4; b <= d ? c <= d : c >= d; e = b <= d ? ++c : --c) setLink(a.snapshotItem(e)); setTimeout(function () { return linkPack(a, b + 1E4) }, 15) } else for (e = c = b, d = a.snapshotLength; b <= d ? c <= d : c >= d; e = b <= d ? ++c : --c) setLink(a.snapshotItem(e)) }; linkify = function (a) { a = document.evaluate(xpath, a, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); return linkPack(a, 0) }; observePage = function (a) { for (a = document.createTreeWalker(a, NodeFilter.SHOW_TEXT, { acceptNode: function (a) { if (!filter.test(a.parentNode.localName)) return NodeFilter.FILTER_ACCEPT } }, !1); a.nextNode();) setLink(a.currentNode) }; observer = new window.MutationObserver(function (a) { var b, c; var d = 0; for (b = a.length; d < b; d++) { var e = a[d]; if ("childList" === e.type) { var g = e.addedNodes; var f = 0; for (c = g.length; f < c; f++) e = g[f], observePage(e) } } }); linkMixInit = function () { if (window === window.top && "" !== window.document.title) return linkify(document.body), observer.observe(document.body, { childList: !0, subtree: !0 }) }; var clearlinkF = function (a) { var url = a.getAttribute("href"); if (0 !== url.indexOf("http") && 0 !== url.indexOf("ed2k://") && 0 !== url.indexOf("thunder://")) return a.setAttribute("href", "http://" + url) }, clearlinkE = function () { for (var a = document.getElementsByClassName("texttolink"), b = 0; b < a.length; b++) clearlinkF(a[b]) }; setTimeout(clearlinkE, 2500); setTimeout(linkMixInit, 1100); } } function online_status() { 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(); if (quanju[cishu].match('离线')) { cishu = cishu + 1; var imi2 = document.createElement('img'); imi2.src = 'https:\/\/cdn2.bbs.binmt.cc\/static\/image\/smiley\/doge\/54.png'; imi2.smilied = '1353'; imi2.border = "0"; imi2.style = 'float:right'; sss[ll].insertAdjacentElement('afterbegin', imi2); } else { cishu = cishu + 1; var imi = document.createElement('img'); imi.src = 'https:\/\/cdn2.bbs.binmt.cc\/static\/image/smiley\/doge\/35.png'; imi.smilied = '1384'; imi.border = "0"; imi.style = 'float:right'; sss[ll].insertAdjacentElement('afterbegin', imi); } } } } } function reviews() { if (window.localStorage.getItem("v6") && 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("已有点评按钮,无需再次添加"); } } } } } function changeFontColorToBlack() { if (window.localStorage.getItem("v3") && location.href.match(mt_config.rexp.forum_post)) { var hide = document.getElementsByTagName('font'); var i = 0; for (i = 0; i < hide.length; i++) { hide[i].removeAttribute('color'); hide[i].removeAttribute('style'); hide[i].removeAttribute('size'); } var content = document.getElementsByClassName("comiis_message bg_f view_all cl message"); var rule = /| ||<\/font>|||||align=".*?"/g; var j = 0, k = 1; for (j = 0; j < content.length; j++ & k++) { content[j].innerHTML = content[j].innerHTML.replace(rule, ''); } } } function collect() { 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 = '<\/a>'; old_Suspended.insertAdjacentElement('afterBegin', new_collect); } function quick_reply() { //快捷回复 document.querySelector("#scrolltop > span:nth-child(2) > a").onclick = function () { showWindow('reply', this.href); var a = document.querySelector("#postsubmit"); setTimeout( 'document.querySelector("#moreconf").innerHTML=document.querySelector("#moreconf").innerHTML+\'一键空格<\/button>\';document.querySelector("#insertspace2").onclick=function(){document.querySelector("#postmessage").value=document.querySelector("#postmessage").value+" ";}', 200) } } function user_level() { var a = document.getElementsByClassName("pls favatar"); var i = 0; var e = "0级"; for (i = 0; i < a.length; i++) { var b = a[i].getElementsByTagName("em")[1].outerText; var c = a[i].getElementsByTagName("tr")[0]; var d = document.createElement("td"); switch (b) { case "幼儿园": e = "1级"; break; case "小学生": e = "2级"; break; case "初中生": e = "3级"; break; case "高中生": e = "4级"; break; case "大学生": e = "5级"; break; case "硕士生": e = "6级"; break; case "博士生": case "实习版主": case "版主": case "审核员": e = "7级"; break; case "博士后": case "超级版主": case "网站编辑": e = "8级"; break; case "管理员": case "信息监察员": e = "9级"; break; } d.innerHTML = '' + e + '<\/a><\/p>Lv'; c.appendChild(d); } } function showUserUID() { //显示用户的uid if (window.localStorage.getItem("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.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 >= 10) { console.log("未出现,清理定时器"); 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 } $.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"]; uid_control.className = "mt_uid_set"; uid_control.style = ` font: ${uid_control_font}; background: rgb(255, 118, 0); 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); iosOverlay({ text: mt_uid + "已复制", duration: 2000, icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png" }); console.log("复制:", mt_uid) } catch (err) { iosOverlay({ text: mt_uid + "复制失败", duration: 2000, icon: "https://whitesev.gitee.io/static_resource/ios_loading/img/cross.png" }); } } mtUidDomInsertElement.parentElement.append(uid_control); } } }) console.log("出现,清理定时器"); clearInterval(findSetInval); } else { findUserFormListNums += 1; } }, 800) } } function shield_user() { // 屏蔽用户 if (window.location.href.match(mt_config.rexp.forum_guide_url) || window.location.href.match(mt_config.rexp.plate_url)) { console.log("屏蔽YH——1"); let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li"); let black_list = window.localStorage.getItem("blacklistuid") ? window.localStorage.getItem("blacklistuid") : ""; let black_list_array = black_list.split(","); Array.from(infos).forEach((info) => { let usr = info.getElementsByClassName("wblist_tximg")[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;"); } }) } if (window.location.href.match(mt_config.rexp.forum_post)) { console.log("屏蔽YH——2"); let comments = document.querySelectorAll(".comiis_postlist .comiis_postli"); let black_list = window.localStorage.getItem("blacklistuid") ? window.localStorage.getItem("blacklistuid") : ""; let black_list_array = black_list.split(","); Array.from(comments).forEach((comment) => { let usr = comment.getElementsByClassName("postli_top_tximg")[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); comment.setAttribute("style", "display:none !important;"); } }) } } function shield_plate() { // 屏蔽板块 if (window.location.href.match(mt_config.rexp.forum_guide_url)) { console.log("屏蔽BK"); let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li"); let black_list = window.localStorage.getItem("blacklistplate") ? window.localStorage.getItem("blacklistplate") : ""; let black_list_array = black_list.split("、"); Array.from(infos).forEach((info) => { let from_plate = info.querySelector(".forumlist_li_time a.f_d").text; 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;"); } }) } } function autoExpendFullText() { //自动展开 if (window.localStorage.getItem("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; }`) } } function recoveryIMGWidth() { // 图片宽度 if (window.localStorage.getItem("v16") && location.href.match(mt_config.rexp.forum_post)) { GM_addStyle(` .comiis_messages img{ max-width: 100% !important; } `) } } function post_setting_js() { //帖子内需要重复加载的脚本 tryCatch(shield_user); tryCatch(reviews); tryCatch(link); tryCatch(showUserUID); tryCatch(previewPictures); tryCatch(changeFontColorToBlack); popup.init() } function auto_load_next_comments(post_comments_list) { //自动加载下一页的评论 $("#loading-comment-tip")[0].parentElement.style.display = ""; let next_page_url = post_comments_list.children[2].href let isloding_flag = false; console.log("获取下一页:", next_page_url); if (next_page_url.indexOf("javascript:;") != -1) { console.log(post_comments_list); console.log("无多页评论"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; return; } function _loadNextComments_() { if (isloding_flag == false) { isloding_flag = true; $("#loading-comment-tip").text("正在加载评论中..."); $("#loading-comment-tip")[0].parentElement.style.display = ""; $.get(next_page_url, function (data, status, xhr) { console.log("正在请求的下一页url", next_page_url); let postlist = $(data); let kqideSourceNode = $(".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"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; } else { console.log("评论全部加载完毕,关闭监听事件"); $(".comiis_page.bg_f").remove(); $("#loading-comment-tip").text("已加载完所有评论") $("#loading-comment-tip")[0].parentElement.style.display = ""; $("#loading-comment-tip").unbind("click", _loadNextComments_); $(window).unbind("scroll"); } isloding_flag = false; kqideSourceNode.append(postDOM); post_setting_js(); }) } else { console.log("正在加载中请稍后"); } } $(window).bind("scroll", function () { // scroll at bottom if (Math.ceil($(window).scrollTop() + $(window).height() + 150) >= $(document).height()) { // load data _loadNextComments_(); } }) $("#loading-comment-tip").text("请上下滑动或点击加载"); $("#loading-comment-tip").bind("click", _loadNextComments_); } function auto_load_prev_comments() { //自动加载上一页的评论 let post_comments_list = document.querySelector(".comiis_page.bg_f"); let prev_page_url = post_comments_list.children[0].href let isloding_flag = false; console.log("获取上一页:", prev_page_url); $("#loading-comment-tip-prev").text("请上下滑动或点击加载"); $("#loading-comment-tip-prev").bind("click", loadPrevComments); function loadPrevComments() { if (isloding_flag) { console.log("正在加载上一页中请稍后"); } else { isloding_flag = true; $("#loading-comment-tip-prev").text("正在加载评论中..."); $("#loading-comment-tip-prev")[0].parentElement.style.display = ""; $.get(prev_page_url, function (data, status, xhr) { console.log("正在请求的上一页评论:", prev_page_url); let postlist = $(data); let kqideSourceNode = $(".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"); $("#loading-comment-tip-prev")[0].parentElement.style.display = "none"; isloding_flag = false; kqideSourceNode.prepend(postDOM); post_setting_js(); } else { isloding_flag = false; kqideSourceNode.prepend(postDOM); console.log("上一页评论全部加载完毕,关闭监听事件"); let page_title = postlist.find(".comiis_viewtit")[0].outerHTML; console.log($(page_title)); kqideSourceNode.prepend($(page_title)[0]); post_setting_js(); // $(".comiis_page.bg_f").remove(); $("#loading-comment-tip-prev").remove(); $("#loading-comment-tip-prev").unbind("click", loadPrevComments); $(window).unbind("scroll"); } }) } // $(window).unbind("scroll",loadPrevComments); } $(window).bind("scroll", function () { if ($(window).scrollTop() <= 50) { loadPrevComments(); } }); } function loadNextComments() { if (window.localStorage.getItem("v21") && window.location.href.match(mt_config.rexp.forum_post)) { let tip_html = ` 正在等待页面加载完毕 `; $(".comiis_bodybox").append($(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("暂无评论"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; return; } let commentsNum = parseInt(commentsEle.textContent); if (commentsNum >= 10) { let setAutoLoadInterval = setInterval(function () { let post_comments_list = document.querySelector(".comiis_page.bg_f"); //评论列表 if (post_comments_list) { auto_load_next_comments(post_comments_list); clearInterval(setAutoLoadInterval); } else { console.log("正在等待下一页列表元素出现"); } }, 500) } else { console.log("无多页评论"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; } } } function loadPrevComments() { if (window.localStorage.getItem("v32") && window.location.href.match(mt_config.rexp.forum_post)) { if (!document.querySelector(".comiis_pltit span.f_d")) { console.log("当前不在第一页,加载上一页评论"); let tip_html = ` 正在等待页面加载完毕 `; $(".comiis_bodybox script")[0].after($(tip_html)[0]); if (document.querySelector(".comiis_pltit h2") && document.querySelector(".comiis_pltit h2").textContent.indexOf("暂无评论") != -1) { console.log("暂无上一页评论"); $("#loading-comment-tip-prev")[0].parentElement.style.display = "none"; return; } auto_load_prev_comments(); } } } function Hooks() { 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 pageAfterDOMChangeRunFunction() { // 当页面内容元素添加时需要执行的函数 if (window.location.href.match(/bbs.binmt.cc\/forum/)) { document.body.addEventListener("DOMNodeInserted", (event) => { let ele = event.target; if (ele.className != null && ele.className.indexOf("comiis_forumlist") != -1) { beforeHookRun(); } }) function beforeHookRun() { tryCatch(showUserUID); tryCatch(previewPictures); tryCatch(shield_user); tryCatch(shield_plate); } } } function previewPictures() { // 贴外预览图片 if (window.localStorage.getItem("v34") && ((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))))) { 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 getPreviewPicturesEle(dom) { let pre_dom = document.createElement("li"); pre_dom.className = "f_c"; let imageDOM = dom.querySelectorAll(".comiis_pyqlist_img").length ? dom.querySelectorAll(".comiis_pyqlist_img") : dom.querySelectorAll(".comiis_pyqlist_imgs"); if (imageDOM.length) { pre_dom.innerHTML = '预览图片'; $.each(imageDOM, function (i, v) { let imgs = v.querySelectorAll("img"); Array.from(imgs).forEach(_img_ => { pre_dom.innerHTML = pre_dom.innerHTML + ``; }) }) pre_dom.onclick = function () { let img_list = $(this)[0].querySelectorAll("img"); let img_items = []; let now_picture_num = 1; for (var k = 0; k < img_list.length; k++) { let img_url = img_list[k].getAttribute("data-src"); let img_dict = {}; let full_picture = null; if (img_url.match(/res-bbs.mt2.cn/) && img_url.match(/size=[\d]*x9999/)) { console.log("gif图"); full_picture = img_url; } else { full_picture = img_url.replace(/size=[\d]*x[\d]*/, "size=600x1000"); full_picture = full_picture.replace(/_[\d]*_[\d]*.jpg/, "_600_1000.jpg"); } img_dict["src"] = full_picture; img_dict["srct"] = img_url; img_dict["title"] = "图片" + now_picture_num.toString(); img_dict["ID"] = hex_md5(img_url); img_items.push(img_dict); now_picture_num = now_picture_num + 1; } $('#picture_review').nanogallery2('destroy'); jQuery("#picture_review").nanogallery2({ thumbnailWidth: 150, thumbnailHeight: 150, items: img_items, thumbnailSelectable: false }); window.location.hash = '#nanogallery/picture_review/0/' + img_items[0]["ID"]; } return pre_dom; } else { pre_dom.innerHTML = '无'; return pre_dom; } } function main() { // blackHome.loadJS("https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/jquery.nanogallery2.min.js"); if (window.hasOwnProperty("loadPreviewPictureCSS")) { console.log("已加载过预览图片"); } else { blackHome.loadCSS("https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/css/nanogallery2.min.css"); blackHome.loadCSS("https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/css/nanogallery2.woff.min.css"); window.loadPreviewPictureCSS = true; } let global_review = document.createElement("div"); global_review.id = "picture_review"; // $(".comiis_bodybox")[0].prepend(global_review); // debug使用 global_review.setAttribute("style", "display:none"); document.body.append(global_review); $.each(formlist, function (index, value) { let formBottomEle = value.querySelectorAll(".cl .f_c"); if (formBottomEle.length == 2) { let clParentEle = formBottomEle[0].parentElement; let previewPicturesEle = getPreviewPicturesEle(value); Array.from(formBottomEle).forEach(e => { e.setAttribute("style", "width: 33%"); }); clParentEle.append(previewPicturesEle); } else if (formBottomEle.length == 3) { console.log("已经插入过预览图片"); } else { console.log("没有阅读、评论这两个东西"); } }) } } } function repairClearSearchInput() { // 修复搜索的清空按钮 if (window.localStorage.getItem("v36") && window.location.href.match(mt_config.rexp.search_url)) { let $search_input = $(".ssclose.bg_e.f_e"); if($search_input){ $search_input.click(function (e) { e.preventDefault(); $("#scform_srchtxt").val("") }) }else{ log.error("搜索界面: 获取清空按钮失败"); } } } function repairUserSpace() { // 修复无法正确进入别人的空间 if (window.localStorage.getItem("v37") && 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"; } } } function mobile_all_setting() { tryCatch(reviews); tryCatch(recoveryIMGWidth); tryCatch(link); tryCatch(showUserUID); tryCatch(previewPictures); tryCatch(removeFontStyle); tryCatch(changeFontColorToBlack); tryCatch(autoSignIn); tryCatch(autoExpendFullText); tryCatch(searchHistory); tryCatch(loadNextComments, '', '$("#loading-comment-tip").text("加载评论失败")'); tryCatch(loadPrevComments, '', '$("#loading-comment-tip-prev").text("加载评论失败")'); tryCatch(repairClearSearchInput); tryCatch(repairUserSpace); } function tryCatch(func, params, errorFunc) { // 捕获错误 try { func(params); } catch (error) { console.log("%c" + (func.name + "出现错误"), "color: #f20000"); console.log("%c" + ("错误原因:" + error), "color: #f20000"); eval(errorFunc); } } function ios_js_css() { var ios_js = document.createElement("script"); var ios_css = document.createElement("link"); ios_js.src = "https://whitesev.gitee.io/static_resource/ios_loading/js/iosOverlay.js"; ios_js.type = "text/javascript"; ios_css.rel = "stylesheet"; ios_css.type = "text/css"; ios_css.href = "https://whitesev.gitee.io/static_resource/ios_loading/css/iosOverlay.css"; document.head.appendChild(ios_js); document.head.appendChild(ios_css); } function set_PC_js() { var a = document.createElement("script"); var b = document.createElement("script"); a.src = "https://cdn2.bbs.binmt.cc/static/js/smilies.js?x6L"; b.src = "https://cdn2.bbs.binmt.cc/static/js/common.js?x6L"; a.type = "text/javascript"; b.type = "text/javascript"; document.head.appendChild(a); document.head.appendChild(b); } function np() { //这是入口 var usa = navigator.userAgent.match(mt_config.rexp.pc_useragent); if (usa != null) { tryCatch(set_PC_js); $(document).ready(function () { tryCatch(Latest_publication); // tryCatch(online_status); tryCatch(link); tryCatch(collect); tryCatch(quick_reply); tryCatch(user_level); tryCatch(autoSignIn); }); } else { $(document).ready(function () { mobile_all_setting() tryCatch(shield_user); tryCatch(shield_plate); try { insert_checked_select(); set_display_last_click(); set_select_clicked(); set_checked_clicked(); set_select_change_clicked(); setCheckBoxCSS(); } catch (err) {} tryCatch(blackHome.insertMobileBlackHomeButton); tryCatch(quickUBB.insertQuickReplyUBB); tryCatch(quickUBB.insertReplayUBB); tryCatch(insert_blacklist); tryCatch(showTodayStar); tryCatch(show_latest_sign); tryCatch(ios_js_css); pageAfterDOMChangeRunFunction(); }) } } //function np()的结束处 $(document).ready(function () { np() }); })();
月天数 ` + people["monthDays"] + ` 天 , 上次奖励 ` + people["reward"] + `
操作行为: ` + value["action"] + `
过期时间: ` + value["groupexpiry"] + `
操作人员: ` + value["operator"] + `
' + e + '<\/a><\/p>Lv'; c.appendChild(d); } } function showUserUID() { //显示用户的uid if (window.localStorage.getItem("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.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 >= 10) { console.log("未出现,清理定时器"); 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 } $.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"]; uid_control.className = "mt_uid_set"; uid_control.style = ` font: ${uid_control_font}; background: rgb(255, 118, 0); 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); iosOverlay({ text: mt_uid + "已复制", duration: 2000, icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png" }); console.log("复制:", mt_uid) } catch (err) { iosOverlay({ text: mt_uid + "复制失败", duration: 2000, icon: "https://whitesev.gitee.io/static_resource/ios_loading/img/cross.png" }); } } mtUidDomInsertElement.parentElement.append(uid_control); } } }) console.log("出现,清理定时器"); clearInterval(findSetInval); } else { findUserFormListNums += 1; } }, 800) } } function shield_user() { // 屏蔽用户 if (window.location.href.match(mt_config.rexp.forum_guide_url) || window.location.href.match(mt_config.rexp.plate_url)) { console.log("屏蔽YH——1"); let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li"); let black_list = window.localStorage.getItem("blacklistuid") ? window.localStorage.getItem("blacklistuid") : ""; let black_list_array = black_list.split(","); Array.from(infos).forEach((info) => { let usr = info.getElementsByClassName("wblist_tximg")[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;"); } }) } if (window.location.href.match(mt_config.rexp.forum_post)) { console.log("屏蔽YH——2"); let comments = document.querySelectorAll(".comiis_postlist .comiis_postli"); let black_list = window.localStorage.getItem("blacklistuid") ? window.localStorage.getItem("blacklistuid") : ""; let black_list_array = black_list.split(","); Array.from(comments).forEach((comment) => { let usr = comment.getElementsByClassName("postli_top_tximg")[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); comment.setAttribute("style", "display:none !important;"); } }) } } function shield_plate() { // 屏蔽板块 if (window.location.href.match(mt_config.rexp.forum_guide_url)) { console.log("屏蔽BK"); let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li"); let black_list = window.localStorage.getItem("blacklistplate") ? window.localStorage.getItem("blacklistplate") : ""; let black_list_array = black_list.split("、"); Array.from(infos).forEach((info) => { let from_plate = info.querySelector(".forumlist_li_time a.f_d").text; 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;"); } }) } } function autoExpendFullText() { //自动展开 if (window.localStorage.getItem("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; }`) } } function recoveryIMGWidth() { // 图片宽度 if (window.localStorage.getItem("v16") && location.href.match(mt_config.rexp.forum_post)) { GM_addStyle(` .comiis_messages img{ max-width: 100% !important; } `) } } function post_setting_js() { //帖子内需要重复加载的脚本 tryCatch(shield_user); tryCatch(reviews); tryCatch(link); tryCatch(showUserUID); tryCatch(previewPictures); tryCatch(changeFontColorToBlack); popup.init() } function auto_load_next_comments(post_comments_list) { //自动加载下一页的评论 $("#loading-comment-tip")[0].parentElement.style.display = ""; let next_page_url = post_comments_list.children[2].href let isloding_flag = false; console.log("获取下一页:", next_page_url); if (next_page_url.indexOf("javascript:;") != -1) { console.log(post_comments_list); console.log("无多页评论"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; return; } function _loadNextComments_() { if (isloding_flag == false) { isloding_flag = true; $("#loading-comment-tip").text("正在加载评论中..."); $("#loading-comment-tip")[0].parentElement.style.display = ""; $.get(next_page_url, function (data, status, xhr) { console.log("正在请求的下一页url", next_page_url); let postlist = $(data); let kqideSourceNode = $(".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"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; } else { console.log("评论全部加载完毕,关闭监听事件"); $(".comiis_page.bg_f").remove(); $("#loading-comment-tip").text("已加载完所有评论") $("#loading-comment-tip")[0].parentElement.style.display = ""; $("#loading-comment-tip").unbind("click", _loadNextComments_); $(window).unbind("scroll"); } isloding_flag = false; kqideSourceNode.append(postDOM); post_setting_js(); }) } else { console.log("正在加载中请稍后"); } } $(window).bind("scroll", function () { // scroll at bottom if (Math.ceil($(window).scrollTop() + $(window).height() + 150) >= $(document).height()) { // load data _loadNextComments_(); } }) $("#loading-comment-tip").text("请上下滑动或点击加载"); $("#loading-comment-tip").bind("click", _loadNextComments_); } function auto_load_prev_comments() { //自动加载上一页的评论 let post_comments_list = document.querySelector(".comiis_page.bg_f"); let prev_page_url = post_comments_list.children[0].href let isloding_flag = false; console.log("获取上一页:", prev_page_url); $("#loading-comment-tip-prev").text("请上下滑动或点击加载"); $("#loading-comment-tip-prev").bind("click", loadPrevComments); function loadPrevComments() { if (isloding_flag) { console.log("正在加载上一页中请稍后"); } else { isloding_flag = true; $("#loading-comment-tip-prev").text("正在加载评论中..."); $("#loading-comment-tip-prev")[0].parentElement.style.display = ""; $.get(prev_page_url, function (data, status, xhr) { console.log("正在请求的上一页评论:", prev_page_url); let postlist = $(data); let kqideSourceNode = $(".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"); $("#loading-comment-tip-prev")[0].parentElement.style.display = "none"; isloding_flag = false; kqideSourceNode.prepend(postDOM); post_setting_js(); } else { isloding_flag = false; kqideSourceNode.prepend(postDOM); console.log("上一页评论全部加载完毕,关闭监听事件"); let page_title = postlist.find(".comiis_viewtit")[0].outerHTML; console.log($(page_title)); kqideSourceNode.prepend($(page_title)[0]); post_setting_js(); // $(".comiis_page.bg_f").remove(); $("#loading-comment-tip-prev").remove(); $("#loading-comment-tip-prev").unbind("click", loadPrevComments); $(window).unbind("scroll"); } }) } // $(window).unbind("scroll",loadPrevComments); } $(window).bind("scroll", function () { if ($(window).scrollTop() <= 50) { loadPrevComments(); } }); } function loadNextComments() { if (window.localStorage.getItem("v21") && window.location.href.match(mt_config.rexp.forum_post)) { let tip_html = ` 正在等待页面加载完毕 `; $(".comiis_bodybox").append($(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("暂无评论"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; return; } let commentsNum = parseInt(commentsEle.textContent); if (commentsNum >= 10) { let setAutoLoadInterval = setInterval(function () { let post_comments_list = document.querySelector(".comiis_page.bg_f"); //评论列表 if (post_comments_list) { auto_load_next_comments(post_comments_list); clearInterval(setAutoLoadInterval); } else { console.log("正在等待下一页列表元素出现"); } }, 500) } else { console.log("无多页评论"); $("#loading-comment-tip")[0].parentElement.style.display = "none"; } } } function loadPrevComments() { if (window.localStorage.getItem("v32") && window.location.href.match(mt_config.rexp.forum_post)) { if (!document.querySelector(".comiis_pltit span.f_d")) { console.log("当前不在第一页,加载上一页评论"); let tip_html = ` 正在等待页面加载完毕 `; $(".comiis_bodybox script")[0].after($(tip_html)[0]); if (document.querySelector(".comiis_pltit h2") && document.querySelector(".comiis_pltit h2").textContent.indexOf("暂无评论") != -1) { console.log("暂无上一页评论"); $("#loading-comment-tip-prev")[0].parentElement.style.display = "none"; return; } auto_load_prev_comments(); } } } function Hooks() { 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 pageAfterDOMChangeRunFunction() { // 当页面内容元素添加时需要执行的函数 if (window.location.href.match(/bbs.binmt.cc\/forum/)) { document.body.addEventListener("DOMNodeInserted", (event) => { let ele = event.target; if (ele.className != null && ele.className.indexOf("comiis_forumlist") != -1) { beforeHookRun(); } }) function beforeHookRun() { tryCatch(showUserUID); tryCatch(previewPictures); tryCatch(shield_user); tryCatch(shield_plate); } } } function previewPictures() { // 贴外预览图片 if (window.localStorage.getItem("v34") && ((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))))) { 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 getPreviewPicturesEle(dom) { let pre_dom = document.createElement("li"); pre_dom.className = "f_c"; let imageDOM = dom.querySelectorAll(".comiis_pyqlist_img").length ? dom.querySelectorAll(".comiis_pyqlist_img") : dom.querySelectorAll(".comiis_pyqlist_imgs"); if (imageDOM.length) { pre_dom.innerHTML = '预览图片'; $.each(imageDOM, function (i, v) { let imgs = v.querySelectorAll("img"); Array.from(imgs).forEach(_img_ => { pre_dom.innerHTML = pre_dom.innerHTML + ``; }) }) pre_dom.onclick = function () { let img_list = $(this)[0].querySelectorAll("img"); let img_items = []; let now_picture_num = 1; for (var k = 0; k < img_list.length; k++) { let img_url = img_list[k].getAttribute("data-src"); let img_dict = {}; let full_picture = null; if (img_url.match(/res-bbs.mt2.cn/) && img_url.match(/size=[\d]*x9999/)) { console.log("gif图"); full_picture = img_url; } else { full_picture = img_url.replace(/size=[\d]*x[\d]*/, "size=600x1000"); full_picture = full_picture.replace(/_[\d]*_[\d]*.jpg/, "_600_1000.jpg"); } img_dict["src"] = full_picture; img_dict["srct"] = img_url; img_dict["title"] = "图片" + now_picture_num.toString(); img_dict["ID"] = hex_md5(img_url); img_items.push(img_dict); now_picture_num = now_picture_num + 1; } $('#picture_review').nanogallery2('destroy'); jQuery("#picture_review").nanogallery2({ thumbnailWidth: 150, thumbnailHeight: 150, items: img_items, thumbnailSelectable: false }); window.location.hash = '#nanogallery/picture_review/0/' + img_items[0]["ID"]; } return pre_dom; } else { pre_dom.innerHTML = '无'; return pre_dom; } } function main() { // blackHome.loadJS("https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/jquery.nanogallery2.min.js"); if (window.hasOwnProperty("loadPreviewPictureCSS")) { console.log("已加载过预览图片"); } else { blackHome.loadCSS("https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/css/nanogallery2.min.css"); blackHome.loadCSS("https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/nanogallery2/3.0.5/css/nanogallery2.woff.min.css"); window.loadPreviewPictureCSS = true; } let global_review = document.createElement("div"); global_review.id = "picture_review"; // $(".comiis_bodybox")[0].prepend(global_review); // debug使用 global_review.setAttribute("style", "display:none"); document.body.append(global_review); $.each(formlist, function (index, value) { let formBottomEle = value.querySelectorAll(".cl .f_c"); if (formBottomEle.length == 2) { let clParentEle = formBottomEle[0].parentElement; let previewPicturesEle = getPreviewPicturesEle(value); Array.from(formBottomEle).forEach(e => { e.setAttribute("style", "width: 33%"); }); clParentEle.append(previewPicturesEle); } else if (formBottomEle.length == 3) { console.log("已经插入过预览图片"); } else { console.log("没有阅读、评论这两个东西"); } }) } } } function repairClearSearchInput() { // 修复搜索的清空按钮 if (window.localStorage.getItem("v36") && window.location.href.match(mt_config.rexp.search_url)) { let $search_input = $(".ssclose.bg_e.f_e"); if($search_input){ $search_input.click(function (e) { e.preventDefault(); $("#scform_srchtxt").val("") }) }else{ log.error("搜索界面: 获取清空按钮失败"); } } } function repairUserSpace() { // 修复无法正确进入别人的空间 if (window.localStorage.getItem("v37") && 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"; } } } function mobile_all_setting() { tryCatch(reviews); tryCatch(recoveryIMGWidth); tryCatch(link); tryCatch(showUserUID); tryCatch(previewPictures); tryCatch(removeFontStyle); tryCatch(changeFontColorToBlack); tryCatch(autoSignIn); tryCatch(autoExpendFullText); tryCatch(searchHistory); tryCatch(loadNextComments, '', '$("#loading-comment-tip").text("加载评论失败")'); tryCatch(loadPrevComments, '', '$("#loading-comment-tip-prev").text("加载评论失败")'); tryCatch(repairClearSearchInput); tryCatch(repairUserSpace); } function tryCatch(func, params, errorFunc) { // 捕获错误 try { func(params); } catch (error) { console.log("%c" + (func.name + "出现错误"), "color: #f20000"); console.log("%c" + ("错误原因:" + error), "color: #f20000"); eval(errorFunc); } } function ios_js_css() { var ios_js = document.createElement("script"); var ios_css = document.createElement("link"); ios_js.src = "https://whitesev.gitee.io/static_resource/ios_loading/js/iosOverlay.js"; ios_js.type = "text/javascript"; ios_css.rel = "stylesheet"; ios_css.type = "text/css"; ios_css.href = "https://whitesev.gitee.io/static_resource/ios_loading/css/iosOverlay.css"; document.head.appendChild(ios_js); document.head.appendChild(ios_css); } function set_PC_js() { var a = document.createElement("script"); var b = document.createElement("script"); a.src = "https://cdn2.bbs.binmt.cc/static/js/smilies.js?x6L"; b.src = "https://cdn2.bbs.binmt.cc/static/js/common.js?x6L"; a.type = "text/javascript"; b.type = "text/javascript"; document.head.appendChild(a); document.head.appendChild(b); } function np() { //这是入口 var usa = navigator.userAgent.match(mt_config.rexp.pc_useragent); if (usa != null) { tryCatch(set_PC_js); $(document).ready(function () { tryCatch(Latest_publication); // tryCatch(online_status); tryCatch(link); tryCatch(collect); tryCatch(quick_reply); tryCatch(user_level); tryCatch(autoSignIn); }); } else { $(document).ready(function () { mobile_all_setting() tryCatch(shield_user); tryCatch(shield_plate); try { insert_checked_select(); set_display_last_click(); set_select_clicked(); set_checked_clicked(); set_select_change_clicked(); setCheckBoxCSS(); } catch (err) {} tryCatch(blackHome.insertMobileBlackHomeButton); tryCatch(quickUBB.insertQuickReplyUBB); tryCatch(quickUBB.insertReplayUBB); tryCatch(insert_blacklist); tryCatch(showTodayStar); tryCatch(show_latest_sign); tryCatch(ios_js_css); pageAfterDOMChangeRunFunction(); }) } } //function np()的结束处 $(document).ready(function () { np() }); })();