`,
mask: true,
only: true,
ok: {
text: "继续上传",
callback: async () => {
popup2.closeConfirm();
popup2.showLoadingMask();
popup2.toast("上传水印图片中...请稍后");
console.log(`图片数量:${needUploadImageFileArray.length}`);
Utils.asyncArrayForEach(
needUploadImageFileArray,
uploadFileAwaitFunction
).then(() => {
Utils.tryCatch().run(completeFunction);
});
},
},
other: {
enable: true,
text: "保存至本地",
callback: () => {
Array.from(needUploadImageFileArray).forEach(
async (item, index) => {
let base64Image = await Utils.asyncFileToBase64(item);
Utils.downloadBase64(item.name, base64Image);
}
);
},
},
});
});
}
if (GM_getValue("chartBedAddWaterMark")) {
Utils.tryCatch().run(waterMarkAwaitFunction);
} else {
popup2.showLoadingMask();
popup2.toast("上传图片中...请稍后");
console.log(`图片数量:${chooseImageFiles.length}`);
Utils.asyncArrayForEach(
chooseImageFiles,
uploadFileAwaitFunction
).then(() => {
Utils.tryCatch().run(completeFunction);
});
}
});
$jq(document).on("click", "#imglist_mt .delImg", async function (e) {
/* 删除上传的图片-目前无法删除 */
e.preventDefault();
const id_encoded = $jq(this).attr("id-encode");
$jq(this).parent().remove();
mobile.chartBed.storage.delete("mt", id_encoded);
});
}
function chartbedByHistory() {
/* 所有图床历史上传过的图片 */
GM_addStyle(`
.comiis_post_imglist li .delImg {
position: absolute;
top: -5px;
left: -5px;
}
`);
$jq(document).on(
"click",
"li[id*='comiis_pictitle_tab_n_'][data-history]",
function (e) {
if (GM_getValue("chartBedsImagesHistory") == undefined) {
GM_setValue("chartBedsImagesHistory", []);
}
let historyImages = mobile.chartBed.storage.get();
if (historyImages == []) {
return;
}
let isAddHistoryImages = $jq("#imglist_history").children();
if (isAddHistoryImages.length === historyImages.length) {
/* 没有新图片 */
console.log("没有新图片");
return;
} else if (isAddHistoryImages.length === 0) {
/* 无图片-全部加进去 */
console.log("无图片-全部加进去");
$jq.each(historyImages, (i) => {
let _id = historyImages[i]["id_encoded"];
let _web = historyImages[i]["web"];
let _url = historyImages[i]["url"];
let _thumb_url = historyImages[i]["thumb_url"];
let _name = historyImages[i]["name"];
let _imageHTML = `
${_web}
`;
$jq("#imglist_history").append($jq(_imageHTML));
});
} else if (isAddHistoryImages.length < historyImages.length) {
/* 其它地方增加了数据-更新结构 */
console.log("其它地方增加了数据-更新结构");
var needAddData = Utils.uniqueArray(
historyImages,
isAddHistoryImages,
(item, item2) => {
let obj = $jq(item2);
let spanElement = obj.find("span.delImg");
let _id = spanElement.attr("t-id");
let _web = spanElement.attr("t-web");
if (!isNaN(parseInt(_id))) {
_id = parseInt(_id);
}
return item["web"] === _web && item["id_encoded"] === _id
? true
: false;
}
);
console.log("新增数组:", needAddData);
Array.from(needAddData).forEach((item, index) => {
let _id = item["id_encoded"];
let _web = item["web"];
let _url = item["url"];
let _thumb_url = item["thumb_url"];
let _name = item["name"];
let _imageHTML = `
${_web}
`;
$jq("#imglist_history").append($jq(_imageHTML));
});
} else if (isAddHistoryImages.length > historyImages.length) {
/* 其它地方删除了数据,更新结构 */
console.log("其它地方删除了数据,更新结构");
var needRemoveData = Utils.uniqueArray(
isAddHistoryImages,
historyImages,
(item, item2) => {
let obj = $jq(item);
let spanElement = obj.find("span.delImg");
let _id = spanElement.attr("t-id");
let _web = spanElement.attr("t-web");
if (!isNaN(parseInt(_id))) {
_id = parseInt(_id);
}
return item2["web"] === _web && item2["id_encoded"] === _id
? true
: false;
}
);
console.log("需去除的数组:", needRemoveData);
needRemoveData.forEach((item) => {
item.remove();
});
}
}
);
$jq(document).on("click", "#imglist_history .delImg", function (e) {
e.preventDefault();
let obj = $jq(this);
let _t_web = obj.attr("t-web");
let _t_id = obj.attr("t-id");
console.log(_t_web, _t_id);
let deleteStatus = mobile.chartBed.storage.delete(_t_web, _t_id);
if (deleteStatus) {
obj.parent()?.remove();
}
});
}
let imgBtn = `
图片`;
let menu = `
`;
GM_addStyle(`
#filedata,
#filedata_kggzs,
#filedata_hello,
#filedata_z4a{
display: none;
}
.comiis_tip dt p{
padding: 10px 0px;
}
.upload-image-water{
overflow-y: auto;
}
.upload-image-water img{
width: 100%;
margin: 10px 0px;
}
`);
let jqMenu = $jq(menu);
jqMenu
.find(".comiis_upbox.comiis_allowpostimg")
.append(
$jq(
".comiis_wzpost.comiis_input_style .comiis_upbox.comiis_allowpostimg"
).children()
);
$jq(".swiper-wrapper.comiis_post_ico").append(imgBtn);
$jq("#comiis_post_tab").append(jqMenu);
Utils.tryCatch().run(chartbedByBBSMT);
Utils.tryCatch().run(chartbedByKggzs);
Utils.tryCatch().run(chartbedByHello);
Utils.tryCatch().run(chartbedByZ4a);
Utils.tryCatch().run(chartbedByMT);
Utils.tryCatch().run(chartbedByHistory);
},
/**
* 编辑器优化-简略
*/
editorOptimization() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.forumPost], "v49")) {
return;
}
GM_addStyle(`
#comiis_foot_menu_beautify{
position: fixed;
display: inline-flex;
z-index: 90;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 48px;
overflow: hidden;
align-content: center;
justify-content: center;
align-items: center;
}
#comiis_foot_menu_beautify_big{
position: fixed;
display: inline-flex;
flex-direction: column;
z-index: 92;
left: 0;
right: 0;
bottom: 0;
width: 100%;
min-height: 120px;
overflow: hidden;
align-content: center;
justify-content: center;
align-items: center;
}
#comiis_foot_menu_beautify input.bg_e.f_c::-webkit-input-placeholder {
padding-left:10px;
color:#999999;
}
#comiis_foot_menu_beautify .reply_area ul li a{
display: block;
width: 22px;
height: 22px;
padding: 4px 8px;
margin: 8px 0;
position: relative;
}
#comiis_foot_menu_beautify .reply_area ul{
display: inline-flex;
align-content: center;
align-items: center;
justify-content: center;
}
#comiis_foot_menu_beautify .reply_area,
#comiis_foot_menu_beautify .reply_area ul{
width: 100%;
}
#comiis_foot_menu_beautify .reply_area li a i {
width: 22px;
height: 22px;
line-height: 22px;
font-size: 22px;
}
#comiis_foot_menu_beautify .reply_area li a span {
position: absolute;
display: block;
font-size: 10px;
height: 14px;
line-height: 14px;
padding: 0 6px;
right: -8px;
top: 4px;
overflow: hidden;
border-radius: 20px;
}
#comiis_foot_menu_beautify li[data-attr="回帖"] input{
border: transparent;
border-radius: 15px;
height: 30px;
width: 100%;
}
#comiis_foot_menu_beautify_big .comiis_smiley_box{
padding: 6px 6px 0px;
}
#comiis_foot_menu_beautify_big .reply_area{
margin: 10px 0px 5px 0px;
}
#comiis_foot_menu_beautify_big .reply_area ul{
display: inline-flex;
align-content: center;
justify-content: center;
align-items: flex-end;
}
#comiis_foot_menu_beautify_big li[data-attr="回帖"]{
width: 75vw;
margin-right: 15px;
}
#comiis_foot_menu_beautify_big .reply_user_content{
width: 75vw;
word-wrap: break-word;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin: 8px 10px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"]{
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] .fastpostform_new{
text-align: center;
margin-bottom: 28px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] .fastpostform_new i{
font-size: 22px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] input{
width: 60px;
height: 30px;
border: transparent;
color: #ffffff;
background: #d1c9fc;
border-radius: 30px;
margin-bottom: 6px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] input[data-text='true']{
background: #7a61fb;
}
#comiis_foot_menu_beautify_big li[data-attr="回帖"] textarea{
padding: 10px 10px 10px 10px;
border: transparent;
border-radius: 6px;
min-height: 70px;
max-height: 180px;
background: #e9e8ec;
overflow-y: auto;
width: -webkit-fill-available;
}
#comiis_foot_menu_beautify .reply_area li[data-attr="回帖"]{
width: 65%;
margin: 0px 3%;
text-align: center;
}
#comiis_foot_menu_beautify .reply_area li:not(first-child){
width: 7%;
text-align: -webkit-center;
text-align: center;
}
#comiis_foot_menu_beautify_big .other_area{
width: 100%;
text-align: center;
}
#comiis_foot_menu_beautify_big .other_area .menu_icon a{
margin: 0px 20px;
}
#comiis_foot_menu_beautify_big .other_area i{
font-size: 24px;
}
#comiis_foot_menu_beautify_big .other_area #comiis_insert_ubb_tab i{
font-size: 16px;
}
#comiis_foot_menu_beautify_big .other_area .menu_body{
background: #f4f4f4;
}
#comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .comiis_optimization{
max-height: 140px;
overflow-y: auto;
flex-direction: column;
}
#comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .bqbox_t{
background: #fff;
}
#comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .bqbox_t ul#comiis_smilies_key li a.bg_f.b_l.b_r{
background: #f4f4f4 !important;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #comiis_pictitle_key{
display: -webkit-box;
top: 0px;
left: 0px;
height: 42px;
line-height: 42px;
overflow: hidden;
overflow-x: auto;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #comiis_pictitle_key li{
padding: 0px 10px;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab .comiis_upbox,
#comiis_foot_menu_beautify_big .menu_body #comiis_insert_ubb_tab .comiis_input_style{
height: 140px;
overflow-y: auto;
flex-direction: column;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_kggzs,
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_hello,
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_z4a,
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_mt{
display:none;
}
@media screen and (max-width: 350px) {
.comiis_bqbox .bqbox_c li {
width: 14.5%;
}
}
@media screen and (min-width: 350px) and (max-width: 400px) {
.comiis_bqbox .bqbox_c li {
width: 12.5%;
}
}
@media screen and (min-width: 400px) and (max-width: 450px) {
.comiis_bqbox .bqbox_c li {
width: 11%;
}
}
@media screen and (min-width: 450px) and (max-width: 500px) {
.comiis_bqbox .bqbox_c li {
width: 10%;
}
}
@media screen and (min-width: 500px) and (max-width: 550px) {
.comiis_bqbox .bqbox_c li {
width: 9.5%;
}
}
@media screen and (min-width: 550px) and (max-width: 600px) {
.comiis_bqbox .bqbox_c li {
width: 9%;
}
}
@media screen and (min-width: 600px) and (max-width: 650px) {
.comiis_bqbox .bqbox_c li {
width: 8.5%;
}
}
@media screen and (min-width: 650px) and (max-width: 700px) {
.comiis_bqbox .bqbox_c li {
width: 8%;
}
}
@media screen and (min-width: 700px) and (max-width: 750px) {
.comiis_bqbox .bqbox_c li {
width: 7.5%;
}
}
@media screen and (min-width: 750px) and (max-width: 800px) {
.comiis_bqbox .bqbox_c li {
width: 7%;
}
}
@media screen and (min-width: 800px) and (max-width: 850px) {
.comiis_bqbox .bqbox_c li {
width: 6.5%;
}
}
@media screen and (min-width: 850px) and (max-width: 1200px) {
.comiis_bqbox .bqbox_c li {
width: 6%;
}
}
@media screen and (min-width: 1200px){
.comiis_bqbox .bqbox_c li {
width: 4.5%;
}
}
#imglist_settings button{
font-size: 13.333px;
color: #9baacf;
outline: none;
border: none;
height: 35px;
width: 80px;
border-radius: 10px;
box-shadow: 0.3rem 0.3rem 0.6rem #c8d0e7, -0.2rem -0.2rem 0.5rem #ffffff;
font-weight: 800;
line-height: 40px;
background: #efefef;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
}
#imglist_settings button:active{
box-shadow: inset 0.2rem 0.2rem 0.5rem #c8d0e7, inset -0.2rem -0.2rem 0.5rem #ffffff !important;
color: #638ffb !important;
}
`);
let pl = $jq("#comiis_foot_memu .comiis_flex li")[1];
let dz = $jq("#comiis_foot_memu .comiis_flex li")[2];
let sc = $jq("#comiis_foot_memu .comiis_flex li")[3];
let form_action = $jq("#fastpostform").attr("action");
let form_serialize = $jq("#fastpostform").serialize();
let form_url = $jq("#fastpostform .header_y a").attr("href");
$jq("#needmessage[name='message']").remove();
$jq("#imglist").remove();
$jq("#fastpostsubmitline").remove();
$jq("#fastpostsubmit").remove();
$jq("#comiis_foot_memu").hide();
$jq("#comiis_foot_memu").after(
$jq(`
`,
app: true,
success: async (x) => {
let localDataUser = lanzou.storage.getUser();
let localDataPwd = lanzou.storage.getPwd();
if (localDataUser != "" && localDataPwd != "") {
x.xtipdiv.querySelector(".xinput.xful[type='text']").value =
localDataUser;
x.xtipdiv.querySelector(".xinput.xful[type='password']").value =
localDataPwd;
}
x.xtipdiv.querySelector(".xbutton.xful.xblue").onclick =
async () => {
let inputUser = x.xtipdiv
.querySelector(".xinput.xful[type='text']")
.value.trim();
let inputPwd = x.xtipdiv
.querySelector(".xinput.xful[type='password']")
.value.trim();
if (inputUser != "" && inputPwd != "") {
xtips.toast("登录中请稍后...");
let _formhash_ = await lanzou.login_getFormHash(
inputUser,
inputPwd
);
console.log(_formhash_);
if (_formhash_ == 4) {
console.log("已登录");
lanzou.storage.setUser(inputUser);
lanzou.storage.setPwd(inputPwd);
if (lanzou.storage.getFormhash() == null) {
console.log(
"未知原因,已登录但本地未保存formhash,建立临时值"
);
lanzou.storage.setFormhash(_formhash_);
}
xtip.close(x.mainid);
showView();
return;
}
if (_formhash_ == null) {
return;
}
let loginStatus = await lanzou.login(
inputUser,
inputPwd,
_formhash_
);
if (loginStatus) {
console.log("登录成功");
console.log(inputUser, inputPwd, _formhash_);
lanzou.storage.setUser(inputUser);
lanzou.storage.setPwd(inputPwd);
lanzou.storage.setFormhash(_formhash_);
xtip.close(x.mainid);
showView();
}
} else {
xtips.toast("账号或密码不能为空");
}
};
},
});
console.log(document.querySelector(".xinput.xful[type='password']"));
Utils.listenKeyPress(
document.querySelector(".xinput.xful[type='password']"),
(keyName, otherKey) => {
if (keyName === "Enter") {
console.log("回车按键");
$jq("button.xbutton.xful.xblue").click();
}
}
);
}
async function showLanZouView(user, pwd) {
popup2.toast("校验登录信息中...");
lanZouViewShowLock = false;
let sheet = null;
let _formhash_ = lanzou.storage.getFormhash();
let loginStatus = await lanzou.login(user, pwd, _formhash_);
if (!loginStatus) {
xtips.toast("登录过期");
lanzou.storage.delFormhash();
showLoginView();
return;
}
popup2.closeToast();
sheet = xtip.sheet({
btn: [
`欢迎! ${user}`,
'上传
',
"查看历史上传",
],
});
$jq("#lanzouuploadfilebtn")
.off("change")
.change(async (e) => {
let lanzouChooseFile = e.currentTarget.files[0];
console.log(lanzouChooseFile);
let uploadFileInfo = await lanzou.uploadFile(lanzouChooseFile);
if (uploadFileInfo) {
let tempData = lanzou.storage.getUploadFiles();
tempData = tempData.concat(uploadFileInfo);
GM_setClipboard(
`${uploadFileInfo["is_newd"]}/${uploadFileInfo["f_id"]}`
);
xtips.toast("已复制到剪贴板");
console.log(tempData);
lanzou.storage.setUploadFiles(tempData);
}
});
let anyTouchNode = new AnyTouch(document.getElementById(sheet));
anyTouchNode.on("tap", (e) => {
if (
document
.getElementById(sheet)
.querySelector(".xtiper_bg")
.outerHTML.indexOf(e.target.outerHTML) != -1
) {
/* 点击背景不关闭小窗 */
return;
}
if (
document
.querySelectorAll(
".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li"
)[0]
.outerHTML.indexOf(e.target.outerHTML) != -1
) {
/* 用户 */
xtip.confirm("确定退出登录吗?", {
btn1: async function () {
let logoutStatus = await lanzou.outLogin(
lanzou.storage.getUser()
);
if (logoutStatus) {
xtips.toast("退出登录成功");
lanzou.storage.delFormhash();
anyTouchNode.off("tap");
xtip.close(sheet);
lanZouViewShowLock = false;
} else {
xtips.toast("退出登录失败");
}
},
});
return;
}
if (
document
.querySelectorAll(
".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li"
)[1]
.outerHTML.indexOf(e.target.outerHTML) != -1
) {
/* 上传 */
$jq("#lanzouuploadfilebtn").val("");
$jq("#lanzouuploadfilebtn").click();
return;
}
if (
document
.querySelectorAll(
".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li"
)[2]
.outerHTML.indexOf(e.target.outerHTML) != -1
) {
/* 查看历史上传 */
anyTouchNode.off("tap");
xtip.close(sheet);
showUploadFiles();
return;
}
if (
document
.querySelectorAll(
".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li"
)[3]
.outerHTML.indexOf(e.target.outerHTML) != -1
) {
/* 取消 */
anyTouchNode.off("tap");
xtip.close(sheet);
lanZouViewShowLock = false;
return;
}
});
}
async function showView() {
let user = lanzou.storage.getUser();
let pwd = lanzou.storage.getPwd();
let formhash = lanzou.storage.getFormhash();
if (user == "" || pwd == "" || formhash == null) {
showLoginView();
} else {
showLanZouView(user, pwd);
}
}
function insertBtn() {
let comiis_left_Touch = document.createElement("li");
comiis_left_Touch.className = "comiis_left_Touch";
let ANode = document.createElement("a");
ANode.setAttribute("href", "javascript:;");
ANode.className = "blacklist";
ANode.innerHTML = `
蓝奏云
`;
ANode.onclick = () => {
if (!lanZouViewShowLock) {
lanZouViewShowLock = true;
showView();
} else {
console.log("重复点击");
}
};
comiis_left_Touch.append(ANode);
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(
comiis_left_Touch
);
}
insertBtn();
},
/**
* 加载下一页的评论
*/
loadNextComments() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.forumPost], "v21")) {
return;
}
if (document.title.indexOf("提示信息 - MT论坛") != -1) {
return;
}
function autoLoadNextPageComments(post_comments_list) {
/* 自动加载下一页的评论 */
$jq("#loading-comment-tip").parent().css("display", "");
let next_page_url = post_comments_list.children[2].href;
console.log("预设,获取下一页url:", next_page_url);
if (next_page_url.indexOf("javascript:;") != -1) {
console.log(post_comments_list);
console.log("无多页评论");
$jq("#loading-comment-tip").parent()?.remove();
return;
}
function _loadNextComments_() {
return new Promise((resolve) => {
$jq("#loading-comment-tip").text("正在加载评论中...");
$jq("#loading-comment-tip").parent().css("display", "");
let _url_ = next_page_url;
$jq.get(_url_, function (data, status, xhr) {
console.log("正在请求的下一页url", _url_);
let postlist = $jq(data);
let kqideSourceNode = $jq(".comiis_postlist.kqide");
let postDOM = postlist.find(".comiis_postlist.kqide").html();
let get_next_page_url = postlist.find(".nxt");
if (get_next_page_url.length != 0) {
console.log("成功获取到下一页-评论");
next_page_url = get_next_page_url.attr("href");
let newURL = new URL(_url_);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log(
"设置当前的url为请求的下一页url",
window.location.origin + setLocationUrl
);
if (window === top.window) {
window.history.pushState("forward", null, setLocationUrl);
}
} else {
console.log("评论全部加载完毕,关闭监听事件");
let newURL = new URL(next_page_url);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log("设置当前的url为请求的最后一页url", setLocationUrl);
if (window === top.window) {
window.history.pushState("forward", null, setLocationUrl);
}
$jq(".comiis_page.bg_f").remove();
$jq("#loading-comment-tip").text("已加载完所有评论");
$jq("#loading-comment-tip").parent()?.remove();
$jq("#loading-comment-tip").off("click", _loadNextComments_);
$jq(window).off("scroll", scroll_loadNextComments);
}
kqideSourceNode.append(postDOM);
mobileRepeatFunc.main();
resolve();
});
});
}
var lock = new Utils.lockFunction(_loadNextComments_);
function scroll_loadNextComments() {
if (
Math.ceil($jq(window).scrollTop() + $jq(window).height() + 150) >=
$jq(document).height()
) {
/* load data */
lock.run();
}
}
$jq(window).on("scroll", scroll_loadNextComments);
$jq("#loading-comment-tip").text("请上下滑动或点击加载");
$jq("#loading-comment-tip").on("click", _loadNextComments_);
}
let tip_html = `
`;
$jq(".comiis_bodybox").append($jq(tip_html));
let commentsEle =
document.querySelector(".comiis_pltit span.f_d") ||
document.querySelector("#comiis_foot_memu .comiis_kmvnum");
if (
document.querySelector(".comiis_pltit h2") &&
document
.querySelector(".comiis_pltit h2")
.textContent.indexOf("暂无评论") != -1
) {
$jq("#loading-comment-tip").parent()?.remove();
console.log("暂无评论");
return;
}
let commentsNum = parseInt(commentsEle.textContent);
if (commentsNum >= 10) {
Utils.waitNode(".comiis_page.bg_f").then((next_page_dom) => {
console.log("找到下一页元素!");
autoLoadNextPageComments(next_page_dom[0]);
});
} else {
$jq("#loading-comment-tip").parent()?.remove();
console.log("无多页评论");
}
},
/**
* 加载上一页的评论
*/
loadPrevComments() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.forumPost], "v32")) {
return;
}
if (document.title.indexOf("提示信息 - MT论坛") != -1) {
return;
}
if (document.querySelector(".comiis_pltit span.f_d")) {
return;
}
function autoLoadPrevPageComments() {
/* 自动加载上一页的评论 */
let post_comments_list = document.querySelector(".comiis_page.bg_f");
let prev_page_url = post_comments_list.children[0].href;
console.log("预设,获取上一页url:", prev_page_url);
$jq("#loading-comment-tip-prev").text("请上下滑动或点击加载");
$jq("#loading-comment-tip-prev").on("click", _loadPrevComments_);
function _loadPrevComments_() {
return new Promise((resolve) => {
$jq("#loading-comment-tip-prev").text("正在加载评论中...");
$jq("#loading-comment-tip-prev").parent()?.css("display", "");
let _url_ = prev_page_url;
$jq.get(_url_, function (data, status, xhr) {
console.log("正在请求的上一页评论:", prev_page_url);
let postlist = $jq(data);
let kqideSourceNode = $jq(".comiis_postlist.kqide");
let postDOM = postlist.find(".comiis_postlist.kqide").html();
let get_pregv_page_url = postlist.find(".prev");
if (get_pregv_page_url.length != 0) {
console.log("成功获取到上一页-评论");
prev_page_url = get_pregv_page_url.attr("href");
let newURL = new URL(_url_);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log(
"设置当前的url为请求的上一页url",
window.location.origin + setLocationUrl
);
if (window === top.window) {
window.history.pushState("forward", null, setLocationUrl);
}
kqideSourceNode.prepend(postDOM);
} else {
kqideSourceNode.prepend(postDOM);
let newURL = new URL(prev_page_url);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log(
"已到顶页,设置当前的url第一页url",
window.location.origin + setLocationUrl
);
if (window === top.window) {
window.history.pushState("forward", null, setLocationUrl);
}
console.log("上一页评论全部加载完毕,关闭监听事件");
let page_title = postlist.find(".comiis_viewtit")[0].outerHTML;
console.log($jq(page_title));
kqideSourceNode.prepend($jq(page_title)[0]);
/* $jq(".comiis_page.bg_f").remove(); */
$jq("#loading-comment-tip-prev").parent().remove();
$jq("#loading-comment-tip-prev").off(
"click",
_loadPrevComments_
);
$jq(window).off("scroll");
}
mobileRepeatFunc.main();
resolve();
});
});
}
function scroll_loadPrevComments() {
if ($jq(window).scrollTop() <= 50) {
lock.run();
}
}
var lock = new Utils.lockFunction(_loadPrevComments_);
$jq(window).on("scroll", scroll_loadPrevComments);
}
console.log("当前不在第一页,加载上一页评论");
let tip_html = `
`;
$jq(".comiis_bodybox script")[0].after($jq(tip_html)[0]);
if (
document.querySelector(".comiis_pltit h2") &&
document
.querySelector(".comiis_pltit h2")
.textContent.indexOf("暂无评论") != -1
) {
console.log("暂无上一页评论");
$jq("#loading-comment-tip-prev").parent()?.remove();
return;
}
autoLoadPrevPageComments();
},
/**
* 在线用户查看
*/
onlineUserView() {
if (!MT_CONFIG.methodRunCheck([], "v56")) {
return;
}
function handleFilterInfo(userListNode) {
/* 过滤用户/UID */
let inputNode = $jq(".online-user-filter input");
let isSeaching = false;
inputNode.on("propertychange input", function () {
let inputText = this.value.trim();
if (isSeaching) {
return;
}
isSeaching = true;
if (inputText == "") {
$jq(".NZ-MsgBox-alert .msgcon center").hide();
$jq(".online-user-list li.online-item").each((index, item) => {
item.removeAttribute("style");
});
isSeaching = false;
return;
}
$jq(".NZ-MsgBox-alert .msgcon center").text("搜索中...");
$jq(".NZ-MsgBox-alert .msgcon center").show();
let isFind = false;
$jq(".online-user-list li.online-item").each((index, item) => {
if (
item
.getAttribute("data-name")
.match(new RegExp(inputText, "ig")) ||
item.getAttribute("data-sf").match(new RegExp(inputText, "ig")) ||
item.getAttribute("data-uid").match(new RegExp(inputText, "ig"))
) {
isFind = true;
$jq(".NZ-MsgBox-alert .msgcon center").hide();
item.removeAttribute("style");
} else {
item.setAttribute("style", "display:none;");
}
});
if (!isFind) {
$jq(".NZ-MsgBox-alert .msgcon center").text("空");
$jq(".NZ-MsgBox-alert .msgcon center").show();
}
isSeaching = false;
});
}
function showView(data) {
console.log(data);
let totalOnline = data["totalOnline"]; /* 全部在线用户 */
let onlineUser = data["onlineUser"]; /* 在线会员用户(已注册账号的) */
let noRegisterUser = data["noRegisterUser"]; /* 游客 */
let invisibleUser = data["invisibleUser"]; /* 隐身的用户 */
let userList = data["data"]; /* 用户列表 */
/* 显示列表 */
let dialogCSSNode = GM_addStyle(`
.online-user-filter input{
width: -webkit-fill-available;
height: 30px;
margin: 8px 20px;
border: 0px;
border-bottom: 1px solid;
}
.online-user-list{
height: 300px;
}
.online-user-list li{
display: flex;
margin: 18px 0px;
align-items: center;
}
.online-user-avatar{
margin-left: 30px;
margin-right: 30px;
display: flex;
align-items: center;
justify-content: center;
}
.online-user-avatar img{
width: 80px;
height: 80px;
border-radius: 8px;
}
.online-user-info{
text-align: center;
}
.online-user-list{
overflow-y: auto;
}
.online-user-list div.online-user-name p::before,
.online-user-list div.online-user-sf p::before,
.online-user-list div.online-user-uid p::before{
display: flex;
width: 70px;
float: left;
}
.online-user-list div.online-user-name p::before{
content: "用户名:";
}
.online-user-list div.online-user-sf p::before{
content: "身份:";
}
.online-user-list div.online-user-uid p::before{
content: "UID:";
}
.online-user-list div.online-user-sf p[data-sf="会员"]{
color: #88b500;
}
.online-user-list div.online-user-sf p[data-sf="版主"]{
color: #2db5e3;
}
.online-user-list div.online-user-sf p[data-sf="超级版主"]{
color: #e89e38;
}
.online-user-list div.online-user-sf p[data-sf="管理员"]{
color: #ff5416;
}
`);
$jq.NZ_MsgBox.alert({
title: "在线用户查看",
content: `
${totalOnline} 人在线 - ${onlineUser} 会员${
invisibleUser == 0 ? "" : `(${invisibleUser}隐身)`
} - ${noRegisterUser} 位游客
处理数据中...
`,
type: "",
location: "center",
buttons: {
confirm: {
text: "确定",
},
},
callback: () => {
dialogCSSNode?.remove();
},
});
let userListHTML = "";
let userListNode = null;
userList.forEach((item) => {
userListHTML += `
`;
});
popup2.closeMask();
$jq(".NZ-MsgBox-alert .msgcon center").hide();
userListNode = $jq(userListHTML);
handleFilterInfo();
$jq(".online-user-list").append(userListNode);
userListNode.on("click", ".online-user-avatar", function () {
window.open(
`home.php?mod=space&uid=${this.parentElement.getAttribute(
"data-uid"
)}&do=profile`,
"_blank"
);
});
}
function getOnlineUsers() {
/* 获取在线用户列表 */
let result = {
status: false,
totalOnline: 0,
onlineUser: 0,
noRegisterUser: 0,
invisibleUser: 0,
data: [],
};
return new Promise((resolve) => {
GM_xmlhttpRequest({
url: "https://bbs.binmt.cc/forum.php?showoldetails=yes",
method: "GET",
timeout: 5000,
headers: {
"User-Agent": Utils.getRandomPCUA(),
},
onload: function (response) {
console.log(response);
let pageHTML = $jq(response.responseText);
let onlineList = pageHTML.find("#onlinelist ul li");
onlineList.each((index, item) => {
let uid = item
.querySelector("a")
.getAttribute("href")
.match("uid-(.+?).html")[1]; /* uid */
let avatar = MT_CONFIG.getAvatar(uid, "middle"); /* 头像 */
let name = item.querySelector("a").innerText; /* 名字 */
let sf = ""; /* 身份 */
let space = item
.querySelector("a")
.getAttribute("href"); /* 个人空间页 */
let memberSrc = item.querySelector("img").src;
if (memberSrc.indexOf("online_member") != -1) {
sf = "会员";
} else if (memberSrc.indexOf("online_moderator") != -1) {
sf = "版主";
} else if (memberSrc.indexOf("online_supermod") != -1) {
sf = "超级版主";
} else if (memberSrc.indexOf("online_admin") != -1) {
sf = "管理员";
} else {
sf = "未知身份";
}
result.data = [
...result.data,
{
uid: uid,
avatar: avatar,
name: name,
sf: sf,
space: space,
},
];
});
let onlineInfo = pageHTML
.find("#online div.bm_h span.xs1")
.text();
console.log(onlineInfo);
result.totalOnline = Utils.parseInt(
onlineInfo.match(/([0-9]*)\s*人在线/i),
0
);
result.onlineUser = Utils.parseInt(
onlineInfo.match(/([0-9]*)\s*会员/i),
0
);
result.noRegisterUser = Utils.parseInt(
onlineInfo.match(/([0-9]*)\s*位游客/i),
0
);
result.invisibleUser = Utils.parseInt(
onlineInfo.match(/([0-9]*)\s*隐身/i),
0
);
result.status = true;
resolve(result);
},
onerror: function () {
popup2.toast("网络异常,请重新获取");
resolve(result);
},
ontimeout: function () {
popup2.toast("请求超时");
resolve(result);
},
});
});
}
function insertLeftButton() {
/* 插入左边按钮 */
let btnNode = `
在线用户查看
`;
btnNode = $jq(btnNode);
btnNode.on("click", function () {
popup2.showLoadingMask();
popup2.toast("获取在线用户列表中");
getOnlineUsers().then((resolve) => {
if (resolve.status) {
popup2.closeToast();
showView(resolve);
} else {
popup2.toast("获取在线用户列表失败");
popup2.closeMask();
}
});
});
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(
btnNode
);
}
insertLeftButton();
},
/**
* 当本页面动态加载帖子需要重复加载的东西
*/
pageAfterDOMChangeRunFunction() {
if (
!MT_CONFIG.methodRunCheck([
/bbs.binmt.cc\/forum/,
/bbs.binmt.cc\/home.php\?mod=space&do=thread&view=me/,
/home.php\?mod=space&uid=.+&do=thread&view=me/,
])
) {
return;
}
function beforeHookRun() {
Utils.tryCatch().run(mobileRepeatFunc.showUserUID);
Utils.tryCatch().run(mobileRepeatFunc.shieldUser);
Utils.tryCatch().run(mobileRepeatFunc.shieldPlate);
Utils.tryCatch().run(mobileRepeatFunc.pageSmallWindowBrowsingForumPost);
Utils.tryCatch().run(mobileRepeatFunc.codeQuoteCopyBtn);
}
document.body.addEventListener("DOMNodeInserted", (event) => {
let ele = event.target;
if (
ele.className != null &&
ele.className.indexOf("comiis_forumlist") != -1
) {
beforeHookRun();
}
});
},
/**
* 付费主题白嫖提醒
*/
paymentSubjectReminder() {
let urlForumPostMatchStatus = window.location.href.match(
MT_CONFIG.urlRegexp.forumPost
);
let urlHomeSpaceMatchStatus = window.location.href.match(
MT_CONFIG.urlRegexp.homeSpaceUrl
);
let urlGuideMatchStatus = window.location.href.match(
MT_CONFIG.urlRegexp.forumGuideUrl
);
let urlCommunityMatchStatus =
window.location.href.match(MT_CONFIG.urlRegexp.communityUrl) ||
window.location.href.match(MT_CONFIG.urlRegexp.plateUrl);
let urlBBSMatchStatus = window.location.href.match(
MT_CONFIG.urlRegexp.bbs
);
let storageMatchStatus = GM_getValue("v44") != null;
let setTipForumPostList = GM_getValue("tipToFreeSubjectForumPost", []);
const paymentSubjectReminderHome = {
getData() {
/* 获取数据 */
return GM_getValue("tipToFreeSubjectForumPost") == null
? []
: GM_getValue("tipToFreeSubjectForumPost");
},
setData(data) {
/* 设置数据 */
GM_setValue("tipToFreeSubjectForumPost", data);
},
async insertButtonView() {
/* 插入-底部导航-我的-付费主题白嫖列表(按钮) */
let comiis_left_Touch = document.createElement("li");
comiis_left_Touch.className = "comiis_left_Touch";
let paymentSubjectReminderHomeBtn = document.createElement("a");
paymentSubjectReminderHomeBtn.setAttribute("href", "javascript:;");
paymentSubjectReminderHomeBtn.className = "paymentsubjectreminder";
paymentSubjectReminderHomeBtn.innerHTML = `
付费主题白嫖列表
`;
GM_addStyle(`
.NZ-MsgBox-alert .msgcontainer .msgtitle {
text-align: center !important;
}
#autolist .k_misign_lu img {
width: 40px;
height: 40px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.k_misign_lc .f_c{
margin: 5px 0px;
}
details.subjectnotvisit,
details.subjectcanvisit{
margin-left: 20px;
}
`);
paymentSubjectReminderHomeBtn.onclick = () => {
paymentSubjectReminderHome.showView();
};
comiis_left_Touch.append(paymentSubjectReminderHomeBtn);
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(
comiis_left_Touch
);
/* Array.from(document.querySelectorAll(".comiis_myinfo_list.bg_f.cl")).forEach((ele) => {
if (ele.innerText.match(/消息提醒|资料设置|我的积分|我的勋章|我的道具/)) {
ele.append(paymentSubjectReminderHomeBtn);
return;
}
}) */
},
async showView() {
/* 显示-付费主题白嫖列表(dialog) */
let data = paymentSubjectReminderHome.getData();
console.log("准备排序的数据: ", data);
$jq.NZ_MsgBox.alert({
title: "付费主题白嫖列表",
content: "
获取中...",
type: "",
location: "center",
buttons: {
confirm: {
text: "确定",
},
},
});
let notVisitedTipContent = ""; /* 可白嫖且未访问 */
let notVisitedNums = 0; /* 可白嫖且未访问的数量 */
let isFreeContent = ""; /* 可白嫖帖子-未读的加左上边红点 */
let isPaidContent = ""; /* 需付费帖子 */
let isFreeNotVisitedContentList = [];
let isFreeContentList = [];
let isPaidContentList = [];
$jq.each(data, (i, v) => {
let timeColor = "#f91212";
let leftRedBtn = "";
if (new Date().getTime() > v["expirationTimeStamp"]) {
/* 可白嫖 */
timeColor = "#1e90ff";
if (v["isVisited"] == false) {
leftRedBtn =
'
';
notVisitedNums = notVisitedNums + 1;
} else {
console.log(v);
console.log("该帖子已经访问过");
}
}
let concatList = {
content: `
|
`,
timestamp: v["expirationTimeStamp"],
};
if (new Date().getTime() > v["expirationTimeStamp"]) {
/* 可白嫖 */
if (leftRedBtn != "") {
isFreeNotVisitedContentList = [
...isFreeNotVisitedContentList,
concatList,
];
} else {
isFreeContentList = [...isFreeContentList, concatList];
}
} else {
isPaidContentList = [...isPaidContentList, concatList];
}
});
console.log("可白嫖但未访问:", isFreeNotVisitedContentList);
console.log("可白嫖:", isFreeContentList);
console.log("未到白嫖时间:", isPaidContentList);
isFreeNotVisitedContentList.sort(
Utils.sortListByProperty((item) => {
return item["expirationTimeStamp"];
}, false)
);
isFreeContentList.sort(
Utils.sortListByProperty((item) => {
return item["timestamp"];
}, false)
);
isPaidContentList.sort(
Utils.sortListByProperty((item) => {
return item["timestamp"];
}, false)
);
console.log("排序后——可白嫖但未访问:", isFreeNotVisitedContentList);
console.log("排序后——可白嫖:", isFreeContentList);
console.log("排序后——未到白嫖时间:", isPaidContentList);
isFreeContent =
Utils.mergeArrayToString(isFreeNotVisitedContentList, (item) => {
return item["content"];
}) +
Utils.mergeArrayToString(isFreeContentList, (item) => {
return item["content"];
});
isPaidContent = Utils.mergeArrayToString(
isPaidContentList,
(item) => {
return item["content"];
}
);
if (notVisitedNums > 0) {
notVisitedTipContent = `
${notVisitedNums}`;
}
let dialogIsFreeContent =
'
可白嫖' +
notVisitedTipContent +
'
";
let dialogIsPaidContent =
'
需付费
";
$jq(".msgcon").html("");
$jq(".msgcon").append(dialogIsFreeContent);
$jq(".msgcon").append(dialogIsPaidContent);
$jq(".msgcon").css("height", "400px");
$jq(".delsubjecttip i.comiis_font").on("click", (e) => {
var t_index = e.target.parentElement.getAttribute("t-index");
popup2.confirm({
text: "
确定移出付费主题白嫖列表?
",
mask: true,
ok: {
callback: () => {
data.splice(t_index, 1);
console.log(data);
paymentSubjectReminderHome.setData(data);
Utils.deleteParentNode(e.target, (dom) => {
return dom.localName === "tr" ? true : false;
});
popup2.closeConfirm();
},
},
only: true,
});
});
$jq("#paymentSubjectReminderIsFreeList").on("click", "a", (e) => {
var t_index = e.target.getAttribute("t-index");
var t_href = e.target.getAttribute("t-href");
console.log(t_index, t_href);
data[t_index]["isVisited"] = true;
paymentSubjectReminderHome.setData(data);
window.open(t_href, "_blank");
e.target.setAttribute("style", "color: #000000;");
if (
e.target.parentElement.parentElement.children[0].className !=
"icon_msgs bg_del"
) {
return;
}
e.target.parentElement.parentElement.children[0].remove();
$jq("#paymentSubjectReminderIsFreeList").append(
e.target.parentElement.parentElement.parentElement.parentElement
.parentElement
);
let notVisitedNums = $jq(
".subjectcanvisit summary span.icon_msgs.bg_del.f_f"
).text();
notVisitedNums = parseInt(notVisitedNums) - 1;
if (notVisitedNums > 0) {
$jq(".subjectcanvisit summary span.icon_msgs.bg_del.f_f").html(
notVisitedNums
);
} else {
$jq(
".subjectcanvisit summary span.icon_msgs.bg_del.f_f"
).remove();
}
});
$jq("#paymentSubjectReminderIsPaidList").on("click", "a", (e) => {
var t_index = e.target.getAttribute("t-index");
var t_href = e.target.getAttribute("t-href");
console.log(t_index, t_href);
window.open(t_href, "_blank");
e.target.setAttribute("style", "color: #000000;");
});
},
};
if (storageMatchStatus && urlForumPostMatchStatus) {
/* 帖子内部-添加进提醒的按钮或者已添加进提醒的按钮点击移出 */
let paySubjectTip = $jq("span.kmren"); /* 购买主题的元素 */
if (paySubjectTip.length != 0) {
console.log("当前帖子存在需要购买主题");
let isAddTip = false;
let tipBtnHTML = "";
Array.from(setTipForumPostList).forEach((item, index) => {
if (window.location.href.match(item["url"])) {
isAddTip = true;
return;
}
});
if (isAddTip) {
console.log("已设置提醒");
tipBtnHTML = $jq(
`
`
);
tipBtnHTML.on("click", function () {
popup2.confirm({
text: "
确定移出付费主题白嫖列表?
",
ok: {
callback: function () {
let isRemove = false;
Array.from(setTipForumPostList).forEach((item, index) => {
if (window.location.href.match(item["url"])) {
setTipForumPostList.splice(index, 1);
GM_setValue(
"tipToFreeSubjectForumPost",
setTipForumPostList
);
isRemove = true;
Utils.asyncSetTimeOut("window.location.reload()", 1500);
return;
}
});
if (!isRemove) {
popup2.toast("移出失败");
} else {
popup2.closeConfirm();
popup2.toast({
text: "移出成功",
});
}
},
},
mask: true,
});
});
} else {
console.log("未设置提醒");
tipBtnHTML = $jq(
`
`
);
tipBtnHTML.on("click", () => {
let expirationTimeMatch = $jq(".kmren")
.parent()
.text()
.replace(/\t|\n/g, "")
.match(
/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}[\s]{1}[0-9]{1,2}:[0-9]{1,2}/
);
if (expirationTimeMatch.length == 0) {
popup2.toast({
text: "获取付费主题到期时间失败",
});
return;
}
let expirationTime = expirationTimeMatch[0];
let expirationTimeStamp =
Utils.formatTextToTimeStamp(expirationTime);
setTipForumPostList = setTipForumPostList.concat({
url: window.location.href,
title: document.title.replace(" - MT论坛", ""),
expirationTime: expirationTime,
expirationTimeStamp: expirationTimeStamp,
isVisited: false,
});
GM_setValue("tipToFreeSubjectForumPost", setTipForumPostList);
popup2.toast({
text: "添加成功",
});
setTimeout(function () {
window.location.reload();
}, 1500);
});
}
$jq(".comiis_head.f_top .header_y").append(tipBtnHTML);
}
}
if (storageMatchStatus && urlBBSMatchStatus) {
/* 底部导航-我的-提供类似小黑屋这种可查看设置提醒的帖子 */
paymentSubjectReminderHome.insertButtonView();
}
if (storageMatchStatus) {
/* 设置提醒小红点 */
function getTipNums() {
let needTipNums = 0;
Array.from(paymentSubjectReminderHome.getData()).forEach(
(item, index) => {
if (
new Date().getTime() > item["expirationTimeStamp"] &&
item["isVisited"] == false
) {
needTipNums += 1;
}
}
);
return needTipNums;
}
if (
urlHomeSpaceMatchStatus ||
urlGuideMatchStatus ||
urlCommunityMatchStatus
) {
/* 当前网页为,底部导航-我的 */
let redBtn = $jq(
".icon_msgs.bg_del.f_f"
); /* 底部导航-我的-右上角小红点 */
let tipNums = 0;
if (redBtn.length) {
tipNums = parseInt(redBtn.text());
$jq(".icon_msgs.bg_del.f_f").html(tipNums + getTipNums());
$jq(".comiis_head .header_z .kmuser em").append(
$jq(`
`)
);
} else {
let tipnums = getTipNums();
if (tipnums) {
/* $jq("ul.comiis_flex li.flex a[title='我的'] i.comiis_font").append($jq(`
${tipnums}`)); */
$jq(".comiis_head .header_z .kmuser em").append(
$jq(`
`)
);
}
}
}
if (urlBBSMatchStatus) {
/* 当前网页为,全部 */
let redBtn = $jq(
".sidenv_num.bg_del.f_f"
); /* 侧边栏-头像-右上角小红点 */
let tipNums = 0;
if (redBtn.length) {
tipNums = parseInt(redBtn.text());
$jq(".sidenv_num.bg_del.f_f").html(tipNums + getTipNums());
} else {
let tipnums = getTipNums();
if (tipnums) {
$jq(".sidenv_user em").before(
$jq(`
${tipnums}`)
);
}
}
if (getTipNums()) {
/* 当前网页为,侧边slider,付费白嫖列表 */
/* $jq(".comiis_left_Touch .paymentsubjectreminder div.flex").append($jq(`
`)); */
$jq(".comiis_left_Touch .paymentsubjectreminder div.flex").append(
$jq(`
`)
);
}
}
}
},
/**
* 发帖、回复、编辑预览功能
*/
previewPostForum() {
GM_addStyle(`
#comiis_mh_sub{
height:40px;
}
.gm_plugin_previewpostforum svg{
}
.gm_plugin_previewpostforum_html .comiis_message_table{
margin-top: 10px;
font-weight: initial;
line-height: 24px;
}
.gm_plugin_previewpostforum_html .comiis_message_table a{
height: auto;
float: unset;
color: #507daf !important;
}
.gm_plugin_previewpostforum_html .comiis_message_table i{
text-align: unset;
font-size: unset;
line-height: unset;
padding-top: unset;
display: unset;
}
.comiis_postli.comiis_list_readimgs.nfqsqi{
width: 100vw;
}
.gm_plugin_previewpostforum_html.double-preview{
width: 50vw;
}
.gm_plugin_previewpostforum_html.double-preview .comiis_over_box.comiis_input_style{
border-left: 1px solid;
}
`);
let open_double = GM_getValue(
"preview_post_forum_by_double",
"comiis_checkbox_close"
);
function addMenu_preview() {
/* 添加底部菜单-预览 */
$jq("#comiis_mh_sub .swiper-wrapper.comiis_post_ico").append(
$jq(
`
预览`
)
);
}
function addMenu_doubleColumnPreview() {
/* 添加底部菜单-高级-使用双列预览 */
$jq("#htmlon")
.parent()
.append(
$jq(`
使用双列预览
`)
);
$jq("#postformdouble").on("click", function () {
let obj = $jq(this);
let code_obj = obj.parent().find(".comiis_checkbox");
if (code_obj.hasClass("comiis_checkbox_close")) {
GM_setValue("preview_post_forum_by_double", true);
} else {
GM_setValue("preview_post_forum_by_double", false);
}
});
}
function addMenu_immersiveInput() {
/* 添加底部菜单-高级-使用沉浸输入 */
$jq("#htmlon")
.parent()
.append(
$jq(`
使用沉浸输入
`)
);
$jq("#immersiveinput").on("click", function () {
let obj = $jq(this);
let code_obj = obj.parent().find(".comiis_checkbox");
console.log(code_obj.attr("class"));
if (code_obj.hasClass("comiis_checkbox_close")) {
$jq(".comiis_wzpost ul li.comiis_flex").hide(); /* 板块、标题 */
$jq(
".comiis_wzpost ul li.comiis_styli.kmquote"
).hide(); /* 回复别人的quote */
$jq("#pollchecked")
.parent()
.parent()
.hide(); /* 投票,最多可填写 20 个选项 */
$jq("#pollm_c_1").hide(); /* 投票,增加一项 */
$jq(
".comiis_polloption_add+div.f_0"
).hide(); /* 投票,增加一项(编辑状态下) */
$jq(
".comiis_wzpost ul li.comiis_thread_content:contains('内容')"
).hide(); /* 投票,内容 */
} else {
$jq(".comiis_wzpost ul li.comiis_flex").show();
$jq(".comiis_wzpost ul li.comiis_styli.kmquote").show();
$jq("#pollchecked").parent().parent().show();
$jq("#pollm_c_1").show();
$jq(".comiis_polloption_add+div.f_0").show();
$jq(
".comiis_wzpost ul li.comiis_thread_content:contains('内容')"
).show();
}
window.dispatchEvent(new Event("resize"));
});
}
const smiliesDictionaries = {
/* 表情字典 */
"[呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq001.gif",
"[撇嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq002.gif",
"[色]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq003.gif",
"[发呆]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq004.gif",
"[得意]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq005.gif",
"[流泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq006.gif",
"[害羞]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq007.gif",
"[闭嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq008.gif",
"[睡]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq009.gif",
"[大哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq010.gif",
"[尴尬]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq011.gif",
"[发怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq012.gif",
"[调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq013.gif",
"[呲牙]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq014.gif",
"[惊讶]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq015.gif",
"[难过]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq016.gif",
"[酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq017.gif",
"[冷汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq018.gif",
"[抓狂]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq019.gif",
"[吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq020.gif",
"[偷笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq021.gif",
"[可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq022.gif",
"[白眼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq023.gif",
"[傲慢]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq024.gif",
"[饥饿]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq025.gif",
"[困]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq026.gif",
"[惊恐]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq027.gif",
"[流汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq028.gif",
"[憨笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq029.gif",
"[装逼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq030.gif",
"[奋斗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq031.gif",
"[咒骂]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq032.gif",
"[疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq033.gif",
"[嘘]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq034.gif",
"[晕]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq035.gif",
"[折磨]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq036.gif",
"[衰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq037.gif",
"[骷髅]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq038.gif",
"[敲打]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq039.gif",
"[再见]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq040.gif",
"[擦汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq041.gif",
"[抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq042.gif",
"[鼓掌]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq043.gif",
"[糗大了]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq044.gif",
"[坏笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq045.gif",
"[左哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq046.gif",
"[右哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq047.gif",
"[哈欠]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq048.gif",
"[鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq049.gif",
"[委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq050.gif",
"[快哭了]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq051.gif",
"[阴脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq052.gif",
"[亲亲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq053.gif",
"[吓]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq054.gif",
"[可怜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq055.gif",
"[眨眼睛]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq056.gif",
"[笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq057.gif",
"[dogeQQ]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq058.gif",
"[泪奔]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq059.gif",
"[无奈]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq060.gif",
"[托腮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq061.gif",
"[卖萌]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq062.png",
"[斜眼笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq063.gif",
"[喷血]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq064.gif",
"[惊喜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq065.gif",
"[骚扰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq066.gif",
"[小纠结]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq067.gif",
"[我最美]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq068.gif",
"[菜刀]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq069.gif",
"[西瓜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq070.gif",
"[啤酒]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq071.gif",
"[篮球]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq072.gif",
"[乒乓]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq073.gif",
"[咖啡]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq074.gif",
"[饭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq075.gif",
"[猪]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq076.gif",
"[玫瑰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq077.gif",
"[凋谢]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq078.gif",
"[示爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq079.gif",
"[爱心]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq080.gif",
"[心碎]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq081.gif",
"[蛋糕]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq082.gif",
"[闪电]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq083.gif",
"[炸弹]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq084.gif",
"[刀]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq085.gif",
"[足球]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq086.gif",
"[瓢虫]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq087.gif",
"[便便]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq088.gif",
"[月亮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq089.gif",
"[太阳]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq090.gif",
"[礼物]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq091.gif",
"[抱抱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq092.gif",
"[喝彩]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq93.gif",
"[祈祷]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq94.gif",
"[棒棒糖]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq95.gif",
"[药]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq96.gif",
"[赞]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq097.gif",
"[差劲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq098.gif",
"[握手]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq099.gif",
"[胜利]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq100.gif",
"[抱拳]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq101.gif",
"[勾引]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq102.gif",
"[拳头]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq103.gif",
"[差劲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq104.gif",
"[爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq105.gif",
"[NO]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq106.gif",
"[OK]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq107.gif",
"[#呵呵]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_1.png",
"[#滑稽]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_10.png",
"[#吐舌]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_3.png",
"[#哈哈]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_2.png",
"[#啊]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_23.png",
"[#酷]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_22.png",
"[#怒]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_13.png",
"[#开心]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_39.png",
"[#汗]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_14.png",
"[#泪]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_16.png",
"[#黑线]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_15.png",
"[#鄙视]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_21.png",
"[#不高兴]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_12.png",
"[#真棒]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_17.png",
"[#钱]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_40.png",
"[#疑问]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_26.png",
"[#阴险]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_20.png",
"[#吐]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_34.png",
"[#咦]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_41.png",
"[#委屈]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_29.png",
"[#花心]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_6.png",
"[#呼~]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_42.png",
"[#激动]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_5.png",
"[#冷]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_43.png",
"[#可爱]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_4.png",
"[#What?]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_25.png",
"[#勉强]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_38.png",
"[#狂汗]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_24.png",
"[#酸爽]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_27.png",
"[#乖]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_8.png",
"[#雅美蝶]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_28.png",
"[#睡觉]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_31.png",
"[#惊哭]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_19.png",
"[#哼]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_44.png",
"[#笑尿]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_32.png",
"[#惊讶]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_30.png",
"[#小乖]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_7.png",
"[#喷]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_18.png",
"[#抠鼻]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_33.png",
"[#捂嘴笑]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_9.png",
"[#你懂的]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_11.png",
"[#犀利]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_35.png",
"[#小红脸]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_36.png",
"[#懒得理]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_37.png",
"[#爱心]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_45.png",
"[#心碎]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_46.png",
"[#玫瑰]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_47.png",
"[#礼物]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_48.png",
"[#彩虹]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_49.png",
"[#太阳]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_50.png",
"[#月亮]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_51.png",
"[#钱币]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_52.png",
"[#咖啡]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_53.png",
"[#蛋糕]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_54.png",
"[#大拇指]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_55.png",
"[#胜利]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_56.png",
"[#爱你]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_57.png",
"[#OK]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_58.png",
"[#弱]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_59.png",
"[#沙发]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_60.png",
"[#纸巾]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_61.png",
"[#香蕉]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_62.png",
"[#便便]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_63.png",
"[#药丸]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_64.png",
"[#红领巾]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_65.png",
"[#蜡烛]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_66.png",
"[#三道杠]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_67.png",
"[#音乐]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_68.png",
"[#灯泡]":
"https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_69.png",
"[doge]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/1.png",
"[doge思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/2.png",
"[doge再见]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/3.png",
"[doge生气]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/4.png",
"[doge气哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/5.png",
"[doge笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/7.png",
"[doge调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/6.png",
"[doge啊哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/8.png",
"[doge原谅TA]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/9.png",
"[miao]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/10.png",
"[miao思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/11.png",
"[miao拜拜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/12.png",
"[miao生气]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/13.png",
"[miao气哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/14.png",
"[二哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/15.png",
"[摊手]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/19.png",
"[w并不简单]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/20.png",
"[w滑稽]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/21.png",
"[w色]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/22.png",
"[w爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/23.png",
"[w拜拜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/24.png",
"[w悲伤]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/25.png",
"[w鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/26.png",
"[w馋嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/27.png",
"[w冷汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/28.png",
"[w打哈欠]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/29.png",
"[w打脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/30.png",
"[w敲打]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/31.png",
"[w生病]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/32.png",
"[w闭嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/33.png",
"[w鼓掌]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/34.png",
"[w哈哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/35.png",
"[w害羞]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/36.png",
"[w呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/37.png",
"[w黑线]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/38.png",
"[w哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/39.png",
"[w调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/40.png",
"[w可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/41.png",
"[w可怜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/42.png",
"[w酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/43.png",
"[w困]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/44.png",
"[w懒得理你]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/45.png",
"[w流泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/46.png",
"[w怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/47.png",
"[w怒骂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/48.png",
"[w钱]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/49.png",
"[w亲亲]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/50.png",
"[w傻眼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/51.png",
"[w便秘]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/52.png",
"[w失望]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/53.png",
"[w衰]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/54.png",
"[w睡觉]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/55.png",
"[w思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/56.png",
"[w开心]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/57.png",
"[w色舔]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/58.png",
"[w偷笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/59.png",
"[w吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/60.png",
"[w抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/61.png",
"[w委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/62.png",
"[w笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/63.png",
"[w嘻嘻]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/64.png",
"[w嘘]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/65.png",
"[w阴险]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/66.png",
"[w疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/67.png",
"[w抓狂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/70.png",
"[w晕]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/69.png",
"[w右哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/68.png",
"[w左哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/71.png",
"[w肥皂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/77.png",
"[w奥特曼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/78.png",
"[w草泥马]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/79.png",
"[w兔子]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/80.png",
"[w熊猫]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/81.png",
"[w猪头]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/82.png",
"[w→_→]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/83.png",
"[w给力]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/84.png",
"[w囧]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/85.png",
"[w萌]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/86.png",
"[w神马]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/87.png",
"[w威武]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/88.png",
};
function clickEvent(e) {
/* 预览按钮点击事件 */
if ($jq("#polldatas").length) {
/* 当前是投票帖子 */
replaceVote();
}
if (!$jq(this).find("i.comiis_font").hasClass("f_0")) {
$jq(".gm_plugin_previewpostforum_html").css("display", "block");
let replaecdText = replaceText($jq("#needmessage").val());
$jq(
".gm_plugin_previewpostforum_html .comiis_message_table"
)[0].innerHTML = replaecdText;
if (open_double) {
$jq(
".gm_plugin_previewpostforum_html.double-preview .comiis_over_box.comiis_input_style"
).css("height", $jq("#needmessage").css("height"));
}
} else {
$jq(".gm_plugin_previewpostforum_html").hide();
}
}
function replaceText(text) {
/* 替换内容 */
let attachimgmatch = text.match(
/\[attachimg\]([\s\S]+?)\[\/attachimg\]/g
);
if (attachimgmatch) {
attachimgmatch.forEach((item) => {
let aimgidMatch = item.match(
/\[attachimg\]([\s\S]+?)\[\/attachimg\]/
);
let aimg_id = aimgidMatch
? aimgidMatch[aimgidMatch.length - 1]
: "";
let imgtitle = $jq(`#aimg_${aimg_id}`).attr("title");
let imgsrc = $jq(`#aimg_${aimg_id}`).attr("src");
if (!imgsrc) {
imgtitle = "该图片不存在";
}
text = text.replace(
item,
`

`
);
});
}
let code = text.match(/\[code\]([\s\S]*?)\[\/code\]/g);
if (code) {
code.forEach((item) => {
let match_content = item.match(/\[code\]([\s\S]*?)\[\/code\]/);
let contentAll = match_content
? match_content[match_content.length - 1]
: "";
let content = "";
let brSplit = contentAll.split("\n");
if (brSplit.length == 1) {
content = `
${contentAll}`;
} else {
Array.from(brSplit).forEach((item, index) => {
if (index == brSplit.length - 1) {
content = `${content}
${item}`;
} else {
content = `${content}
${item}
`;
}
});
}
text = text.replace(
item,
`
`
);
});
}
let url = text.match(/\[url\=[\s\S]*?\]([\s\S]*?)\[\/url\]/g);
if (url) {
url.forEach((item) => {
let urlMatch = item.match(/\[url=([\s\S]*?)\][\s\S]*\[\/url\]/);
let urlNameMatch = item.match(
/\[url=[\s\S]*?\]([\s\S]*?)\[\/url\]/
);
let _url_ = urlMatch ? urlMatch[urlMatch.length - 1] : "";
let _url_name_ = urlNameMatch
? urlNameMatch[urlNameMatch.length - 1]
: "";
text = text.replace(
item,
`
${_url_name_}`
);
});
}
let color = text.match(/\[color\=[\s\S]*?\]([\s\S]*?)\[\/color\]/g);
if (color) {
color.forEach((item) => {
let colorValueMatch = item.match(
/\[color=([\s\S]*?)\][\s\S]*\[\/color\]/
);
let colorTextMatch = item.match(
/\[color=[\s\S]*?\]([\s\S]*?)\[\/color\]/
);
let colorValue = colorValueMatch
? colorValueMatch[colorValueMatch.length - 1]
: "";
let colorText = colorTextMatch
? colorTextMatch[colorTextMatch.length - 1]
: "";
text = text.replace(
item,
`
${colorText}`
);
});
}
let size = text.match(/\[size\=[\s\S]*?\]([\s\S]*?)\[\/size\]/g);
if (size) {
console.log(size);
size.forEach((item) => {
let sizeValueMatch = item.match(
/\[size=([\s\S]*?)\][\s\S]*\[\/size\]/
);
let sizeTextMatch = item.match(
/\[size=[\s\S]*?\]([\s\S]*?)\[\/size\]/
);
let sizeValue = sizeValueMatch
? sizeValueMatch[sizeValueMatch.length - 1]
: "";
let sizeText = sizeTextMatch
? sizeTextMatch[sizeTextMatch.length - 1]
: "";
text = text.replace(
item,
`
${sizeText}`
);
});
}
let img = text.match(/\[img(|\=[\s\S]+?)\]([\s\S]*?)\[\/img\]/g);
if (img) {
img.forEach((item) => {
let widthInfo = null;
let heightInfo = null;
let img_size_match = item.match(
/\[img\=([\s\S]+?)\][\s\S]*?\[\/img\]/
);
if (img_size_match) {
img_size_match =
img_size_match[img_size_match.length - 1].split(",");
widthInfo = img_size_match[0];
heightInfo = img_size_match[1];
}
widthInfo = widthInfo ? widthInfo : "";
heightInfo = heightInfo ? heightInfo : "";
let match_content = item.match(
/\[img\]([\s\S]*?)\[\/img\]|\[img=[\s\S]*?\]([\s\S]*?)\[\/img\]/
);
let content = "";
if (match_content) {
if (match_content[match_content.length - 1] == null) {
content = match_content[match_content.length - 2];
} else {
content = match_content[match_content.length - 1];
}
}
text = text.replace(
item,
`

`
);
});
}
let hide = text.match(/\[hide\]([\s\S]*?)\[\/hide\]/g);
if (hide) {
hide.forEach((item) => {
let match_content = item.match(/\[hide\]([\s\S]*?)\[\/hide\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(
item,
`
本帖隐藏的内容:
${content}`
);
});
}
let hide2 = text.match(/\[hide=[\s\S]*?\]([\s\S]*?)\[\/hide\]/g);
if (hide2) {
hide2.forEach((item) => {
let match_content = item.match(
/\[hide=([\s\S]*?)\]([\s\S]*?)\[\/hide\]/
);
let other_info = match_content
? match_content[match_content.length - 2]
: "";
other_info = other_info.split(",");
let integral_big_can_see =
other_info.length == 2 ? other_info[1] : "";
text = text.replace(
item,
`
以下内容需要积分高于 ${integral_big_can_see} 才可浏览
`
);
});
}
let quote = text.match(/\[quote\]([\s\S]*?)\[\/quote\]/g);
if (quote) {
quote.forEach((item) => {
let match_content = item.match(/\[quote\]([\s\S]*?)\[\/quote\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(
item,
`
`
);
});
}
let free = text.match(/\[free\]([\s\S]*?)\[\/free\]/g);
if (free) {
free.forEach((item) => {
let match_content = item.match(/\[free\]([\s\S]*?)\[\/free\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(
item,
`
`
);
});
}
let strong = text.match(/\[b\]([\s\S]*?)\[\/b\]/g);
if (strong) {
strong.forEach((item) => {
let match_content = item.match(/\[b\]([\s\S]*?)\[\/b\]/i);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(item, `
${content}`);
});
}
let xhx = text.match(/\[u\]([\s\S]*?)\[\/u\]/g);
if (xhx) {
xhx.forEach((item) => {
let match_content = item.match(/\[u\]([\s\S]*?)\[\/u\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(item, `
${content}`);
});
}
let qx = text.match(/\[i\]([\s\S]*?)\[\/i\]/g);
if (qx) {
qx.forEach((item) => {
let match_content = item.match(/\[i\]([\s\S]*?)\[\/i\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(item, `
${content}`);
});
}
let strike = text.match(/\[s\]([\s\S]*?)\[\/s\]/g);
if (strike) {
strike.forEach((item) => {
let match_content = item.match(/\[s\]([\s\S]*?)\[\/s\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(item, `
${content}`);
});
}
let smilies = text.match(/\[([\s\S]+?)\]/g);
if (smilies) {
smilies.forEach((item) => {
console.log(item);
let smiliesMatchSrc = smiliesDictionaries[item];
if (smiliesMatchSrc) {
text = text.replace(
item,
`

`
);
}
});
}
let media = text.match(/\[media=[\s\S]+?\][\s\S]+?\[\/media\]/g);
if (media) {
media.forEach((item) => {
console.log(item);
let match_content = item.match(
/\[media=[\s\S]*?\]([\s\S]*?)\[\/media\]/
);
let content = match_content
? match_content[match_content.length - 1]
: "";
if (content) {
text = text.replace(
item,
`
`
);
}
});
}
let email = text.match(/\[email=[\s\S]+?\][\s\S]+?\[\/email\]/g);
if (email) {
email.forEach((item) => {
console.log(item);
let email_match = item.match(
/\[email=([\s\S]*?)\][\s\S]*?\[\/email\]/
);
let content_match = item.match(
/\[email=[\s\S]*?\]([\s\S]*?)\[\/email\]/
);
let _email_ = email_match.length
? email_match[email_match.length - 1]
: "";
let _content_ = content_match.length
? content_match[content_match.length - 1]
: "";
if (_email_ || _content_) {
text = text.replace(
item,
`
${_content_}`
);
}
});
}
let align = text.match(/\[align=[\s\S]+?\][\s\S]+?\[\/align\]/g);
if (align) {
align.forEach((item) => {
console.log(item);
let align_match = item.match(
/\[align=([\s\S]*?)\][\s\S]+?\[\/align\]/
);
let content_match = item.match(
/\[align=[\s\S]*?\]([\s\S]+?)\[\/align\]/
);
let _align_ = align_match.length
? align_match[align_match.length - 1]
: "";
let _content_ = content_match.length
? content_match[content_match.length - 1]
: "";
if (_align_ || _content_) {
text = text.replace(
item,
`
${_content_}
`
);
}
});
}
let qq = text.match(/\[qq\][\s\S]*?\[\/qq\]/g);
if (qq) {
qq.forEach((item) => {
console.log(item);
let match_content = item.match(/\[qq\]([\s\S]*?)\[\/qq\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
/* 这个是以前的wpa协议,现在是tencent协议,mt的discuz没有更新,如:tencent://message/?uin=xxx&site=bbs.binmt.cc&menu=yes */
text = text.replace(
item,
`

`
);
});
}
let td = text.match(/\[td\][\s\S]+?\[\/td\]/g);
if (td) {
td.forEach((item) => {
console.log(item);
let match_content = item.match(/\[td\]([\s\S]*?)\[\/td\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(item, `
${content} | `);
});
}
let tr = text.match(/\[tr\][\s\S]+?\[\/tr\]/g);
if (tr) {
tr.forEach((item) => {
console.log(item);
let match_content = item.match(/\[tr\]([\s\S]*?)\[\/tr\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
text = text.replace(item, `
${content}
`);
});
}
let table = text.match(/\[table\][\s\S]+?\[\/table\]/g);
if (table) {
table.forEach((item) => {
console.log(item);
let match_content = item.match(/\[table\]([\s\S]*?)\[\/table\]/);
let content = match_content
? match_content[match_content.length - 1]
: "";
content = content.replace(/\n/g, "");
text = text.replace(item, `
`);
});
}
let list = text.match(/\[list=[\s\S]+?\][\s\S]+?\[\/list\]/g);
if (list) {
list.forEach((item) => {
console.log(item);
let list_model_match = item.match(
/\[list=([\s\S]*?)\][\s\S]*?\[\/list\]/
);
let list_content_match = item.match(
/\[list=[\s\S]*?\]([\s\S]*?)\[\/list\]/
);
let list_model = list_model_match
? list_model_match[list_model_match.length - 1]
: "";
let list_type = "";
if (list_model === "a") {
list_type = "litype_2";
} else if (list_model === "A") {
list_type = "litype_3";
} else if (
list_model.length === 1 &&
list_model.match(/[0-9]{1}/)
) {
list_type = "litype_1";
}
let content = list_content_match
? list_content_match[list_content_match.length - 1]
: "";
let li_split = content.split("[*]");
if (li_split.length > 1) {
let newContent = "";
if (li_split[0].replace(/[\s]*/, "") == "") {
li_split = li_split.slice(1);
}
Array.from(li_split).forEach((item) => {
newContent = `${newContent}
${item}`;
});
content = newContent;
}
content = content.replace(/\n/g, "");
text = text.replace(
item,
`
`
);
});
}
$jq(
".gm_plugin_previewpostforum_html .comiis_quote.comiis_qianglou"
).remove();
let password = text.match(/\[password\](.*?)\[\/password\]/gi);
if (password) {
password.forEach((item) => {
console.log(item);
text = item.replace(/\[password\](.*?)\[\/password\]/gi, "");
$jq(
".gm_plugin_previewpostforum_html .comiis_message_table"
).before(
$jq(`
付费主题, 价格:
${$jq(
"#price"
).val()} 金币
记录 `)
);
});
}
let every_reward = parseInt($jq("#replycredit_extcredits").val());
let total_reward = parseInt($jq("#replycredit_times").val());
let getreward_menbertimes = parseInt(
$jq("#replycredit_membertimes").val()
);
let getreward_random = parseInt($jq("#replycredit_random").val());
$jq(".gm_plugin_previewpostforum_html .comiis_htjl").remove();
if (
!isNaN(every_reward) &&
!isNaN(total_reward) &&
every_reward > 0 &&
total_reward > 0
) {
$jq(".gm_plugin_previewpostforum_html .comiis_message_table").before(
$jq(`
总共奖励 ${total_reward} 金币
回复本帖可获得 ${every_reward} 金币奖励! 每人限 ${getreward_menbertimes} 次 ${
getreward_random != 100 ? `(中奖概率 ${getreward_random}%)` : ""
}
`)
);
}
text = text.replace(/\[hr\]/g, '
');
text = text.replace(/\[\*\]/g, "
");
text = text.replace(/\n/g, "
");
return text;
}
function replaceVote() {
/* 替换预览投票 */
let chooseColor = [
"rgb(233, 39, 37)",
"rgb(242, 123, 33)",
"rgb(242, 166, 31)",
"rgb(90, 175, 74)",
"rgb(66, 196, 245)",
"rgb(0, 153, 204)",
"rgb(51, 101, 174)",
"rgb(42, 53, 145)",
"rgb(89, 45, 142)",
"rgb(219, 49, 145)",
"rgb(233, 39, 37)",
"rgb(242, 123, 33)",
"rgb(242, 166, 31)",
"rgb(90, 175, 74)",
"rgb(66, 196, 245)",
"rgb(0, 153, 204)",
"rgb(51, 101, 174)",
"rgb(42, 53, 145)",
"rgb(89, 45, 142)",
"rgb(219, 49, 145)",
]; /* 选择的背景 */
let chooseContent = $jq(
".comiis_polloption_add ul li:first-child div.flex .comiis_input.kmshow[type='text']"
); /* 选项,最多20个 */
let maxchoices = parseInt($jq("input#maxchoices").val()); /* 最多可选 */
maxchoices = isNaN(maxchoices) ? 0 : maxchoices;
maxchoices = maxchoices > 0 ? maxchoices : 0;
maxchoices =
maxchoices > chooseContent.length
? chooseContent.length
: maxchoices; /* 大于当前选项数量的话为当前最大选项数量 */
let polldatas = parseInt($jq("input#polldatas").val()); /* 记票天数 */
polldatas = isNaN(polldatas) ? 0 : polldatas;
let visibilitypoll = $jq("input#visibilitypoll")
.parent()
.find(".comiis_checkbox")
.hasClass("comiis_checkbox_close")
? false
: true; /* 投票后结果可见 */
let overt = $jq("input#overt")
.parent()
.find(".comiis_checkbox")
.hasClass("comiis_checkbox_close")
? false
: true; /* 公开投票参与人 */
let html = "";
let choosehtml = "";
console.log(chooseContent);
chooseContent.each((i, v) => {
if (i >= 20) {
/* 最多20个 */
return;
}
choosehtml =
choosehtml +
`
0% (0)
`;
});
html = `
${
maxchoices > 1
? "多选投票" +
' 最多可选 ' +
maxchoices +
" 项"
: "单选投票"
}
共有 0 人参与投票
${
polldatas > 0
? `
距结束还有:
${
polldatas > 1
? '' +
(polldatas - 1) +
" 天 "
: ""
}23 小时 59 分钟
`
: ""
}
${
overt
? '
此为公开投票,其他人可看到您的投票项目
'
: ""
}
`;
$jq(".gm_plugin_previewpostforum_html .postforum_vote").remove();
$jq(
".gm_plugin_previewpostforum_html .comiis_messages.comiis_aimg_show"
)
.children()
.eq(0)
.before($jq(html));
}
function keyUpEvent(e) {
/* 内容输入事件 */
let userInputText = e.target.value;
let replaecdText = replaceText(userInputText);
$jq(
".gm_plugin_previewpostforum_html .comiis_message_table"
)[0].innerHTML = replaecdText;
}
if (typeof unsafeWindow.comiis_addsmilies == "function") {
/* 替换全局函数添加图片到里面触发input */
unsafeWindow.comiis_addsmilies = (_str_) => {
unsafeWindow.$("#needmessage").comiis_insert(_str_);
unsafeWindow.$("#needmessage")[0].dispatchEvent(new Event("input"));
};
}
addMenu_doubleColumnPreview();
addMenu_preview();
addMenu_immersiveInput();
if (open_double) {
/* box-shadow: -1px 0px 8px; */
$jq("#needmessage").parent().css("display", "flex");
$jq("#needmessage").after(
$jq(`
`)
);
} else {
$jq("#comiis_post_tab").append(
$jq(`
`)
);
}
$jq("#needmessage").on("propertychange input", keyUpEvent);
$jq(".gm_plugin_previewpostforum").on("click", clickEvent);
},
/**
* 编辑器中的ubb代码
*/
quickUBB: {
code: {
rainbow1: {
key: "转普通彩虹",
value: "",
isFunc: true,
num: 1,
},
rainbow2: {
key: "转黑白彩虹",
value: "",
isFunc: true,
num: 2,
},
rainbow3: {
key: "转黑红彩虹",
value: "",
isFunc: true,
num: 3,
},
rainbow4: {
key: "转蓝绿彩虹",
value: "",
isFunc: true,
num: 4,
},
size: {
key: "size",
value: "[size=][/size]",
tagL: "=",
tagR: "]",
L: "[size=]",
R: "[/size]",
cursorL: "[size=",
cursorLength: 6,
quickUBBReplace: "[size=14]replace[/size]",
},
color: {
key: "color",
value: "[color=][/color]",
tagL: "=",
tagR: "]",
L: "[color=]",
R: "[/color]",
cursorL: "[color=",
cursorLength: 7,
quickUBBReplace: "[color=#000]replace[/color]",
},
b: {
key: "加粗",
value: "[b][/b]",
tagL: "]",
tagR: "[",
L: "[b]",
R: "[/b]",
cursorR: "[/b]",
cursorLength: 4,
quickUBBReplace: "[b]replace[/b]",
},
u: {
key: "下划线",
value: "[u][/u]",
tagL: "]",
tagR: "[",
L: "[u]",
R: "[/u]",
cursorR: "[/u]",
cursorLength: 4,
quickUBBReplace: "[u]replace[/u]",
},
i: {
key: "倾斜",
value: "[i][/i]",
tagL: "]",
tagR: "[",
L: "[i]",
R: "[/i]",
cursorR: "[/i]",
cursorLength: 4,
quickUBBReplace: "[i]replace[/i]",
},
s: {
key: "中划线",
value: "[s][/s]",
tagL: "]",
tagR: "[",
L: "[s]",
R: "[/s]",
cursorR: "[/s]",
cursorLength: 4,
quickUBBReplace: "[s]replace[/s]",
},
lineFeed: {
key: "换行",
value: "[*]",
L: "",
R: "[*]",
cursorL: "[*]",
cursorLength: 3,
quickUBBReplace: "replace[*]",
},
longHorizontalLine: {
key: "水平线",
value: "[hr]",
L: "",
R: "[hr]",
cursorL: "[hr]",
cursorLength: 4,
quickUBBReplace: "replace[hr]",
},
link: {
key: "链接",
value: "[url=][/url]",
tagL: "=",
tagR: "]",
L: "[url=]",
R: "[/url]",
cursorL: "[url=",
cursorLength: 5,
quickUBBReplace: "[url=replace]replace[/url]",
},
hide: {
key: "隐藏",
value: "[hide]\n[/hide]",
tagL: "]",
tagR: "[",
L: "[hide]",
R: "[/hide]",
cursorR: "[/hide]",
cursorLength: 7,
quickUBBReplace: "[hide]replace\n[/hide]",
},
quote: {
key: "引用",
value: "[quote][/quote]",
tagL: "]",
tagR: "[",
L: "[quote]",
R: "[/quote]",
cursorR: "[/quote]",
cursorLength: 8,
quickUBBReplace: "[quote]replace[/quote]",
},
email: {
key: "邮件",
value: "[email=][/email]",
tagL: "=",
tagR: "]",
L: "[email=]",
R: "[/email]",
cursorL: "[email=",
cursorLength: 7,
quickUBBReplace: "[email=replace]replace[/email]",
},
},
insertQuickReplyUBB: () => {
/* 快捷回复 */
$jq.each(mobile.quickUBB.code, function (index, value) {
let ubbs = $jq(
`
${value["key"]}`
);
ubbs.on("click", function () {
$jq(
"#comiis_insert_ubb_tab div.comiis_post_urlico ul li.quickUBBs a.comiis_xifont"
)
.removeClass("f_0")
.addClass("f_d");
$jq(this).find(".comiis_xifont").removeClass("f_d").addClass("f_0");
popup2.confirm({
text: `
`,
mask: true,
only: true,
ok: {
callback: () => {
let userInput = $jq(".quickinsertbbsdialog").val();
if (userInput.trim() == "") {
popup2.toast({
text: "输入框不能为空或纯空格",
});
return;
}
if (value["isFunc"]) {
comiis_addsmilies(
mobile.quickUBB.set_rainbow(value["num"], userInput)
); /* 插入贴内 */
} else if (value["quickUBBReplace"]) {
comiis_addsmilies(
value["quickUBBReplace"].replaceAll("replace", userInput)
); /* 插入贴内 */
} else {
comiis_addsmilies(userInput); /* 插入贴内 */
}
popup2.closeConfirm();
},
},
});
});
$jq("#comiis_insert_ubb_tab div.comiis_post_urlico ul").append(
ubbs[0]
);
});
},
insertReplayUBB: () => {
/* 具体回复 */
let insertDOM = $jq(".comiis_post_urlico");
if (!insertDOM) {
console.log("未找到插入元素");
return;
}
GM_addStyle(`
#comiis_post_tab .comiis_input_style .comiis_post_urlico li a.f_0{
color: #53bcf5 !important;
}
`);
let parentEle = $jq(".comiis_post_urlico > ul")[0];
let contentEle = $jq("#comiis_post_qydiv > ul");
let childNums = $jq("#comiis_post_qydiv ul li").length;
mobile.quickUBB.jqueryExtraFunction();
$jq("#comiis_post_tab .comiis_input_style .comiis_post_urlico li").on(
"click",
function () {
$jq(
"#comiis_post_tab .comiis_input_style .comiis_post_urlico li a"
).removeClass("f_0");
$jq(
"#comiis_post_tab .comiis_input_style .comiis_post_urlico li a"
).addClass("f_d");
$jq(this).find("a").attr("class", "comiis_xifont f_0");
$jq("#comiis_post_qydiv ul li")
.hide()
.eq($jq(this).index())
.fadeIn();
}
);
$jq.each(mobile.quickUBB.code, function (key, value) {
let ubbs = $jq(
`
${value["key"]}`
);
ubbs.on("click", (e) => {
let bottomEle = $jq(
`#comiis_post_qydiv li[data-key='${value.key}']`
);
if (!bottomEle.length) {
console.log("未找到该元素");
return;
}
let contentIndex =
childNums + Object.keys(mobile.quickUBB.code).indexOf(key);
console.log(contentIndex);
$jq("#comiis_post_qydiv ul li").hide().eq(contentIndex).fadeIn();
$jq.each(
$jq(
"#comiis_post_tab div.comiis_post_urlico ul li a.comiis_xifont"
),
(i, v) => {
v.className = "comiis_xifont f_d";
if (v == e.target) {
v.className = "comiis_xifont f_0";
}
}
);
});
parentEle.append(ubbs[0]);
let ubbs_content = document.createElement("li");
ubbs_content.setAttribute("style", "display: none;");
ubbs_content.setAttribute("data-key", value["key"]);
ubbs_content.innerHTML = `
`;
contentEle.append(ubbs_content);
$jq(`.comiis_sendbtn[data-keyI="${key}"]`).on("click", () => {
let text = $jq(`#comiis_input_${key}`).val();
if (text == "") {
popup2.toast("请输入需要插入的内容");
return;
}
if (mobile.quickUBB.code[key]["isFunc"]) {
text = mobile.quickUBB.set_rainbow(
mobile.quickUBB.code[key]["num"],
text
);
}
if (mobile.quickUBB.code[key].hasOwnProperty("L")) {
text =
mobile.quickUBB.code[key]["L"] +
text +
mobile.quickUBB.code[key]["R"];
}
$jq("#needmessage").insertAtCaret(text);
/*
if (mobile.quickUBB.code[key]["tagL"] != undefined || mobile.quickUBB.code[key]["tagR"] != undefined) {
$jq("#needmessage").moveCursorInCenterByText(mobile.quickUBB.code[key]["tagL"], mobile.quickUBB.code[key]["tagR"]);
}*/
if (mobile.quickUBB.code[key].hasOwnProperty("cursorL")) {
$jq("#needmessage").moveCursorToCenterByTextWithLeft(
mobile.quickUBB.code[key]["cursorL"],
mobile.quickUBB.code[key]["cursorLength"]
);
}
if (mobile.quickUBB.code[key].hasOwnProperty("cursorR")) {
$jq("#needmessage").moveCursorToCenterByTextWithRight(
mobile.quickUBB.code[key]["cursorR"],
mobile.quickUBB.code[key]["cursorLength"]
);
}
});
});
},
set_rainbow: (num, text) => {
if (text == "") {
return "";
}
var wr_text = text;
var wr_code, wr_rgb, r, g, b, i, j, istep;
var wr_rgb1, wr_rgb2, r1, g1, b1, r2, g2, b2;
r1 = g1 = b1 = r2 = g2 = b2 = 0;
r = 0;
g = 0;
b = 0;
istep = 0;
wr_code = "";
if (num == 1) {
istep = 40;
r = 255;
i = 1;
j = 0;
do {
if (wr_text.charCodeAt(j) != 32) {
if (g + istep < 256) {
if (i == 1) g += istep;
} else if (i == 1) {
i = 2;
g = 255;
}
if (r - istep > -1) {
if (i == 2) r -= istep;
} else if (i == 2) {
i = 3;
r = 0;
}
if (b + istep < 256) {
if (i == 3) b += istep;
} else if (i == 3) {
i = 4;
b = 255;
}
if (g - istep > -1) {
if (i == 4) g -= istep;
} else if (i == 4) {
i = 5;
g = 0;
}
if (r + istep < 256) {
if (i == 5) r += istep;
} else if (i == 5) {
i = 6;
r = 255;
}
if (b - istep > -1) {
if (i == 6) b -= istep;
} else if (i == 6) {
i = 1;
b = 0;
}
wr_rgb = "";
wr_rgb +=
parseInt(r).toString(16).length == 1
? 0 + parseInt(r).toString(16)
: parseInt(r).toString(16);
wr_rgb +=
parseInt(g).toString(16).length == 1
? 0 + parseInt(g).toString(16)
: parseInt(g).toString(16);
wr_rgb +=
parseInt(b).toString(16).length == 1
? 0 + parseInt(b).toString(16)
: parseInt(b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += `[color=#${wr_rgb}]${wr_text.charAt(j)}[/color]`;
} else {
wr_code += wr_text.charAt(j);
}
j++;
} while (j < wr_text.length);
} else if (num == 2) {
istep = 255 / wr_text.length;
for (i = 1; i < wr_text.length + 1; i++) {
if (wr_text.charCodeAt(i - 1) != 32) {
r += istep;
g += istep;
b += istep;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
wr_rgb = "";
wr_rgb +=
parseInt(r).toString(16).length == 1
? 0 + parseInt(r).toString(16)
: parseInt(r).toString(16);
wr_rgb +=
parseInt(g).toString(16).length == 1
? 0 + parseInt(g).toString(16)
: parseInt(g).toString(16);
wr_rgb +=
parseInt(b).toString(16).length == 1
? 0 + parseInt(b).toString(16)
: parseInt(b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += `"[color=#${wr_rgb}]${wr_text.charAt(i - 1)}[/color]`;
} else {
wr_code += wr_text.charAt(i - 1);
}
}
} else if (num == 3) {
istep = 255 / wr_text.length;
for (i = 1; i < wr_text.length + 1; i++) {
if (wr_text.charCodeAt(i - 1) != 32) {
r += istep;
g = 29;
b = 36;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
wr_rgb = "";
wr_rgb +=
parseInt(r).toString(16).length == 1
? 0 + parseInt(r).toString(16)
: parseInt(r).toString(16);
wr_rgb +=
parseInt(g).toString(16).length == 1
? 0 + parseInt(g).toString(16)
: parseInt(g).toString(16);
wr_rgb +=
parseInt(b).toString(16).length == 1
? 0 + parseInt(b).toString(16)
: parseInt(b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += `[color=#${wr_rgb}]${wr_text.charAt(i - 1)}[/color]`;
} else {
wr_code += wr_text.charAt(i - 1);
}
}
} else if (num == 4) {
istep = 255 / wr_text.length;
for (i = 1; i < wr_text.length + 1; i++) {
if (wr_text.charCodeAt(i - 1) != 32) {
r = 0;
g = 174;
b += istep;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
wr_rgb = "";
wr_rgb +=
parseInt(r).toString(16).length == 1
? 0 + parseInt(r).toString(16)
: parseInt(r).toString(16);
wr_rgb +=
parseInt(g).toString(16).length == 1
? 0 + parseInt(g).toString(16)
: parseInt(g).toString(16);
wr_rgb +=
parseInt(255 - b).toString(16).length == 1
? 0 + parseInt(255 - b).toString(16)
: parseInt(255 - b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += `[color=#${wr_rgb}]${wr_text.charAt(i - 1)}[/color]`;
} else {
wr_code += wr_text.charAt(i - 1);
}
}
}
return wr_code;
},
jqueryExtraFunction: () => {
$jq.fn.extend({
insertAtCaret: function (myValue) {
var $t = $jq(this)[0];
if (document.selection) {
this.focus();
var sel = document.selection.createRange();
sel.text = myValue;
this.focus();
} else if ($t.selectionStart || $t.selectionStart == "0") {
var startPos = $t.selectionStart;
var endPos = $t.selectionEnd;
var scrollTop = $t.scrollTop;
$t.value =
$t.value.substring(0, startPos) +
myValue +
$t.value.substring(endPos, $t.value.length);
this.focus();
$t.selectionStart = startPos + myValue.length;
$t.selectionEnd = startPos + myValue.length;
$t.scrollTop = scrollTop;
} else {
this.value += myValue;
this.focus();
}
},
selectRange: function (start, end) {
if (end === undefined) {
end = start;
}
return this.each(function () {
if ("selectionStart" in this) {
this.selectionStart = start;
this.selectionEnd = end;
} else if (this.setSelectionRange) {
this.setSelectionRange(start, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd("character", end);
range.moveStart("character", start);
range.select();
}
});
},
getCursorPosition: function () {
var el = $jq(this)[0];
var pos = 0;
if ("selectionStart" in el) {
pos = el.selectionStart;
} else if ("selection" in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
Sel.moveStart("character", -el.value.length);
pos = Sel.text.length - SelLength;
}
return pos;
},
moveCursorInCenterByText: function (leftTextFlag, rightTextFlag) {
var el = $jq(this)[0];
var el_text = el.value;
for (let i = el.selectionStart - 1; i > 0; i--) {
let LText = el_text[i - 1];
let currentText = el_text[i];
if (LText == leftTextFlag && currentText == rightTextFlag) {
this.selectRange(i);
break;
}
}
},
moveCursorToCenterByTextWithLeft: function (leftMatchText, _length_) {
var el = $jq(this)[0];
var el_text = el.value;
for (let i = el.selectionStart - 1; i > 0; i--) {
let lTexts = el_text.substring(i - _length_, i);
if (lTexts == leftMatchText) {
this.selectRange(i);
break;
}
}
},
moveCursorToCenterByTextWithRight: function (
rightMatchText,
_length_
) {
var el = $jq(this)[0];
var el_text = el.value;
for (let i = el.selectionStart - 1; i > 0; i--) {
let rTexts = el_text.substring(i, i + _length_);
if (rTexts == rightMatchText) {
this.selectRange(i + _length_);
break;
}
}
},
});
},
},
/**
* 修复图片宽度
*/
recoveryIMGWidth() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.forumPost], "v16")) {
return;
}
GM_addStyle(`
.comiis_messages img{
max-width: 100% !important;
}
`);
},
/**
* 移除帖子内的字体style
*/
removeForumPostFontStyle() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.forumPost], "v1")) {
return;
}
if ($jq(".comiis_a.comiis_message_table").eq(0).html()) {
$jq(".comiis_a.comiis_message_table")
.eq(0)
.html(
$jq(".comiis_a.comiis_message_table")
.eq(0)
.html()
.replace(MT_CONFIG.urlRegexp.fontSpecial, "")
);
}
},
/**
* 修复搜索的清空按钮
*/
repairClearSearchInput() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.searchUrl], "v36")) {
return;
}
let $search_input = $jq(".ssclose.bg_e.f_e");
if ($search_input) {
$search_input.click(function (e) {
e.preventDefault();
$jq("#scform_srchtxt").val("");
});
} else {
console.log("搜索界面: 获取清空按钮失败");
}
},
/**
* 修复评论区打赏评论因为文字或打赏人数评论太多导致高度显示不出来问题
*/
repairRecommendRewardHeight() {
if (window.location.href.match(MT_CONFIG.urlRegexp.forumPost)) {
GM_addStyle(`
.comiis_view_lcrate li p{
height: auto !important;
}
`);
}
},
/**
* 修复无法正确进入别人的空间
*/
repairUnableToEnterOtherSpaceCorrectly() {
if (!GM_getValue("v37")) {
return;
}
if (window.location.href.match(MT_CONFIG.urlRegexp.homeUrlBrief)) {
let href_params = window.location.href.match(/home.php\?(.+)/gi);
href_params = href_params[href_params.length - 1];
let params_split = href_params.split("&");
if (
params_split.length == 2 &&
href_params.indexOf("uid=") != -1 &&
href_params.indexOf("mod=space") != -1
) {
window.location.href = window.location.href + "&do=profile";
}
}
if (window.location.href.match(MT_CONFIG.urlRegexp.homeUrlWithAt)) {
let href_params = window.location.href.match(/space-uid-(.+).html/i);
href_params = href_params[href_params.length - 1];
window.location.href = `https://bbs.binmt.cc/home.php?mod=space&uid=${href_params}&do=profile`;
}
},
/**
* 搜索历史
*/
async searchHistory() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.searchUrl], "v19")) {
return;
}
class searchSelect {
constructor(config) {
this.parentDOM = config.parentDOM ? config.parentDOM : null;
this.list = this.arrayDistinct(
config.list ? config.list : []
); /* 用于搜索的数组 */
this.showList = this.list.length
? this.list
: []; /* 用于显示在界面上的数组 */
this.inputValueChangeEvent = config.inputValueChangeEvent
? config.inputValueChangeEvent
: () => {
return [];
};
this.css = {
falInDuration: config?.css?.falInDuration
? config?.css?.falInDuration
: 0.5,
falInTiming: config?.css?.falInTiming
? config?.css?.falInTiming
: "linear",
falOutDuration: config?.css?.falOutDuration
? config?.css?.falOutDuration
: 0.5,
falOutTiming: config?.css?.falOutTiming
? config?.css?.falOutTiming
: "linear",
PaddingTop: config?.css?.PaddingTop
? config?.css?.PaddingTop
: 8 /* 选择框距离输入框距离 */,
};
this.searchSelectClassName = config.searchSelectClassName
? config.searchSelectClassName
: "WhiteSevsSearchSelect"; /* 可修改div */
this.searchSelectHintClassName = config.searchSelectHintClassName
? config.searchSelectHintClassName
: "whiteSevSearchHint"; /* 可修改ul */
this.searchSelectHTMLNoData = config.searchSelectHTMLNoData
? `
${config.searchSelectHTMLNoData}`
: '
暂无其它数据';
this.searchSelectHTML = `
${this.searchSelectHTMLNoData}
`;
this.searchSelectDeleteItemHTML = `
`;
this.searchSelectDeleteItemClicked = false;
this.searchSelectCss = ``;
if (
document.querySelector(`.${this.searchSelectClassName}`) == null
) {
document.body.appendChild(
this.parseTextToDOM(this.searchSelectHTML)
);
document.body.appendChild(
this.parseTextToDOM(this.searchSelectCss)
);
}
this.setParentEvent();
this.setItemEvent();
if (this.showList.length !== 0) {
this.update(this.showList);
}
}
parseTextToDOM(arg) {
arg = arg
.replace(/^[\n|\s]*/g, "")
.replace(/[\n|\s]*$/g, ""); /* 去除前后的换行和空格 */
var objE = document.createElement("div");
objE.innerHTML = arg;
var result =
objE.children.length == 1 ? objE.children[0] : objE.children;
return result;
}
addSearching() {
document
.querySelector(`ul.${this.searchSelectHintClassName}`)
.appendChild(
this.parseTextToDOM(`
正在搜索中...`)
);
}
removeSearching() {
document
.querySelector(`ul.${this.searchSelectHintClassName} .searching`)
?.remove();
}
update(data) {
/* 更新页面显示的搜索结果 */
if (!(data instanceof Array)) {
console.log(data);
throw "传入的数据不是数组";
}
this.showList = this.arrayDistinct(data);
document
.querySelectorAll(`ul.${this.searchSelectHintClassName} li`)
.forEach((item) => {
item?.remove();
});
let that = this;
var parentUlDOM = document.querySelector(
`ul.${this.searchSelectHintClassName}`
);
if (this.showList.length === 0) {
this.clear();
if (this.parentDOM.value === "") {
document
.querySelectorAll(`ul.${this.searchSelectHintClassName} li`)
.forEach((item) => {
item?.remove();
});
this.list.forEach((item, index) => {
parentUlDOM.appendChild(
this.parseTextToDOM(
`
${item}${that.searchSelectDeleteItemHTML}`
)
);
});
this.setItemEvent();
} else {
this.parentDOM.dispatchEvent(new Event("focus"));
}
} else {
this.showList.forEach((item, index) => {
parentUlDOM.appendChild(
this.parseTextToDOM(
`
${item}${that.searchSelectDeleteItemHTML}`
)
);
});
this.setItemEvent();
}
}
arrayDistinct(data) {
/* 数组去重 */
var result = [];
data = new Set(data);
for (let item of data.values()) {
result = [item, ...result];
}
return result;
}
clear() {
this.showList = [];
document
.querySelectorAll(`ul.${this.searchSelectHintClassName} li`)
.forEach((item) => {
item?.remove();
});
document
.querySelector(`ul.${this.searchSelectHintClassName}`)
?.appendChild(this.parseTextToDOM(this.searchSelectHTMLNoData));
}
hide() {
document
.querySelector(`div.${this.searchSelectClassName}`)
?.setAttribute("style", "display: none;");
}
show() {
document
.querySelector(`div.${this.searchSelectClassName}`)
?.removeAttribute("style");
}
setParentValue(value) {
this.parentDOM.value = value;
}
setParentEvent() {
let that = this;
function _focus_event_(event) {
document
.querySelector(`div.${that.searchSelectClassName}`)
.setAttribute(
"style",
`
-moz-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming};
-webkit-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming};
-o-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming};
-ms-animation: searchSelectFalIn ${that.css.falInDuration}s 1 ${that.css.falInTiming};
`
);
}
function _blur_event_(event) {
setTimeout(() => {
if (that.searchSelectDeleteItemClicked) {
return;
}
if (
getComputedStyle(
document.querySelector(`div.${that.searchSelectClassName}`)
).display === "none"
) {
return;
}
document
.querySelector(`div.${that.searchSelectClassName}`)
.setAttribute(
"style",
`
-moz-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming};
-webkit-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming};
-o-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming};
-ms-animation: searchSelectFalOut ${that.falOutDuration}s 1 ${that.falOutTiming};
`
);
setTimeout(() => {
document
.querySelector(`div.${that.searchSelectClassName}`)
.setAttribute("style", "display:none;");
}, that.falOutDuration * 1000);
}, 100);
}
async function _propertychange_event_(event) {
that.parentDOM.dispatchEvent(new Event("focus"));
var getListResult = await that.getList(event.target.value);
that.update(getListResult);
}
this.parentDOM?.setAttribute(
"autocomplete",
"off"
); /* 禁用输入框自动提示 */
this.parentDOM.addEventListener(
"focus",
function (event) {
_focus_event_(event);
},
true
);
this.parentDOM.addEventListener(
"click",
function (event) {
event.target.dispatchEvent(new Event("focus"));
},
true
);
this.parentDOM.addEventListener(
"blur",
function (event) {
_blur_event_(event);
},
false
);
this.parentDOM.addEventListener(
"input",
function (event) {
_propertychange_event_(event);
},
true
);
document.addEventListener("click", function () {
var checkDOM = document.querySelector(
"ul." + that.searchSelectHintClassName
);
var mouseClickPosX = Number(
window.event.clientX
); /* 鼠标相对屏幕横坐标 */
var mouseClickPosY = Number(
window.event.clientY
); /* 鼠标相对屏幕纵坐标 */
var elementPosXLeft = Number(
checkDOM.getBoundingClientRect().left
); /* 要检测的元素的相对屏幕的横坐标最左边 */
var elementPosXRight = Number(
checkDOM.getBoundingClientRect().right
); /* 要检测的元素的相对屏幕的横坐标最右边 */
var elementPosYTop = Number(
checkDOM.getBoundingClientRect().top
); /* 要检测的元素的相对屏幕的纵坐标最上边 */
var elementPosYBottom = Number(
checkDOM.getBoundingClientRect().bottom
); /* 要检测的元素的相对屏幕的纵坐标最下边 */
if (
!(
mouseClickPosX >= elementPosXLeft &&
mouseClickPosX <= elementPosXRight &&
mouseClickPosY >= elementPosYTop &&
mouseClickPosY <= elementPosYBottom
) &&
!(
checkDOM.innerHTML.indexOf(window.event.target.innerHTML) !== -1
)
) {
that.searchSelectDeleteItemClicked = false;
that.parentDOM.dispatchEvent(new Event("blur"));
}
});
}
setItemEvent() {
let that = this;
document
.querySelectorAll(
`div.${this.searchSelectClassName} ul.${this.searchSelectHintClassName} li`
)
.forEach((item, index) => {
((v, i) => {
v.addEventListener(
"click",
function (event) {
event.stopPropagation();
that.searchSelectDeleteItemClicked = false;
that.parentDOM.dispatchEvent(new Event("focus"));
if (event.target.localName === "li") {
that.parentDOM.value = this.innerText;
that.parentDOM.dispatchEvent(new Event("blur"));
} else {
that.searchSelectDeleteItemClicked = true;
var dataId = parseInt(v.getAttribute("data-id"));
console.log("删除 " + that.showList[dataId]);
that.list.forEach((item, index) => {
if (item === this.innerText) {
that.list.splice(index, 1);
return;
}
});
that.showList.splice(dataId, 1);
v.remove();
document
.querySelectorAll(
`ul.${that.searchSelectHintClassName} li`
)
.forEach((item, index) => {
item.setAttribute("data-id", index);
});
that.list = that.list;
that.showList = that.showList;
GM_setValue("search_history", that.list);
if (that.list.length === 0) {
that.clear();
}
}
},
true
);
})(item, index);
});
}
getList(text) {
var event = {};
var that = this;
event.userInputText = text;
event.target = this.parentDOM;
event.list = this.list;
event.showList = this.showList;
this.addSearching();
return new Promise((resolve) => {
var result = that.inputValueChangeEvent(event);
if (this.parentDOM.value !== "" && result.length == 0) {
this.parentDOM.dispatchEvent(new Event("focus"));
}
that.removeSearching();
resolve(result);
});
}
}
GM_addStyle(`
#comiis_search_noe{
display: none !important;
}
#comiis_search_two{
display: block !important;
}
`);
var searchHistoryList = await GM_getValue("search_history", []);
new searchSelect({
parentDOM: document.querySelector("#scform_srchtxt"),
list: searchHistoryList,
inputValueChangeEvent: (event) => {
var result = [];
event.userInputText = event.userInputText.trim();
if (event.userInputText == "") {
return result;
}
event.list.forEach((item) => {
if (
item.match(
event.userInputText.replace(
/[\-\/\\\^\$\*\+\?\.\(\)\|\[\]\{\}]/g,
"\\$&"
)
)
) {
result = [item, ...result];
}
});
return result;
},
});
function search_event() {
/* 搜索历史事件 */
/* 搜索界面增加关闭按钮事件,清空input内容 */
/* 点击搜索保存搜索记录 */
$jq("#scform_submit").click(function () {
let getsearchtext = $jq("#scform_srchtxt").val();
if (getsearchtext != null && getsearchtext != "") {
let search_history_array = new Array(getsearchtext);
let has_history = GM_getValue("search_history");
if (has_history != null) {
if ($jq.inArray(getsearchtext, has_history) != -1) {
console.log("已有该搜索历史记录");
search_history_array = has_history;
} else {
console.log("无该记录,追加");
search_history_array = search_history_array.concat(has_history);
}
} else {
console.log("空记录,添加");
}
GM_setValue("search_history", search_history_array);
}
});
}
function add_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 = $jq(
".comiis_p12.f14.bg_f.f_c.b_b.cl,.comiis_tagtit.b_b.f_c"
);
insertdom.before(clear_history_innerHTML);
$jq(".btn_clear_search_history").click(function () {
GM_deleteValue("search_history");
window.location.reload();
});
}
search_event();
add_clear_history();
},
/**
* 在发帖|编辑帖子时选择发帖板块
*/
selectPostingSection() {
if (
!MT_CONFIG.methodRunCheck([
MT_CONFIG.urlRegexp.postForum,
MT_CONFIG.urlRegexp.editForum,
])
) {
return;
}
GM_addStyle(`
#select-post-section{
height: 28px;
width: 160px;
line-height: 28px;
border: 1px solid #ececec;
background: url(w.png) no-repeat;
background-position: 95% 50%;
-webkit-appearance: none;
appearance: none;
-moz-appearance: none;
}
`);
let section_dict = {
2: "版本发布",
37: "插件交流",
38: "建议反馈",
41: "逆向交流",
39: "玩机交流",
42: "编程开发",
40: "求助问答",
44: "综合交流",
50: "休闲灌水",
46: "官方公告",
53: "申诉举报",
92: "站务专区",
};
$jq(
".comiis_post_from .comiis_wzpost.comiis_input_style .comiis_styli:contains('标题')"
).before(
$jq(`
板块
`)
);
let selectNode = $jq(`#select-post-section`);
let currentSection = window.location.search.match(/fid=([0-9]+)/);
currentSection = currentSection[currentSection.length - 1];
if (window.location.href.match(MT_CONFIG.urlRegexp.postForum)) {
/* 发帖 */
console.log("发帖");
selectNode.on("change", function () {
let obj = $jq(this);
let fid = obj.val();
let postSection = `forum.php?mod=post&action=newthread&fid=${fid}&extra=&topicsubmit=yes&mobile=2`;
console.log(`修改发帖板块: ${section_dict[fid]} ${postSection}`);
let classifyClassNameDict = {
求助问答: {
className: "gm_user_select_help",
optionHTML: `
`,
},
建议反馈: {
className: "gm_user_select_feedback",
optionHTML: `
`,
},
站务专区: {
className: "gm_user_select_depot",
optionHTML: `
`,
},
};
if (classifyClassNameDict[section_dict[fid]]) {
if ($jq(".comiis_post_from .styli_tit:contains('分类')").length) {
$jq(".comiis_post_from .styli_tit:contains('分类')")
.parent()
.remove();
}
$jq(".comiis_stylino.comiis_needmessage").before(
$jq(`
分类
`)
);
} else {
Object.keys(classifyClassNameDict).forEach((key) => {
$jq(
".comiis_post_from ." + classifyClassNameDict[key]["className"]
).remove();
});
}
$jq("#postform").attr("action", postSection);
});
} else {
selectNode.attr("disabled", true);
}
selectNode.val(currentSection).trigger("change");
},
/**
* 设置动态头像
* 感谢提供思路 https://greasyfork.org/zh-CN/scripts/11969-discuz论坛头像上传助手
*/
setDynamicAvatar() {
if (
!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.dataSettingUrl], "v51")
) {
return;
}
let formhash = $jq(".sidenv_exit a:nth-child(1)")
.attr("href")
.match(/formhash=([0-9a-zA-Z]+)/);
let uid = $jq(".sidenv_exit a:nth-child(2)")
.attr("href")
.match(/uid=([0-9]+)/); /* 获取UID */
let avatarInfo = {
maxSize: 2097152 /* 图片文件最大大小 */,
big: {
width: 200,
height: 250,
status: false,
},
medium: {
width: 120,
height: 120,
status: false,
},
small: {
width: 48,
height: 48,
status: false,
},
};
formhash = formhash[formhash.length - 1];
uid = uid[uid.length - 1];
let dynamicAvater = $jq(`
修改动态头像
`);
function getStatus() {
/* 获取变量状态 */
return (
avatarInfo.big.status &&
avatarInfo.medium.status &&
avatarInfo.small.status
);
}
function setStatus(key, value) {
/* 设置变量状态 */
if (key === "comiis_file_dynamic_avater_big") {
avatarInfo.big.status = value;
} else if (key === "comiis_file_dynamic_avater_medium") {
avatarInfo.medium.status = value;
} else {
avatarInfo.small.status = value;
}
}
function getPCUploadNewAvater() {
return new Promise((resolve) => {
GM_xmlhttpRequest({
url: "https://bbs.binmt.cc/home.php?mod=spacecp&ac=avatar",
method: "GET",
timeout: 5000,
headers: {
"User-Agent": Utils.getRandomPCUA(),
},
onload: function (response) {
resolve(response.responseText);
},
onerror: function () {
popup2.toast("网络异常,请重新获取");
resolve("");
},
ontimeout: () => {
popup2.toast("请求超时");
resolve("");
},
});
});
}
function changeCheckFileEvent(
elementQuery,
maxWidth,
maxHeight,
maxSize
) {
/* 检查上传的文件是否符合,大小,尺寸 */
$jq(elementQuery).on("change", function () {
let uploadImageFile = this.files[0];
let fileSize = uploadImageFile.size;
let tmpImage = new Image();
let reader = new FileReader();
reader.readAsDataURL(uploadImageFile);
reader.onload = function (response) {
tmpImage.src = response.target.result;
tmpImage.onload = function () {
if (this.width > maxWidth || this.height > maxHeight) {
$jq(elementQuery).val("");
popup2.toast({
text: `图片尺寸超出,当前宽:${this.width} 高:${this.height}`,
delayTime: 4000,
});
return;
}
if (fileSize > maxSize) {
$jq(elementQuery).val("");
popup2.toast({
text: `图片大小(最大${maxSize})超出,当前大小:${fileSize}`,
delayTime: 4000,
});
return;
}
};
};
});
}
$jq(".comiis_edit_avatar").after(dynamicAvater);
dynamicAvater.on("click", () => {
popup2.confirm({
text: `
修改动态头像
`,
mask: true,
only: true,
ok: {
text: "上传",
callback: async () => {
if (!getStatus()) {
popup2.toast("图片校验不通过");
return;
}
popup2.showLoadingMask();
popup2.toast("正在处理数据中...");
let baseBig = await Utils.asyncFileToBase64(
$jq("#comiis_file_dynamic_avater_big").prop("files")[0]
);
let baseMedium = await Utils.asyncFileToBase64(
$jq("#comiis_file_dynamic_avater_medium").prop("files")[0]
);
let baseSmall = await Utils.asyncFileToBase64(
$jq("#comiis_file_dynamic_avater_small").prop("files")[0]
);
let base64Arr = [baseBig, baseMedium, baseSmall];
const dataArr = base64Arr.map((str) =>
str.substr(str.indexOf(",") + 1)
); /* 拿到3个头像的Base64字符串 */
let data_resp = await getPCUploadNewAvater();
if (data_resp == "") {
popup2.toast("获取PC数据失败");
popup2.closeMask();
return;
}
let data = data_resp.match(/var[\s]*data[\s]*=[\s]*"(.+?)"/);
if (data == null || data.length != 2) {
popup2.toast("获取变量-data失败");
popup2.closeMask();
return;
}
data = data[data.length - 1];
let data_split = data.split(",");
let uploadUrl = data_split[data_split.indexOf("src") + 1].replace(
"images/camera.swf?inajax=1",
"index.php?m=user&a=rectavatar&base64=yes"
);
let formData = new FormData();
formData.append("Filedata", "");
formData.append("avatar1", dataArr[0]);
formData.append("avatar2", dataArr[1]);
formData.append("avatar3", dataArr[2]);
formData.append("formhash", formhash);
GM_xmlhttpRequest({
url: uploadUrl,
method: "POST",
data: formData,
headers: {
origin: "https://bbs.binmt.cc",
referer:
"https://bbs.binmt.cc/home.php?mod=spacecp&ac=avatar",
accept:
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"User-Agent": Utils.getRandomPCUA(),
},
onload: function (response) {
let text = response.responseText;
if (
text.indexOf("window.parent.postMessage('success','*')") !=
-1
) {
popup2.toast("上传成功");
popup2.closeConfirm();
setTimeout(() => {
window.location.reload();
}, 1500);
} else {
popup2.toast(text);
}
},
onerror: function () {
popup2.toast("网络异常,请重新获取");
},
});
},
},
});
});
$jq(document).on(
"change",
"#popup2-confirm input[type='file']",
function () {
let fileObj = $jq(this);
if (fileObj.prop("files").length == 0) {
return;
}
let statusObj = fileObj.parent().find(".status");
let maxWidth = parseInt(fileObj.attr("data-maxwidth"));
let maxHeight = parseInt(fileObj.attr("data-maxheight"));
statusObj.text("🤡获取文件信息中...");
let uploadImageFile = fileObj.prop("files")[0];
let fileSize = uploadImageFile.size;
let tmpImage = new Image();
let reader = new FileReader();
reader.readAsDataURL(uploadImageFile);
reader.onload = function (response) {
tmpImage.src = response.target.result;
tmpImage.onload = function () {
if (this.width > maxWidth || this.height > maxHeight) {
/* 判断尺寸大小 */
setStatus(fileObj.attr("id"), false);
fileObj.val("");
statusObj.text(
`🤡校验失败,图片尺寸不符合 宽:${this.width} 高:${this.height}`
);
return;
}
if (fileSize > avatarInfo.maxSize) {
setStatus(fileObj.attr("id"), false);
fileObj.val("");
statusObj.text("🤡校验失败,图片大小不符合 " + fileSize);
return;
}
setStatus(fileObj.attr("id"), true);
statusObj.text(
`🤣 通过 宽:${this.width} 高:${this.height} 大小(byte):${fileSize}`
);
};
};
}
);
changeCheckFileEvent(
"#comiis_file_dynamic_avater_big",
avatarInfo.big.width,
avatarInfo.big.height,
avatarInfo.maxSize
);
changeCheckFileEvent(
"#comiis_file_dynamic_avater_medium",
avatarInfo.medium.width,
avatarInfo.medium.height,
avatarInfo.maxSize
);
changeCheckFileEvent(
"#comiis_file_dynamic_avater_small",
avatarInfo.small.width,
avatarInfo.small.height,
avatarInfo.maxSize
);
},
/**
* 导读新增显示最新帖子
*/
showLatestPostForm() {
if (
!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.navigationUrl], "v53")
) {
return;
}
if (
window.location.href.match(
/bbs.binmt.cc\/forum.php\?mod=guide&view=hot/g
)
) {
return;
}
function getLatestPostForm() {
/* 获取轮播的最新的帖子 */
return new Promise((resolve) => {
GM_xmlhttpRequest({
url: "https://bbs.binmt.cc/forum.php?mod=guide&view=hot",
method: "GET",
timeout: 8000,
async: false,
responseType: "html",
headers: {
accept:
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"User-Agent": Utils.getRandomAndroidUA(),
},
onload: function (response) {
console.log(response);
var respHTML = $jq(response.responseText);
var postFormList = respHTML.find(
'div.comiis_mh_kxtxt div[id*="comiis_mh_kxtxt"] ul'
);
if (postFormList.length === 0) {
popup2.toast("获取轮播失败");
resolve([]);
} else {
var result = [];
postFormList[postFormList.length - 1]
.querySelectorAll("a")
.forEach((item) => {
result = [
{
href: item.getAttribute("href"),
title: item.getAttribute("title"),
},
...result,
];
});
resolve(result);
}
},
onerror: function (response) {
console.log(response);
popup2.toast("网络异常,获取轮播失败");
resolve([]);
},
ontimeout: () => {
popup2.toast("请求超时");
resolve([]);
},
});
});
}
getLatestPostForm().then((result) => {
if (result.length) {
GM_addStyle(`
div.comiis_mh_kxtxt_owm{
margin-top: 10px;
}
div.comiis_mh_kxtxt_owm li{
height: 30px;
width: 100%;
display: flex;
align-items: center;
}
div.comiis_mh_kxtxt_owm span{
background: #FF705E;
color: #fff;
float: left;
height: 18px;
line-height: 18px;
padding: 0 3px;
margin-top: 2px;
margin-right: 10px;
overflow: hidden;
border-radius: 2px;
margin-left: 10px;
}
div.comiis_mh_kxtxt_owm a{
display: block;
font-size: 14px;
font-weight: 400;
height: 22px;
line-height: 22px;
overflow: hidden;
min-width: 100px;
max-width: 80%;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 10px;
}
`);
var latestPostFormHTML = "";
result.sort(
Utils.sortListByProperty((item) => {
var forumPostNum = item["href"].match(/thread-(.+?)-/i);
forumPostNum = forumPostNum[forumPostNum.length - 1];
forumPostNum = parseInt(forumPostNum);
return forumPostNum;
}, true)
);
console.log("导读内容", result);
result.forEach((item) => {
latestPostFormHTML += `
新帖
${item.title}
`;
});
$jq(".comiis_forumlist.comiis_xznlist").before(
$jq(
`
`
)
);
}
});
},
/**
* 显示签到的最先几个人,最多10个,和顶部的今日签到之星
*/
showSignInRanking() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.kMiSignSign])) {
return;
}
let today_ranking_ele = document.querySelector(
".comiis_topnv .comiis_flex .flex"
);
today_ranking_ele.after(
$jq(
`
今日最先`
)[0]
);
let getMaxPage = (urlextra) => {
return new Promise((resolve) => {
GM_xmlhttpRequest({
url: `https://bbs.binmt.cc/k_misign-sign.html?operation=${urlextra}`,
async: false,
responseType: "html",
timeout: 5000,
headers: {
"User-Agent": Utils.getRandomPCUA(),
},
onload: function (response) {
let last_page = $jq(response.responseText).find(
"#J_list_detail .pg span"
);
if (
last_page.length &&
typeof last_page[0].title != "undefined"
) {
let last_page_match = last_page[0].title.match(/([0-9]+)/);
if (last_page_match.length == 2) {
resolve(last_page_match[last_page_match.length - 1]);
} else {
popup2.toast("获取页失败");
resolve(0);
}
} else {
popup2.toast("请求最先签到的页失败");
resolve(0);
}
},
onerror: function (response) {
console.log(response);
popup2.toast("网络异常,请重新获取");
resolve(0);
},
ontimeout: () => {
popup2.toast("请求超时");
resolve(0);
},
});
});
};
let getPagePeople = (page) => {
return new Promise((resolve) => {
GM_xmlhttpRequest({
url: `https://bbs.binmt.cc/k_misign-sign.html?operation=list&op=&page=${page}`,
async: false,
timeout: 5000,
responseType: "html",
headers: {
"User-Agent": Utils.getRandomPCUA(),
},
onload: function (response) {
let peoples = $jq(response.responseText).find(
"#J_list_detail tbody tr"
);
let ret_array = [];
if (
peoples.length == 2 &&
peoples[0].textContent.indexOf("暂无内容") != -1
) {
resolve(ret_array);
return;
}
for (let i = 1; i <= peoples.length - 2; i++) {
let people = peoples[i];
let ret_json = {};
let user_name =
people.children[0].getElementsByTagName("a")[0].textContent;
let space_url =
people.children[0].getElementsByTagName("a")[0].href;
let uid = space_url.match(/space-uid-([0-9]*)/)[1];
let sign_all_days = people.children[1].textContent;
let sign_month_days = people.children[2].textContent;
let sign_time = people.children[3].textContent;
let sign_reward = people.children[5].textContent;
ret_json["user"] = user_name;
ret_json["uid"] = uid;
ret_json["avatar"] = MT_CONFIG.getAvatar(uid, "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);
}
resolve(ret_array);
},
onerror: function (response) {
console.log(response);
resolve({});
},
ontimeout: () => {
popup2.toast("请求超时");
resolve({});
},
});
});
};
function changeRankList(data, listtype) {
$jq("#ranklist").html(data);
$jq("#ranklist").attr("listtype", listtype);
}
ajaxlist = async (listtype) => {
listtype = listtype;
if (listtype == "today") {
loadingdelay = false;
urlextra = "list&op=today";
} else if (listtype == "month") {
loadingdelay = false;
urlextra = "list&op=month";
} else if (listtype == "zong") {
loadingdelay = false;
urlextra = "list&op=zong";
} else if (listtype == "calendar") {
loadingdelay = true;
urlextra = "calendar";
} else {
loadingdelay = false;
urlextra = "list";
}
/* alert(loadingdelay); */
if (listtype == "todayLatest") {
loadingdelay = false;
urlextra = "list&op=&page=0";
let maxPage = await getMaxPage(urlextra);
if (maxPage == 0) {
return;
}
let latestPeople = await getPagePeople(maxPage);
latestPeople.reverse();
if (latestPeople.length < 10) {
let latestPeople_2 = await getPagePeople(maxPage - 1);
latestPeople_2.reverse();
latestPeople = latestPeople.concat(latestPeople_2);
latestPeople.reverse();
}
let peopleHTML = "";
latestPeople.reverse();
console.log(latestPeople);
latestPeople.forEach((people) => {
peopleHTML =
peopleHTML +
`
|
|
${people["user"]}
${people["time"]}
总天数 ${people["days"]}天
月天数 ${people["monthDays"]} 天,次奖励 ${people["reward"]}
|
`;
});
let latestHTML =
`
`;
changeRankList(latestHTML, listtype);
} else {
$jq.ajax({
type: "GET",
url: `plugin.php?id=k_misign:sign&operation=${urlextra}`,
async: false,
dataType: "html",
success: function (response) {
/* console.log(data); */
response = response.replace(
`今日排行`,
`今日排行
今日最先`
);
changeRankList(response, listtype);
},
complete: function (XHR, TS) {
XHR = null;
},
});
}
};
},
/**
* 显示今日之星,在签到页上
*/
showTodayStar() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.kMiSignSign], "v33")) {
return;
}
let todayStarParent = $jq(".pg_k_misign .comiis_qdinfo");
let todayStar = document.createElement("ul");
GM_xmlhttpRequest({
url: "/k_misign-sign.html",
method: "get",
async: false,
timeout: 5000,
headers: {
"User-Agent": Utils.getRandomPCUA(),
},
onload: (response) => {
let html = $jq(response.responseText);
let todatastarele = html.find("#pt span.xg1");
if (!todatastarele.length) {
return;
}
let todaypeople = todatastarele[0].textContent.replace(
"今日签到之星:",
""
);
todayStar.innerHTML =
'
今日签到之星' +
todaypeople +
"";
let comiis_space_box_height = getComputedStyle(
$jq(".comiis_space_box")[0],
null
)["height"].replace("px", "");
let comiis_space_box_padding_bottom = getComputedStyle(
$jq(".comiis_space_box")[0],
null
)["padding-bottom"].replace("px", "");
comiis_space_box_height = parseInt(comiis_space_box_height);
comiis_space_box_padding_bottom = parseInt(
comiis_space_box_padding_bottom
);
let total_height =
comiis_space_box_height + comiis_space_box_padding_bottom + 50;
GM_addStyle(`
.comiis_space_box{
height: ${total_height}px;
background-size: 100% 100%;
}
.pg_k_misign .comiis_qdinfo{
height: 110px !important;
}`);
todayStarParent.append(todayStar);
},
onerror: (response) => {
console.log(response);
console.log("请求今日之星失败");
popup2.toast("请求今日之星失败");
},
ontimeout: () => {
popup2.toast("请求今日之星超时");
console.log("请求超时");
},
});
},
/**
* 显示空间-帖子-具体回复
*/
async showSpaceContreteReply() {
if (!MT_CONFIG.methodRunCheck([MT_CONFIG.urlRegexp.spacePost], "v52")) {
return;
}
GM_addStyle(`
div.contrete-reply{
padding: 5px 10px;
border-top: 1px solid #f3f3f3;
}
div.contrete-reply a{
margin: 0px 10px;
}`);
/**
* 获取PC端的回复内容
* @returns {[Array]}
*/
function getPCReply() {
return new Promise((resolve) => {
GM_xmlhttpRequest({
url: window.location.href,
method: "get",
async: false,
timeout: 5000,
headers: {
"User-Agent": Utils.getRandomPCUA(),
},
onload: (response) => {
let pageHTML = $jq(response.responseText);
let form = pageHTML.find("#delform tr.bw0_all+tr");
let resultList = [];
Array.from(form).forEach((item) => {
let replyData = [];
let tagTDNode = $jq($jq(item).find("td"));
let tagTDValue = tagTDNode.html().replace(/^ /, "");
replyData = replyData.concat(tagTDValue);
let nextHTML = $jq(item).next();
/* bw0_all是每个帖子的标志位 */
for (
let index = 0;
index < pageHTML.find("#delform tr").length;
index++
) {
if (
nextHTML.attr("class") === "bw0_all" ||
nextHTML.length === 0
) {
break;
}
let nextTdHTML = nextHTML.find("td");
let nextValue = nextTdHTML.html().replace(/^ /, "");
replyData = replyData.concat(nextValue);
nextHTML = nextHTML.next();
}
resultList.push(replyData);
});
resolve(resultList);
},
onerror: () => {
console.error("网络异常,获取PC回复失败");
popup2.toast("网络异常,获取PC回复失败");
resolve(null);
},
ontimeout: () => {
console.error("网络异常,获取PC回复失败");
popup2.toast("请求超时,获取PC回复失败");
resolve(null);
},
});
});
}
/**
* 获取当前页面所有帖子
* @returns {NodeList}
*/
function getFormList() {
return Utils.getNodeListValue(
MT_CONFIG.element.comiisFormlist,
MT_CONFIG.element.comiisPostli,
MT_CONFIG.element.comiisMmlist
);
}
/**
* 格式化一下获取的PC端的回复的内容
* @param {Array} dataList
*/
function formatPCReply(dataList) {
let resultJSON = {};
dataList.forEach((item) => {
let divItem = $jq(`
${item[0]}
`);
let url = divItem.find("a").prop("href");
let paramPtid = url.match(MT_CONFIG.urlRegexp.formPostParam_ptid);
let paramPid = url.match(MT_CONFIG.urlRegexp.formPostParam_pid);
if(!paramPtid){
popup2.toast("获取ptid失败")
return
}
if(!paramPid){
popup2.toast("获取pid失败")
return
}
paramPtid = paramPtid[paramPtid.length-1];
paramPid = paramPid[paramPid.length-1];
if(resultJSON[paramPtid]){
resultJSON[paramPtid]["data"] = [...resultJSON[paramPtid]["data"],...item];
}else{
resultJSON[paramPtid] = {
ptid:paramPtid,
pid:paramPid,
data:item
}
}
});
return resultJSON;
}
var pcReplyArray = await getPCReply();
if (pcReplyArray == null) {
return;
}
var pcReplyJSON = formatPCReply(pcReplyArray);
console.log(pcReplyJSON);
let formList = getFormList();
formList.forEach((formListItem, formListItemIndex) => {
/* 点赞按钮 */
let praiseNode = formListItem.querySelector(
".comiis_xznalist_bottom a"
);
let formTid = praiseNode.getAttribute("tid");
if (!formTid) {
popup2.toast("获取帖子tid失败");
console.error(formListItem);
return;
}
if(!pcReplyJSON[formTid]){
return;
}
pcReplyJSON[formTid]["data"].forEach((formListReplyHTMLItem) => {
$jq(formListItem).append(
$jq(`
${formListReplyHTMLItem}
`)
);
});
});
},
/**
* 注册设置菜单项
*/
registerSettingView() {
/**
* 设置 脚本设置界面的事件
*/
function setPageSettingViewEvent() {
$jq(".whitesev-mt-setting-item input[type='checkbox']").each(
(index, item) => {
item = $jq(item);
let dataKey = item.attr("data-key");
item.prop("checked", GM_getValue(dataKey, false));
}
);
$jq(".whitesev-mt-setting-item input[type='checkbox']").on(
"click",
function () {
let dataKey = $jq(this).attr("data-key");
GM_setValue(dataKey, this.checked);
}
);
}
/**
* 设置 脚本设置界面的CSS
*/
function setPageSettingViewCSS() {
/* checkbox美化 */
GM_addStyle(`
.whitesev-mt-setting-checkbox .knobs,
.whitesev-mt-setting-checkbox .layer{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.whitesev-mt-setting-checkbox{
/* position: relative;
top: 50%;
width: 56px;
height: 28px;
margin: 0px auto 0 auto;
overflow: hidden;
transform: translateY(-50%); */
position: relative;
width: 56px;
height: 28px;
overflow: hidden;
}
.whitesev-mt-setting-checkbox input[type="checkbox"]{
position: relative;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 3;
}
.whitesev-mt-setting-checkbox .knobs{
z-index: 2;
}
.whitesev-mt-setting-checkbox .layer{
width: 100%;
background-color: #fcebeb;
transition: 0.3s ease all;
z-index: 1;
}
.whitesev-mt-setting-checkbox .knobs:before,
.whitesev-mt-setting-checkbox .knobs span{
position: relative;
display: block;
top: 50%;
left: 30%;
/* width: 35%;
height: 65%; */
width: 20%;
height: auto;
color: #fff;
font-size: 10px;
font-weight: bold;
text-align: center;
line-height: 1;
padding: 9px 4px;
transform: translate(-50%,-50%);
}
.whitesev-mt-setting-checkbox .knobs span{
background-color: #F44336;
border-radius: 2px;
transition: 0.3s ease all, left 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15);
z-index: 1;
}
.whitesev-mt-setting-checkbox .knobs:before{
transition: 0.3s ease all, left 0.5s cubic-bezier(0.18, 0.89, 0.35, 1.15);
z-index: 2;
}
.whitesev-mt-setting-checkbox input[type="checkbox"]:checked + .knobs span{
left: 70%;
background-color: #03A9F4;
}
.whitesev-mt-setting-checkbox input[type="checkbox"]:checked ~ .layer{
background-color: #ebf7fc;
}`);
GM_addStyle(`
.whitesev-mt-setting{
height: 400px;
overflow-y: auto;
}
.whitesev-mt-setting-item{
width: 100%;
display: inline-flex;
margin: 15px 0px;
align-items: center;
justify-content: space-between;
}
.whitesev-mt-setting-name{
margin-left: 10px;
max-width: 70%;
}
.whitesev-mt-setting-checkbox{
margin-right: 10px;
}
`);
}
/**
* 设置 脚本设置界面
*/
function setPageSettingView() {
let settingView = $jq(`
MT论坛脚本设置
`);
settingView.on("click", function () {
$jq.NZ_MsgBox.alert({
title: "MT论坛脚本设置",
content: `
`,
type: "",
buttons: {
confirm: { text: "好的" },
},
});
setPageSettingViewEvent();
});
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(
settingView
);
}
if (window.location.href.match(MT_CONFIG.urlRegexp.bbs)) {
setPageSettingView();
setPageSettingViewCSS();
}
},
};
function entrance() {
/* 这是入口 */
if (!envIsMobile()) {
console.log("PC端显示");
Utils.tryCatch().run(pc.repairPCNoLoadResource);
$jq(document).ready(function () {
pc.main();
});
} else {
console.log("移动端显示");
$jq(document).ready(function () {
Utils.tryCatch().run(mobile.registerSettingView);
mobile.main();
});
}
}
/**
* 第一次使用该脚本的提示
*/
function firstUseTip() {
if (GM_getValue("firstUse", true) && envIsMobile()) {
var tipImage = "https://www.helloimg.com/images/2023/01/04/oCgy7o.gif";
popup2.confirm({
text: `
如果您是第一次使用,请看演示GIF
`,
cancel: {
text: "不再提醒",
callback: () => {
GM_setValue("firstUse", false);
popup2.closeConfirm();
popup2.closeMask();
},
},
});
}
}
if (envCheck()) {
$jq(document).ready(function () {
entrance();
console.log(`执行完毕,耗时${Date.now() - MT_CONFIG.gmRunStartTime}ms`);
firstUseTip();
});
}
})();