// ==UserScript== // @name MT论坛 // @namespace http://tampermonkey.net/ // @description MT论坛优化 // @version 2.0.5.3 // @author MT-戒酒的李白染 // @icon https://bbs.binmt.cc/favicon.ico // @match *://bbs.binmt.cc/* // @compatible edge Beta/Dev/Candy 测试通过 // @compatible 火狐 测试通过 // @compatible Yandex 测试通过 // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_setClipboard // @run-at document-start // @supportURL https://github.com/893177236/Monkey_script // @require http://cdn.staticfile.org/jquery/2.1.4/jquery.min.js // @downloadURL none // ==/UserScript== (function () { 'use strict'; 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("top_lev bg_a f_f"); }, comiis_postli: function () { //帖子内评论,包括帖子内容主体,第一个就是主体【list】 return document.getElementsByClassName("comiis_postli comiis_list_readimgs nfqsqi") } }, rexp: { search_url: /bbs.binmt.cc\/search.php/g, home_url: /home.php\?mod=spacecp&ac=profile&op=info/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/g, //【我的】 个人信息页链接 home_space_pc_uid_url: /space-uid-(.*?).html/, //PC 个人空间链接uid reply_url: "", sign_url: "", navigation_url: "", forum_post: /bbs.binmt.cc\/thread-/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, //各版块名称 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识别 } } 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 insert_empty_title() { if (location.href.match(/mod=post&action=newthread&fid=50/g) != null) { var a = document.createElement("div"); var b = document.querySelector("#postform > div > div:nth-child(5)"); a.className = "comiis_btnbox cl"; a.innerHTML = '`; 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 search_event() { //搜索界面增加关闭按钮事件,清空input内容 //点击搜索保存搜索记录 $(".ssclose.bg_e.f_e").click(function () { $("#scform_srchtxt").val("") }) $("#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) { search_history_array = search_history_array.concat(has_history); } GM_setValue("search_history", search_history_array); } }) } function apply_none() { if (location.href.match(mt_config.rexp.forum_post) != null) { var a = document.createElement("span"); var b = document.querySelector("#fastpostform > div.comiis_post_ico.comiis_minipost_icot.f_c.cl"); a.id = "fastpostsubmitline2"; a.className = "y"; a.innerHTML = ''; b.appendChild(a); document.querySelector("#fastpostsubmitline2 > input").onclick = function () { document.querySelector("#needmessage").value = document.querySelector("#needmessage").value + "🤣🤣🤣🤣🤣"; } } if (location.href.match(mt_config.rexp.forum_post_reply) != null) { var c = document.createElement("span"); var d = document.getElementsByClassName("swiper-wrapper comiis_post_ico")[0]; c.id = "fastpostsubmitline2"; c.className = "y"; c.innerHTML = ''; d.appendChild(c); document.querySelector("#fastpostsubmitline2 > input").onclick = function () { document.querySelector("#needmessage").value = document.querySelector("#needmessage").value + "🤣🤣🤣🤣🤣"; } } } function set_css() { var a = document.createElement("style"); var b = document.head; var c = document.createElement("script"); var image = document.createElement("script"); var file = document.createElement("script"); c.src = "https://cdn2.bbs.binmt.cc/template/comiis_app/comiis/js/common_u.js?EPT:formatted"; //可能是论坛引入的js么有加载,顾重新引入 image.src = "https://cdn2.bbs.binmt.cc/template/comiis_app/comiis/js/buildfileupload.js?EPT"; file.src = "https://cdn.bbs.binmt.cc/static/js/mobile/ajaxfileupload.js?EPT"; a.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;/*去掉样式*/ } `; b.appendChild(a); //把a看成b弄错了 b.appendChild(c); b.appendChild(image); b.appendChild(file); } 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 (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]; localStorage.setItem("last", select_value); if (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 = localStorage.getItem(a); if (b) { localStorage.removeItem(a); } else { localStorage.setItem(a, "true"); } var c = 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: 2000, icon: "https://whitesev.gitee.io/static_resource/ios_loading/img/check.png" }); } else { iosOverlay({ text: e + "已关闭", duration: 2000, icon: "https://whitesev.gitee.io/static_resource/ios_loading/img/check.png" }); } setTimeout(function () { location.reload() }, 2000); } } 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 = 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 (localStorage.getItem(last_select_value)) { combobox_switch.checked = true; } else { combobox_switch.checked = false; } } function insert_tips() { var a = document.createElement("li"); var b = document.querySelector("#comiis_menu_vtr_menu > ul"); a.className = "f_b"; a.innerHTML = '

Tip:点击按钮将自动刷新<\/p>'; b.appendChild(a); } 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_combobox.className = "f_b"; // setting_combobox.style = "text-align: center;"; setting_content.innerHTML = '' + '<\/select>'; setting_content.style = " top;padding: 8px 0px 8px 8px;margin: 0px 15px;border-top:1px solid #efefef !important;"; // setting_combobox.innerHTML = ''; let mt_commis_menu = document.getElementsByClassName("comiis_myinfo_list bg_f cl")[1]; mt_commis_menu.appendChild(setting_content); // mt_commis_menu.appendChild(setting_combobox); // var setting_combobox = document.getElementsByClassName("switch_1")[0]; var setting_selectValue = mt_config.dom_obj.beauty_select().value; // console.log(mt_config.dom_obj.beauty_select()) if (localStorage.getItem(setting_selectValue) != null) { mt_config.dom_obj.combobox_switch().checked = true; } else { mt_config.dom_obj.combobox_switch().checked = false; } } } function link() { 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 && -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) { 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, 1500); setTimeout(linkMixInit, 100); } function online_status() { 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() { 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++) { 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); } } } // function reviews_all_click(){//全局监听点击事件修改点评的名字 // document.addEventListener("click",function(e){ // let click_classname = e.toElement.className; // if(click_classname=="comiis_font mt_review"){ // console.log(e); // } // }) // } function new_thread() { try { document.getElementsByClassName("comiis_mh_tit cl")[1].getElementsByTagName("a")[0].href = "https://bbs.binmt.cc/page-4.html"; } catch (err) {} } function show_black() { 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 reply_space() { var a = document.getElementsByClassName("fastre"); var i = 0; for (i = 0; i < a.length; i++) { a[i].onclick = function () { showWindow('reply', this.href); setTimeout('document.querySelector("#moreconf").innerHTML=document.querySelector("#moreconf").innerHTML+\'