// ==UserScript== // @name MT论坛 // @namespace http://tampermonkey.net/ // @description MT论坛效果增强,如自动签到、自动展开帖子、自动展开评论、显示uid、屏蔽用户等 // @version 2.2.2 // @author MT-戒酒的李白染 // @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 // @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'; 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("top_lev bg_a f_f"); }, 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, //搜索页 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-|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, //各版块名称 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 remove_post_content_font_special() { 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 mt_getFormHash_pc() { let mt_formhash = document.querySelector("input[name=formhash]").value; return mt_formhash; } function mt_getFormHash_mobile() { let mt_formhash = document.querySelector("div[class=sidenv_exit]>a").href.match(mt_config.rexp.formhash)[1] return mt_formhash; } function auto_sign(mt_formhash) { //mt签到 if (mt_formhash != null) { let GM_localTime = getLocalTime(); $.get("/k_misign-sign.html?operation=qiandao&format=button&formhash=" + mt_formhash + "&inajax=1&ajaxtarget=midaben_sign", function (data, status) { console.log(data.responseText); GM_setValue("mt_sign", GM_localTime); location.reload(); }); } else { console.log("获取账号formhash失败") } } 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 + '

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_content.innerHTML = '' + '<\/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 (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) { try { let parentClassName = a.parentNode.className; } catch (error) { return; } let parentClassNameTypeOf = typeof (parentClassName); if (parentClassNameTypeOf != 'string') { return } if (null != a && -1 === parentClassName.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++) { 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 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+\'