`,
mask: true,
only: true,
callback: async () => {
popup2.confirm_close();
let login_status = await checkLogin();
if (login_status) {
popup2.mask_loading_show();
popup2.toast("上传水印图片中...请稍后");
console.log(`图片数量:${needUploadImageFileArray.length}`);
utils.asyncArrayForEach(needUploadImageFileArray, uploadFileAwaitFunction, completeFunction);
}
},
btnOkText: "继续上传",
btnOther: {
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")) {
tryCatch(waterMarkAwaitFunction);
} else {
let login_status = await checkLogin();
if (login_status) {
popup2.mask_loading_show();
popup2.toast("上传图片中...请稍后");
console.log(`图片数量:${chooseImageFiles.length}`);
utils.asyncArrayForEach(chooseImageFiles, uploadFileAwaitFunction, completeFunction);
}
}
})
$jq(document).on("click", "#imglist_z4a .delImg", async function (e) {
e.preventDefault();
popup2.mask_loading_show();
popup2.toast("删除中,请稍后");
let id_encoded = e.currentTarget.getAttribute("id-encode");
if (!id_encoded) {
popup2.toast('获取id_encoded失败,请自行去Z4A图床删除');
return;
}
let deleteStatus = await mobile.chartBed.deleteImage(chartBedUrl, chartBedAuthToken, id_encoded);
popup2.mask_close();
if (deleteStatus) {
$jq(this).parent().remove();
mobile.chartBed.storage.delete("z4a", id_encoded);
}
})
}
function chartbedByHistory() {
/* 所有图床历史上传过的图片 */
GM_addStyle(`
.comiis_post_imglist li .delImg {
position: absolute;
top: -5px;
left: -5px;
}
`);
if (GM_getValue("chartBedsImagesHistory") == undefined) {
GM_setValue("chartBedsImagesHistory", []);
}
let historyImages = mobile.chartBed.storage.get();
let isAdd = false;
if (historyImages == []) {
return;
}
$jq(document).on("click", "#comiis_pictitle_tab_n_5", function (e) {
if (isAdd) {
$jq(document).off("click", "#comiis_pictitle_tab_n_5");
return;
}
isAdd = true;
$jq.each(historyImages, (i) => {
let _web = historyImages[i]["web"];
let _url = historyImages[i]["url"];
let _thumb_url = historyImages[i]["thumb_url"];
let _name = historyImages[i]["name"];
let _imageHTML = `
${_web}
`;
$jq("#imglist_history").append($jq(_imageHTML));
})
});
$jq(document).on("click", "#imglist_history .delImg", (e) => {
e.preventDefault();
let _t_index = e.currentTarget.getAttribute("t-index");
let imageItem = historyImages[_t_index];
let web = imageItem["web"];
let id_encoded = imageItem["id_encoded"];
e.currentTarget.parentElement.remove();
mobile.chartBed.storage.delete(web, id_encoded);
})
}
let imgBtn = `
图片 `;
let menu = `
`;
GM_addStyle(`
#filedata,
#filedata_kggzs,
#filedata_hello,
#filedata_z4a{
display: none;
}
.comiis_tip dt p{
padding: 10px 0px;
}
.upload-image-water{
overflow-y: auto;
}
.upload-image-water img{
width: 100%;
margin: 10px 0px;
}
`);
let jqMenu = $jq(menu);
jqMenu.find(".comiis_upbox.comiis_allowpostimg").append($jq(".comiis_wzpost.comiis_input_style .comiis_upbox.comiis_allowpostimg").children());
$jq(".swiper-wrapper.comiis_post_ico").append(imgBtn);
$jq("#comiis_post_tab").append(jqMenu);
tryCatch(chartbedByMT);
tryCatch(chartbedByKggzs);
tryCatch(chartbedByHello);
tryCatch(chartbedByZ4a);
tryCatch(chartbedByHistory);
},
editorOptimization() {
/* 编辑器优化-简略 */
if (!GM_getValue("v49") ||
!window.location.href.match(mt_config.rexp.forum_post)
) {
return
};
GM_addStyle(`
#comiis_foot_menu_beautify{
position: fixed;
display: inline-flex;
z-index: 90;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 48px;
overflow: hidden;
align-content: center;
justify-content: center;
align-items: center;
}
#comiis_foot_menu_beautify_big{
position: fixed;
display: inline-flex;
flex-direction: column;
z-index: 90;
left: 0;
right: 0;
bottom: 0;
width: 100%;
min-height: 120px;
overflow: hidden;
align-content: center;
justify-content: center;
align-items: center;
}
#comiis_foot_menu_beautify input.bg_e.f_c::-webkit-input-placeholder {
padding-left:10px;
color:#999999;
}
#comiis_foot_menu_beautify .reply_area ul li a{
display: block;
width: 22px;
height: 22px;
padding: 4px 8px;
margin: 8px 0;
position: relative;
}
#comiis_foot_menu_beautify .reply_area ul{
display: inline-flex;
align-content: center;
align-items: center;
justify-content: center;
}
#comiis_foot_menu_beautify .reply_area,
#comiis_foot_menu_beautify .reply_area ul{
width: 100%;
}
#comiis_foot_menu_beautify .reply_area li a i {
width: 22px;
height: 22px;
line-height: 22px;
font-size: 22px;
}
#comiis_foot_menu_beautify .reply_area li a span {
position: absolute;
display: block;
font-size: 10px;
height: 14px;
line-height: 14px;
padding: 0 6px;
right: -8px;
top: 4px;
overflow: hidden;
border-radius: 20px;
}
#comiis_foot_menu_beautify li[data-attr="回帖"] input{
border: transparent;
border-radius: 15px;
height: 30px;
width: 100%;
}
#comiis_foot_menu_beautify_big .reply_area{
margin: 10px 0px 5px 0px;
}
#comiis_foot_menu_beautify_big .reply_area ul{
display: inline-flex;
align-content: center;
justify-content: center;
align-items: flex-end;
}
#comiis_foot_menu_beautify_big li[data-attr="回帖"]{
width: 75vw;
margin-right: 15px;
}
#comiis_foot_menu_beautify_big .reply_user_content{
width: 75vw;
word-wrap: break-word;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin: 8px 10px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"]{
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] .fastpostform_new{
text-align: center;
margin-bottom: 28px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] .fastpostform_new i{
font-size: 22px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] input{
width: 60px;
height: 30px;
border: transparent;
color: #ffffff;
background: #d1c9fc;
border-radius: 30px;
margin-bottom: 6px;
}
#comiis_foot_menu_beautify_big li[data-attr="发表"] input[data-text='true']{
background: #7a61fb;
}
#comiis_foot_menu_beautify_big li[data-attr="回帖"] textarea{
padding: 10px 10px 10px 10px;
border: transparent;
border-radius: 6px;
min-height: 70px;
max-height: 180px;
background: #e9e8ec;
overflow-y: auto;
width: -webkit-fill-available;
}
#comiis_foot_menu_beautify .reply_area li[data-attr="回帖"]{
width: 65%;
margin: 0px 3%;
text-align: center;
}
#comiis_foot_menu_beautify .reply_area li:not(first-child){
width: 7%;
text-align: -webkit-center;
text-align: center;
}
#comiis_foot_menu_beautify_big .other_area{
width: 100%;
text-align: center;
}
#comiis_foot_menu_beautify_big .other_area .menu_icon a{
margin: 0px 20px;
}
#comiis_foot_menu_beautify_big .other_area i{
font-size: 24px;
}
#comiis_foot_menu_beautify_big .other_area #comiis_insert_ubb_tab i{
font-size: 16px;
}
#comiis_foot_menu_beautify_big .other_area .menu_body{
background: #f4f4f4;
}
#comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .comiis_optimization{
max-height: 140px;
overflow-y: auto;
flex-direction: column;
}
#comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .bqbox_t{
background: #fff;
}
#comiis_foot_menu_beautify_big .other_area .menu_body .comiis_smiley_box .bqbox_t ul#comiis_smilies_key li a.bg_f.b_l.b_r{
background: #f4f4f4 !important;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #comiis_pictitle_key{
display: flex;
top: 0px;
left: 0px;
height: 42px;
line-height: 42px;
overflow: hidden;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #comiis_pictitle_key li{
padding: 0px 10px;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab .comiis_upbox,
#comiis_foot_menu_beautify_big .menu_body #comiis_insert_ubb_tab .comiis_input_style{
height: 140px;
overflow-y: auto;
flex-direction: column;
}
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_kggzs,
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_hello,
#comiis_foot_menu_beautify_big .menu_body #comiis_pictitle_tab #filedata_z4a{
display:none;
}
`);
let pl = $jq("#comiis_foot_memu .comiis_flex li")[1];
let dz = $jq("#comiis_foot_memu .comiis_flex li")[2];
let sc = $jq("#comiis_foot_memu .comiis_flex li")[3];
let form_action = $jq('#fastpostform').attr('action');
let form_serialize = $jq('#fastpostform').serialize();
let form_url = $jq("#fastpostform .header_y a").attr("href");
$jq("#needmessage[name='message']").remove();
$jq("#imglist").remove();
$jq("#fastpostsubmitline").remove();
$jq("#fastpostsubmit").remove();
$jq("#comiis_foot_memu").hide();
$jq("#comiis_foot_memu").after($jq(`
`,
app: true,
success: async (x) => {
let localDataUser = lanzou.storage.getUser();
let localDataPwd = lanzou.storage.getPwd();
if (localDataUser != "" && localDataPwd != "") {
x.xtipdiv.querySelector(".xinput.xful[type='text']").value = localDataUser;
x.xtipdiv.querySelector(".xinput.xful[type='password']").value = localDataPwd;
}
x.xtipdiv.querySelector(".xbutton.xful.xblue").onclick = async () => {
let inputUser = x.xtipdiv.querySelector(".xinput.xful[type='text']").value.trim();
let inputPwd = x.xtipdiv.querySelector(".xinput.xful[type='password']").value.trim();
if (inputUser != "" && inputPwd != "") {
xtips.toast("登录中请稍后...");
let _formhash_ = await lanzou.login_getFormHash(inputUser, inputPwd);
console.log(_formhash_);
if (_formhash_ == 4) {
console.log("已登录");
lanzou.storage.setUser(inputUser);
lanzou.storage.setPwd(inputPwd);
if (lanzou.storage.getFormhash() == null) {
console.log("未知原因,已登录但本地未保存formhash,建立临时值");
lanzou.storage.setFormhash(_formhash_);
}
xtip.close(x.mainid);
showView();
return;
};
if (_formhash_ == null) {
return;
};
let loginStatus = await lanzou.login(inputUser, inputPwd, _formhash_);
if (loginStatus) {
console.log("登录成功");
console.log(inputUser, inputPwd, _formhash_);
lanzou.storage.setUser(inputUser);
lanzou.storage.setPwd(inputPwd);
lanzou.storage.setFormhash(_formhash_);
xtip.close(x.mainid);
showView();
}
} else {
xtips.toast('账号或密码不能为空');
}
}
}
});
}
async function showLanZouView(user, pwd) {
lanZouViewShowLock = false;
let sheet = null;
let _formhash_ = lanzou.storage.getFormhash();
let loginStatus = await lanzou.login(user, pwd, _formhash_);
if (!loginStatus) {
xtips.toast("登录过期");
lanzou.storage.delFormhash();
showLoginView();
return;
}
sheet = xtip.sheet({
btn: [`欢迎! ${user}`, '上传
', '查看历史上传']
});
$jq("#lanzouuploadfilebtn").off("change").change(async (e) => {
let lanzouChooseFile = e.currentTarget.files[0];
console.log(lanzouChooseFile);
let uploadFileInfo = await lanzou.uploadFile(lanzouChooseFile);
if (uploadFileInfo) {
let tempData = lanzou.storage.getUploadFiles();
tempData = tempData.concat(uploadFileInfo);
GM_setClipboard(`${uploadFileInfo["is_newd"]}/${uploadFileInfo["f_id"]}`);
xtips.toast("已复制到剪贴板");
console.log(tempData);
lanzou.storage.setUploadFiles(tempData);
}
})
let anyTouchNode = new AnyTouch(document.getElementById(sheet));
anyTouchNode.on("tap", (e) => {
if (document.getElementById(sheet).querySelector(".xtiper_bg").outerHTML.indexOf(e.target.outerHTML) != -1) {
/* 点击背景不关闭小窗 */
return;
}
if (document.querySelectorAll(".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li")[0].outerHTML.indexOf(e.target.outerHTML) != -1) {
/* 用户 */
xtip.confirm('确定退出登录吗?', {
btn1: async function () {
let logoutStatus = await lanzou.outLogin(lanzou.storage.getUser());
if (logoutStatus) {
xtips.toast("退出登录成功");
lanzou.storage.delFormhash();
anyTouchNode.off("tap");
xtip.close(sheet);
lanZouViewShowLock = false;
} else {
xtips.toast("退出登录失败");
}
}
});
return;
}
if (document.querySelectorAll(".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li")[1].outerHTML.indexOf(e.target.outerHTML) != -1) {
/* 上传 */
$jq("#lanzouuploadfilebtn").val("");
$jq("#lanzouuploadfilebtn").click();
return;
}
if (document.querySelectorAll(".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li")[2].outerHTML.indexOf(e.target.outerHTML) != -1) {
/* 查看历史上传 */
anyTouchNode.off("tap");
xtip.close(sheet);
showUploadFiles();
return;
}
if (document.querySelectorAll(".xtiper_sheet_ul.xtiper_sheet_center .xtiper_sheet_li")[3].outerHTML.indexOf(e.target.outerHTML) != -1) {
/* 取消 */
anyTouchNode.off("tap");
xtip.close(sheet);
lanZouViewShowLock = false;
return;
}
})
}
async function showView() {
let user = lanzou.storage.getUser();
let pwd = lanzou.storage.getPwd();
let formhash = lanzou.storage.getFormhash();
if (user == "" || pwd == "" || formhash == null) {
showLoginView();
} else {
showLanZouView(user, pwd);
}
}
function insertBtn() {
let comiis_left_Touch = document.createElement("li");
comiis_left_Touch.className = "comiis_left_Touch";
let ANode = document.createElement("a");
ANode.setAttribute("href", "javascript:;");
ANode.className = "blacklist";
ANode.innerHTML = `
蓝奏云
`;
ANode.onclick = () => {
if (!lanZouViewShowLock) {
showView();
lanZouViewShowLock = true;
} else {
console.log("重复点击");
}
}
comiis_left_Touch.append(ANode);
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(comiis_left_Touch);
}
insertBtn();
},
async loadCheckboxTipResource() {
/* 加载checkbox值变化的显示的提示的资源 */
await GM_asyncLoadScriptContent("https://whitesev.gitee.io/static_resource/ios_loading/js/iosOverlay.js");
await GM_asyncLoadStyleSheet("https://whitesev.gitee.io/static_resource/ios_loading/css/iosOverlay.css");
},
loadNextComments() {
/* 加载下一页的评论 */
function autoLoadNextPageComments(post_comments_list) {
/* 自动加载下一页的评论 */
$jq("#loading-comment-tip")[0].parentElement.style.display = "";
let next_page_url = post_comments_list.children[2].href;
let isloding_flag = false;
console.log("预设,获取下一页url:", next_page_url);
if (next_page_url.indexOf("javascript:;") != -1) {
console.log(post_comments_list);
console.log("无多页评论");
$jq("#loading-comment-tip")[0].parentElement.style.display = "none";
return;
}
function _loadNextComments_() {
if (isloding_flag == false) {
isloding_flag = true;
$jq("#loading-comment-tip").text("正在加载评论中...");
$jq("#loading-comment-tip")[0].parentElement.style.display = "";
let _url_ = next_page_url;
$jq.get(_url_, function (data, status, xhr) {
console.log("正在请求的下一页url", _url_);
let postlist = $jq(data);
let kqideSourceNode = $jq(".comiis_postlist.kqide");
let postDOM = postlist.find(".comiis_postlist.kqide").html();
let get_next_page_url = postlist.find(".nxt");
if (get_next_page_url.length != 0) {
console.log("成功获取到下一页-评论");
next_page_url = get_next_page_url.attr("href");
let newURL = new URL(_url_);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log("设置当前的url为请求的下一页url", window.location.origin + setLocationUrl);
window.history.pushState('forward', null, setLocationUrl);
$jq("#loading-comment-tip")[0].parentElement.style.display = "none";
} else {
console.log("评论全部加载完毕,关闭监听事件");
let newURL = new URL(next_page_url);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log("设置当前的url为请求的最后一页url", setLocationUrl);
window.history.pushState('forward', null, setLocationUrl);
$jq(".comiis_page.bg_f").remove();
$jq("#loading-comment-tip").text("已加载完所有评论");
$jq("#loading-comment-tip")[0].parentElement.style.display = "";
$jq("#loading-comment-tip").off("click", _loadNextComments_);
$jq(window).off("scroll", scroll_loadNextComments);
}
isloding_flag = false;
kqideSourceNode.append(postDOM);
mobile.needRepeatLoadingJSResource();
})
} else {
console.log("正在加载中请稍后");
}
}
function scroll_loadNextComments() {
if (Math.ceil($jq(window).scrollTop() + $jq(window).height() + 150) >= $jq(document).height()) {
/* load data */
_loadNextComments_();
}
}
$jq(window).on("scroll", scroll_loadNextComments);
$jq("#loading-comment-tip").text("请上下滑动或点击加载");
$jq("#loading-comment-tip").on("click", _loadNextComments_);
}
if (GM_getValue("v21") && window.location.href.match(mt_config.rexp.forum_post) && document.title.indexOf("提示信息 - MT论坛") == -1) {
let tip_html = `
`;
$jq(".comiis_bodybox").append($jq(tip_html));
let commentsEle = document.querySelector(".comiis_pltit span.f_d") || document.querySelector("#comiis_foot_memu .comiis_kmvnum");
if (document.querySelector(".comiis_pltit h2") && document.querySelector(".comiis_pltit h2").textContent.indexOf("暂无评论") != -1) {
console.log("暂无评论");
$jq("#loading-comment-tip")[0].parentElement.style.display = "none";
return;
}
let commentsNum = parseInt(commentsEle.textContent);
if (commentsNum >= 10) {
let setAutoLoadInterval = setInterval(function () {
let post_comments_list = document.querySelector(".comiis_page.bg_f"); /* 评论列表 */
if (post_comments_list) {
autoLoadNextPageComments(post_comments_list);
clearInterval(setAutoLoadInterval);
} else {
console.log("正在等待下一页列表元素出现");
}
}, 500)
} else {
console.log("无多页评论");
$jq("#loading-comment-tip")[0].parentElement.style.display = "none";
}
}
},
loadPrevComments() {
/* 加载上一页的评论 */
function autoLoadPrevPageComments() {
/* 自动加载上一页的评论 */
let post_comments_list = document.querySelector(".comiis_page.bg_f");
let prev_page_url = post_comments_list.children[0].href;
let isloding_flag = false;
console.log("预设,获取上一页url:", prev_page_url);
$jq("#loading-comment-tip-prev").text("请上下滑动或点击加载");
$jq("#loading-comment-tip-prev").on("click", _loadPrevComments_);
function _loadPrevComments_() {
if (isloding_flag) {
console.log("正在加载上一页中请稍后");
} else {
isloding_flag = true;
$jq("#loading-comment-tip-prev").text("正在加载评论中...");
$jq("#loading-comment-tip-prev")[0].parentElement.style.display = "";
let _url_ = prev_page_url;
$jq.get(_url_, function (data, status, xhr) {
console.log("正在请求的上一页评论:", prev_page_url);
let postlist = $jq(data);
let kqideSourceNode = $jq(".comiis_postlist.kqide");
let postDOM = postlist.find(".comiis_postlist.kqide").html();
let get_pregv_page_url = postlist.find(".prev");
if (get_pregv_page_url.length != 0) {
console.log("成功获取到上一页-评论");
prev_page_url = get_pregv_page_url.attr("href");
let newURL = new URL(_url_);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log("设置当前的url为请求的上一页url", window.location.origin + setLocationUrl);
window.history.pushState('forward', null, setLocationUrl);
$jq("#loading-comment-tip-prev")[0].parentElement.style.display = "none";
isloding_flag = false;
kqideSourceNode.prepend(postDOM);
mobile.needRepeatLoadingJSResource();
} else {
isloding_flag = false;
kqideSourceNode.prepend(postDOM);
let newURL = new URL(prev_page_url);
let setLocationUrl = `${newURL.pathname}${newURL.search}`;
console.log("已到顶页,设置当前的url第一页url", window.location.origin + setLocationUrl);
window.history.pushState('forward', null, setLocationUrl);
console.log("上一页评论全部加载完毕,关闭监听事件");
let page_title = postlist.find(".comiis_viewtit")[0].outerHTML;
console.log($jq(page_title));
kqideSourceNode.prepend($jq(page_title)[0]);
mobile.needRepeatLoadingJSResource();
/* $jq(".comiis_page.bg_f").remove(); */
$jq("#loading-comment-tip-prev").remove();
$jq("#loading-comment-tip-prev").off("click", _loadPrevComments_);
$jq(window).off("scroll", );
}
})
}
/* $jq(window).unbind("scroll",_loadPrevComments_); */
}
function scroll_loadPrevComments() {
if ($jq(window).scrollTop() <= 50) {
_loadPrevComments_();
}
}
$jq(window).on("scroll", scroll_loadPrevComments);
}
if (GM_getValue("v32") && window.location.href.match(mt_config.rexp.forum_post) && document.title.indexOf("提示信息 - MT论坛") == -1) {
if (!document.querySelector(".comiis_pltit span.f_d")) {
console.log("当前不在第一页,加载上一页评论");
let tip_html = `
`;
$jq(".comiis_bodybox script")[0].after($jq(tip_html)[0]);
if (document.querySelector(".comiis_pltit h2") && document.querySelector(".comiis_pltit h2").textContent.indexOf("暂无评论") != -1) {
console.log("暂无上一页评论");
$jq("#loading-comment-tip-prev")[0].parentElement.style.display = "none";
return;
}
autoLoadPrevPageComments();
}
}
},
main() {
/* 手机版按顺序加载的函数 */
tryCatch(mobile.commentsAddReviews);
tryCatch(mobile.recoveryIMGWidth);
tryCatch(mobile.identifyLinks);
tryCatch(mobile.showUserUID);
tryCatch(mobile.previewPictures);
tryCatch(mobile.removeForumPostFontStyle);
tryCatch(mobile.removeForumPostCommentFontStyle);
tryCatch(mobile.autoSignIn);
tryCatch(mobile.autoExpendFullTextByForumPost);
tryCatch(mobile.searchHistory);
tryCatch(mobile.loadNextComments, '', '$jq("#loading-comment-tip").text("加载评论失败")');
tryCatch(mobile.loadPrevComments, '', '$jq("#loading-comment-tip-prev").text("加载评论失败")');
tryCatch(mobile.repairClearSearchInput);
tryCatch(mobile.repairUnableToEnterOtherSpaceCorrectly);
tryCatch(mobile.chatChartBed);
tryCatch(mobile.pageSmallWindowBrowsingForumPost);
tryCatch(mobile.codeQuoteCopyBtn);
tryCatch(mobile.editorOptimization);
tryCatch(mobile.editorOptimizationFull);
tryCatch(mobile.shieldUser);
tryCatch(mobile.shieldPlate);
tryCatch(mobile.userCheckBoxSettings); /* 选项主要界面内容 */
tryCatch(mobile.blackHome.insertMobileBlackHomeButton);
tryCatch(mobile.lanzouFunction);
tryCatch(mobile.paymentSubjectReminder);
tryCatch(mobile.blacklistShieldUsersOrBlocks);
tryCatch(mobile.showTodayStar);
tryCatch(mobile.showSignInRanking);
tryCatch(mobile.pageAfterDOMChangeRunFunction);
unsafeWindow.popup2 = popup2;
popup2.init();
},
needRepeatLoadingJSResource() {
/* 帖子内需要重复执行的js */
tryCatch(mobile.shieldUser);
tryCatch(mobile.commentsAddReviews);
tryCatch(mobile.identifyLinks);
tryCatch(mobile.showUserUID);
tryCatch(mobile.previewPictures);
tryCatch(mobile.modifyForumPostFontColor);
tryCatch(mobile.pageSmallWindowBrowsingForumPost);
tryCatch(mobile.codeQuoteCopyBtn);
tryCatch(mobile.editorOptimizationOffDefaultBottomReplyBtnClickEvent);
popup.init();
},
pageAfterDOMChangeRunFunction() {
/* 当本页面动态加载帖子需要重复加载的东西 */
if (window.location.href.match(/bbs.binmt.cc\/forum/) ||
window.location.href.match(/bbs.binmt.cc\/home.php\?mod=space&do=thread&view=me/) ||
window.location.href.match(/home.php\?mod=space&uid=.+&do=thread&view=me/)) {
function beforeHookRun() {
tryCatch(mobile.showUserUID);
tryCatch(mobile.previewPictures);
tryCatch(mobile.shieldUser);
tryCatch(mobile.shieldPlate);
tryCatch(mobile.pageSmallWindowBrowsingForumPost);
tryCatch(mobile.codeQuoteCopyBtn);
}
document.body.addEventListener("DOMNodeInserted", (event) => {
let ele = event.target;
if (ele.className != null && ele.className.indexOf("comiis_forumlist") != -1) {
beforeHookRun();
}
})
}
},
pageSmallWindowBrowsingForumPost() {
/* 页面小窗浏览帖子 */
if (!GM_getValue("v45") && (
!(window.location.href.match(mt_config.rexp.forum_guide_url) ||
!(window.location.href.match(mt_config.rexp.search_url))
))) {
return
};
/* if (window != top.window) {
console.log("当前在非top里,已禁用初始化小窗");
return;
} */
GM_addStyle(`
.xtiper_sheet,
.xtiper_sheet .xtiper_sheet_tit{
border-radius: 18px 18px 0px 0px;
}
/* title自定义美化 */
.xtiper_sheet_tit.xtiper_sheet_left{
display: block;
background: #fff;
width: 100%;
box-sizing: border-box;
}
.xtiper_sheet_tit.xtiper_sheet_left img.xtiper_tit_ico{
background: #fff;
filter: invert(100%);
width: 24px;
height: 24px;
align-self: center;
}
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content{
margin-left: 22px;
width: 215px;
}
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content p{
word-wrap: break-word;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content .xtiper_tit_svg_lock{
display: flex;
align-items: center;
}
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_content .xtiper_tit_svg_lock svg{
margin: 0px 6px 0px 2px;
}
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_right {
display: inline-flex;
align-items: center;
align-content: center;
width: 115px;
justify-content: center;
}
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_right_windowopen,
.xtiper_sheet_tit.xtiper_sheet_left .xtiper_tit_right_windowclose{
width: 100%;
text-align: center;
margin: 0px 0px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
/* 底部高度不对等问题*/
.xtiper_content.xtit{
height: calc(100% - 80px);
}
/* 底部消息距离底部30px*/
.xtiper.xtiper_msg.xtiper_msg_bottom.xtiper_msg_black.xon{
margin-bottom: 30px;
}
/* 标题顶部拖拽*/
.xtiper_sheet_tit_top_drag{
width: 100%;
position: relative;
height: 10px;
}
.xtiper_sheet_tit_top_drag div{
width: 50px;
margin: 0 auto;
height: 4px;
background: #d9d9d9;
border-radius: 15px;
bottom: 3px;
position: relative;
}
`);
function getFormList() {
/* 获取当前页面所有帖子 */
let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : [];
formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList;
formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList;
return formList;
}
let formlist = null; /* 帖子列表 */
let isFindFormList = false; /* 是否找到帖子 */
let findFormListNums = 0; /* 找到帖子的数量 */
let smallWindowId = null; /* 小窗对象 */
let waitFormListAppear = setInterval(function () {
/* 等待页面加载出现帖子 */
if (isFindFormList) {
formlist = getFormList();
main();
clearInterval(waitFormListAppear);
} else {
if (findFormListNums >= 10) {
console.log("未出现帖子或寻找贴子超时,清理定时器");
clearInterval(waitFormListAppear);
}
isFindFormList = getFormList().length ? true : false;
findFormListNums += 1;
}
}, 800);
function popstateFunction() {
window.history.pushState('forward', null, '#');
window.history.forward(1);
resumeBack();
}
function banBack() {
/* 禁止浏览器后退按钮 */
if (window.history && window.history.pushState) {
$jq(window).on('popstate', popstateFunction);
}
window.history.pushState('forward', null, '#'); /* 在IE中必须得有这两行 */
window.history.forward(1);
};
async function resumeBack() {
/* 允许浏览器后退并关闭小窗 */
xtip.close(smallWindowId);
smallWindowId = null;
$jq(window).off('popstate', popstateFunction);
while (1) {
if (window.location.href == 'https://bbs.binmt.cc/#') {
console.log("back!");
await utils.asyncSetTimeOut("window.history.back();", 100);
await utils.sleep(100);
} else {
return;
}
}
};
function getSmallPageBtn(forumPostTitle, forumPostUrl, isNew) {
let prevNode = document.createElement("li");
let constructURL = new URL(forumPostUrl);
let isHTTPS = constructURL.protocol.indexOf("https:") != -1 ? true : false;
let safeIcon = `
`;
let unsafeIcon = `
`;
let blankOpenIcon = `
`;
let closeIcon = `
`;
let showWebsiteSafeIcon = isHTTPS ? safeIcon : unsafeIcon;
let websiteTitle = `
${forumPostTitle}
${showWebsiteSafeIcon}
${constructURL.host}
${blankOpenIcon}
${closeIcon}
`;
prevNode.className = "f_c";
prevNode.setAttribute("style", "display: flex;justify-content: center;align-items: center;");
prevNode.innerHTML = `
`;
prevNode.getElementsByClassName("tosmallwindowprev")[0].innerText = isNew ? "Win" : "浏览";
prevNode.onclick = () => {
banBack();
let temp_id = xtip.open({
type: 'url',
content: forumPostUrl,
title: websiteTitle,
height: '88%',
app: true,
success: (e) => {},
end: () => {
console.log("点击其它区域关闭小窗");
resumeBack();
}
});
if (typeof top.window.tampermonkeyByMT != "undefined") {
console.log("当前执行为非油猴调用");
let iframe_id = temp_id + "_id";
document.getElementById(iframe_id).onload = () => {
console.log(`子窗口: ${iframe_id}加载完毕`);
let scriptNode = document.createElement("script");
scriptNode.innerHTML = top.window.tampermonkeyByMT;
document.getElementById(iframe_id).contentWindow.document.head.append(scriptNode);
}
}
smallWindowId = temp_id;
console.log(smallWindowId);
let dragNode = new AnyTouch(document.getElementById(temp_id));
let smallWidowNode = document.getElementById(temp_id).querySelector("div.xtiper_sheet");
let smallWidowNormalHeight = parseInt(smallWidowNode.style["height"]); /* 小窗原始高度 */
console.log("小窗原始高度", smallWidowNormalHeight);
dragNode.on("pan", (e) => {
if (e.phase == 'move' && e.displacementY > 0) {
/* 当前为向下移动 */
smallWidowNode.style["transition"] = "none";
smallWidowNode.style["height"] = Math.abs(smallWidowNormalHeight - e.distanceY) + "px";
}
if (e.isEnd) {
/* 当前为停止移动,松开手指,判断在哪个区域,一半以上回归上面,一般以下,关闭 */
smallWidowNode.style["transition"] = "0.2s ease-in";
if (parseInt(smallWidowNode.style["height"]) > (window.innerHeight / 2)) {
smallWidowNode.style["height"] = smallWidowNormalHeight + "px";
} else {
resumeBack();
}
}
})
dragNode.on("tap", (e) => {
if (document.getElementById(temp_id).querySelector(".xtiper_bg").outerHTML.indexOf(e.target.outerHTML) != -1) {
/* 点击背景关闭小窗 */
console.log("点击背景关闭小窗");
resumeBack();
dragNode.off("tap");
dragNode.off("pan");
return;
}
if (document.getElementById(temp_id).querySelector(".xtiper_tit_content").outerHTML.indexOf(e.target.outerHTML) != -1) {
GM_setClipboard(`『${forumPostTitle}』 - ${forumPostUrl}`);
xtips.toast('已复制链接', {
icon: 'success',
pos: 'bottom'
});
return;
}
if (document.getElementById(temp_id).querySelector(".xtiper_tit_right_windowopen svg").outerHTML.indexOf(e.target.outerHTML) != -1) {
window.open(forumPostUrl, "_blank");
return;
}
if (document.getElementById(temp_id).querySelector(".xtiper_tit_right_windowclose svg").outerHTML.indexOf(e.target.outerHTML) != -1) {
console.log("点击关闭按钮关闭小窗");
resumeBack();
dragNode.off("tap");
dragNode.off("pan");
return;
}
})
}
return prevNode;
}
async function main() {
$jq.each(formlist, function (index, value) {
let isNewUI = false;
let formBottomEle = value.querySelectorAll(".comiis_znalist_bottom.b_t.cl ul.cl li");
if (!formBottomEle.length) {
let tempFormBottomEle = value.querySelectorAll(".comiis_xznalist_bottom.cl ul.cl li"); /* 新版论坛UI */
if (!tempFormBottomEle.length) {
return
};
formBottomEle = tempFormBottomEle;
isNewUI = true;
};
let clParentEle = formBottomEle[0].parentElement;
if (clParentEle.querySelector(".tosmallwindowprev")) {
console.log("已经插入过小窗浏览");
} else {
let forumPostUrl = value.querySelector(".mmlist_li_box.cl a").getAttribute("href");
let forumPostTitle = value.querySelector(".mmlist_li_box.cl a").innerText;
if (!forumPostUrl) {
console.log("获取帖子url失败");
return;
}
if (!forumPostTitle) {
console.log("获取帖子标题失败");
return;
}
let previewPicturesEle = getSmallPageBtn(forumPostTitle, forumPostUrl, isNewUI ? isNewUI : null);
if (previewPicturesEle != null) {
clParentEle.append(previewPicturesEle);
clParentEle.setAttribute("style", "display: flex;height: inherit;");
}
}
})
}
},
paymentSubjectReminder() {
/* 付费主题白嫖提醒 */
let urlForumPostMatchStatus = window.location.href.match(mt_config.rexp.forum_post);
let urlHomeSpaceMatchStatus = window.location.href.match(mt_config.rexp.home_space_url);
let urlGuideMatchStatus = window.location.href.match(mt_config.rexp.forum_guide_url);
let urlCommunityMatchStatus = window.location.href.match(mt_config.rexp.community_url) || window.location.href.match(mt_config.rexp.plate_url);
let urlBBSMatchStatus = window.location.href.match(mt_config.rexp.bbs);
let storageMatchStatus = GM_getValue("v44") != null;
let setTipForumPostList = GM_getValue("tipToFreeSubjectForumPost") == null ? [] : GM_getValue("tipToFreeSubjectForumPost");
const paymentSubjectReminderHome = {
getData() {
/* 获取数据 */
return GM_getValue("tipToFreeSubjectForumPost") == null ? [] : GM_getValue("tipToFreeSubjectForumPost");
},
setData(data) {
/* 设置数据 */
GM_setValue("tipToFreeSubjectForumPost", data);
},
async insertButtonView() {
/* 插入-底部导航-我的-付费主题白嫖列表(按钮) */
let comiis_left_Touch = document.createElement("li");
comiis_left_Touch.className = "comiis_left_Touch";
let paymentSubjectReminderHomeBtn = document.createElement("a");
paymentSubjectReminderHomeBtn.setAttribute("href", "javascript:;");
paymentSubjectReminderHomeBtn.className = "paymentsubjectreminder";
paymentSubjectReminderHomeBtn.innerHTML = `
付费主题白嫖列表
`;
GM_addStyle(`
.NZ-MsgBox-alert .msgcontainer .msgtitle {
text-align: center !important;
}
#autolist .k_misign_lu img {
width: 40px;
height: 40px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
}
.k_misign_lc .f_c{
margin: 5px 0px;
}
details.subjectnotvisit,
details.subjectcanvisit{
margin-left: 20px;
}
`)
paymentSubjectReminderHomeBtn.onclick = () => {
paymentSubjectReminderHome.showView();
}
comiis_left_Touch.append(paymentSubjectReminderHomeBtn);
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(comiis_left_Touch);
/* Array.from(document.querySelectorAll(".comiis_myinfo_list.bg_f.cl")).forEach((ele) => {
if (ele.innerText.match(/消息提醒|资料设置|我的积分|我的勋章|我的道具/)) {
ele.append(paymentSubjectReminderHomeBtn);
return;
}
}) */
},
async showView() {
/* 显示-付费主题白嫖列表(dialog) */
if (typeof $jq.NZ_MsgBox == "undefined") {
popup2.toast("加载NZMsgBox.js中");
await GM_asyncLoadScriptNode("https://greasyfork.org/scripts/449562-nzmsgbox/code/NZMsgBox.js");
if (typeof $jq.NZ_MsgBox == "undefined") {
popup2.toast("网络异常,加载NZMsgBox.js失败");
return;
} else {
console.log("成功加载NZMsgBox.js");
}
}
let data = paymentSubjectReminderHome.getData();
$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;
}
}
let concatList = {
"content": `
`,
"timestamp": v["expirationTimeStamp"]
};
if (new Date().getTime() > v["expirationTimeStamp"]) {
/* 可白嫖 */
if (leftRedBtn != '') {
isFreeNotVisitedContentList = isFreeNotVisitedContentList.concat(concatList);
} else {
isFreeContentList = isFreeContentList.concat(concatList);
}
} else {
isPaidContentList = isPaidContentList.concat(concatList);
}
});
isFreeNotVisitedContentList.sort(utils.sortListByProperty("timestamp", "asc"));
isFreeContentList.sort(utils.sortListByProperty("timestamp", "asc"));
isFreeContent = utils.listToStringByValue(isFreeNotVisitedContentList, "content") + utils.listToStringByValue(isFreeContentList, "content");
isPaidContent = utils.listToStringByValue(isPaidContentList, "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,
"callback": () => {
data.splice(t_index, 1);
console.log(data);
paymentSubjectReminderHome.setData(data);
e.target.parentElement.parentElement.parentElement.parentElement.parentElement.remove();
popup2.confirm_close();
},
"only": true
});
});
$jq("#paymentSubjectReminderIsFreeList").on("click", "a", (e) => {
var t_index = e.target.getAttribute("t-index");
var t_href = e.target.getAttribute("t-href");
console.log(t_index, t_href);
data[t_index]["isVisited"] = true;
paymentSubjectReminderHome.setData(data);
window.open(t_href, "_blank");
e.target.setAttribute("style", "color: #000000;");
if (e.target.parentElement.parentElement.children[0].className != "icon_msgs bg_del") {
return;
}
e.target.parentElement.parentElement.children[0].remove();
$jq("#paymentSubjectReminderIsFreeList").append(e.target.parentElement.parentElement.parentElement.parentElement.parentElement);
let notVisitedNums = $jq(".subjectcanvisit summary span.icon_msgs.bg_del.f_f").text();
notVisitedNums = parseInt(notVisitedNums) - 1;
if (notVisitedNums > 0) {
$jq(".subjectcanvisit summary span.icon_msgs.bg_del.f_f").html(notVisitedNums);
} else {
$jq(".subjectcanvisit summary span.icon_msgs.bg_del.f_f").remove();
}
})
$jq("#paymentSubjectReminderIsPaidList").on("click", "a", (e) => {
var t_index = e.target.getAttribute("t-index");
var t_href = e.target.getAttribute("t-href");
console.log(t_index, t_href);
window.open(t_href, "_blank");
e.target.setAttribute("style", "color: #000000;");
})
}
}
if (storageMatchStatus && urlForumPostMatchStatus) {
/* 帖子内部-添加进提醒的按钮或者已添加进提醒的按钮点击移出 */
let paySubjectTip = $jq("span.kmren"); /* 购买主题的元素 */
if (paySubjectTip.length != 0) {
log.success("当前帖子存在需要购买主题");
let isAddTip = false;
let tipBtnHTML = '';
Array.from(setTipForumPostList).forEach((item, index) => {
if (window.location.href.match(item["url"])) {
isAddTip = true;
return;
}
});
if (isAddTip) {
log.success("已设置提醒");
tipBtnHTML = $jq(`
`);
tipBtnHTML.on("click", function () {
popup2.confirm({
text: "
确定移出付费主题白嫖列表?
",
callback: function () {
let isRemove = false;
Array.from(setTipForumPostList).forEach((item, index) => {
if (window.location.href.match(item["url"])) {
setTipForumPostList.splice(index, 1);
GM_setValue("tipToFreeSubjectForumPost", setTipForumPostList);
isRemove = true;
utils.asyncSetTimeOut("window.location.reload()", 1500);
return;
}
});
if (!isRemove) {
popup2.toast("移出失败");
} else {
popup2.confirm_close();
popup2.toast({
"text": "移出成功"
});
}
},
mask: true
});
});
} else {
log.success("未设置提醒");
tipBtnHTML = $jq(`
`);
tipBtnHTML.on("click", () => {
let expirationTimeMatch = $jq(".kmren").parent().text().replace(/\t|\n/g, "").match(/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}[\s]{1}[0-9]{1,2}:[0-9]{1,2}/);
if (expirationTimeMatch.length == 0) {
popup2.toast({
"text": "获取付费主题到期时间失败"
});
return;
}
let expirationTime = expirationTimeMatch[0];
let expirationTimeStamp = utils.formatDateStrToStamp(expirationTime);
setTipForumPostList = setTipForumPostList.concat({
"url": window.location.href,
"title": document.title.replace(" - MT论坛", ""),
"expirationTime": expirationTime,
"expirationTimeStamp": expirationTimeStamp,
"isVisited": false
});
GM_setValue("tipToFreeSubjectForumPost", setTipForumPostList);
popup2.toast({
"text": "添加成功"
});
setTimeout(function () {
window.location.reload();
}, 1500);
});
}
$jq(".comiis_head.f_top .header_y").append(tipBtnHTML);
};
}
if (storageMatchStatus && urlBBSMatchStatus) {
/* 底部导航-我的-提供类似小黑屋这种可查看设置提醒的帖子 */
paymentSubjectReminderHome.insertButtonView();
}
if (storageMatchStatus) {
/* 设置提醒小红点 */
function getTipNums() {
let needTipNums = 0;
Array.from(paymentSubjectReminderHome.getData()).forEach((item, index) => {
if (new Date().getTime() > item["expirationTimeStamp"] && item["isVisited"] == false) {
needTipNums += 1;
}
});
return needTipNums;
}
if (urlHomeSpaceMatchStatus || urlGuideMatchStatus || urlCommunityMatchStatus) {
/* 当前网页为,底部导航-我的 */
let redBtn = $jq(".icon_msgs.bg_del.f_f"); /* 底部导航-我的-右上角小红点 */
let tipNums = 0;
if (redBtn.length) {
tipNums = parseInt(redBtn.text());
$jq(".icon_msgs.bg_del.f_f").html(tipNums + getTipNums());
$jq(".comiis_head .header_z .kmuser em").append($jq(`
`));
} else {
let tipnums = getTipNums();
if (tipnums) {
/* $jq("ul.comiis_flex li.flex a[title='我的'] i.comiis_font").append($jq(`
${tipnums} `)); */
$jq(".comiis_head .header_z .kmuser em").append($jq(`
`));
}
}
}
if (urlBBSMatchStatus) {
/* 当前网页为,全部 */
let redBtn = $jq(".sidenv_num.bg_del.f_f"); /* 侧边栏-头像-右上角小红点 */
let tipNums = 0;
if (redBtn.length) {
tipNums = parseInt(redBtn.text());
$jq(".sidenv_num.bg_del.f_f").html(tipNums + getTipNums());
} else {
let tipnums = getTipNums();
if (tipnums) {
$jq(".sidenv_user em").before($jq(`
${tipnums} `));
}
}
if (getTipNums()) {
/* 当前网页为,侧边slider,付费白嫖列表 */
/* $jq(".comiis_left_Touch .paymentsubjectreminder div.flex").append($jq(`
`)); */
$jq(".comiis_left_Touch .paymentsubjectreminder div.flex").append($jq(`
`));
}
}
}
},
async previewPictures() {
/* 贴外预览图片-使用github项目https://github.com/fengyuanchen/viewerjs */
if (!GM_getValue("v34") &&
(!(window.location.href.match(mt_config.rexp.forum_guide_url) ||
/* !(window.location.href.match(mt_config.rexp.forum_post)) ||
!(window.location.href.match(mt_config.rexp.plate_url)) || */
!(window.location.href.match(mt_config.rexp.search_url))
))) {
return
}
function getFormList() {
let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : [];
formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList;
formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList;
return formList;
}
let formlist = null; /* 帖子列表 */
let isFindFormList = false;
let findFormListNums = 0;
let waitFormListAppear = setInterval(function () {
if (isFindFormList) {
formlist = getFormList();
main();
clearInterval(waitFormListAppear)
} else {
if (findFormListNums >= 10) {
console.log("未出现帖子或寻找贴子超时,清理定时器");
clearInterval(waitFormListAppear);
}
isFindFormList = getFormList().length ? true : false;
findFormListNums += 1;
}
}, 800);
function getPreviewBtn(node, isNew) {
let prevNode = document.createElement("li");
prevNode.className = "f_c";
let imageDOM = node.querySelectorAll(".comiis_pyqlist_img").length ? node.querySelectorAll(".comiis_pyqlist_img") : node.querySelectorAll(".comiis_pyqlist_imgs");
if (imageDOM.length == 0) {
return null;
};
prevNode.setAttribute("style", "display: flex;justify-content: center;");
prevNode.innerHTML = `
`;
Array.from(imageDOM).forEach(item => {
let needPrevImages = item.querySelectorAll("img");
let postForumImageNodeDiv = document.createElement("div");
let postForumImageNodeUl = document.createElement("ul");
postForumImageNodeUl.className = "postforumimages";
postForumImageNodeUl.setAttribute("style", "display:none;");
Array.from(needPrevImages).forEach(_img_ => {
let tempLi = document.createElement("li");
let tempImg = document.createElement("img");
tempImg.setAttribute("data-src", _img_.getAttribute("src"));
tempLi.append(tempImg);
postForumImageNodeUl.append(tempLi);
});
postForumImageNodeDiv.append(postForumImageNodeUl);
prevNode.append(postForumImageNodeDiv);
})
let canPrevImageNums = prevNode.getElementsByTagName("img").length;
prevNode.getElementsByClassName("topreimg")[0].innerText = isNew ? canPrevImageNums : "预览";
prevNode.onclick = (e) => {
let imageList = e.target.parentElement.children[2].children[0];
let viewer = new Viewer(imageList, {
inline: false,
url: "data-src",
hidden: () => {
viewer.destroy();
}
});
viewer.zoomTo(1);
viewer.show();
}
return prevNode;
}
async function main() {
$jq.each(formlist, function (index, value) {
let isNewUI = false;
let formBottomEle = value.querySelectorAll(".comiis_znalist_bottom.b_t.cl ul.cl li");
if (!formBottomEle.length) {
let tempFormBottomEle = value.querySelectorAll(".comiis_xznalist_bottom.cl ul.cl li"); /* 新版论坛UI */
if (!tempFormBottomEle.length) {
return
};
formBottomEle = tempFormBottomEle;
isNewUI = true;
};
let clParentEle = formBottomEle[0].parentElement;
if (clParentEle.querySelector(".topreimg")) {
console.log("已经插入过预览图片");
} else {
let previewPicturesEle = getPreviewBtn(value, isNewUI ? isNewUI : null);
if (previewPicturesEle != null) {
clParentEle.append(previewPicturesEle);
clParentEle.setAttribute("style", "display: flex;");
}
}
})
}
},
previewPostForum() {
/* 发帖、回复、编辑预览功能 */
GM_addStyle(`
#comiis_mh_sub{
height:40px;
}
.gm_plugin_previewpostforum svg{
}
.gm_plugin_previewpostforum_html .comiis_message_table{
margin-top: 10px;
font-weight: initial;
line-height: 24px;
}
.gm_plugin_previewpostforum_html .comiis_message_table a{
height: auto;
float: unset;
color: #507daf !important;
}
.gm_plugin_previewpostforum_html .comiis_message_table i{
text-align: unset;
font-size: unset;
line-height: unset;
padding-top: unset;
display: unset;
}
.comiis_postli.comiis_list_readimgs.nfqsqi{
width: 100vw;
}
.gm_plugin_previewpostforum_html.double-preview{
width: 50vw;
}
.gm_plugin_previewpostforum_html.double-preview .comiis_over_box.comiis_input_style{
border-left: 1px solid;
}
`);
let open_double = GM_getValue("preview_post_forum_by_double");
function addMenu_preview() {
/* 添加底部菜单-预览 */
$jq("#comiis_mh_sub .swiper-wrapper.comiis_post_ico").append($jq(`
预览 `));
}
function addMenu_doubleColumnPreview() {
/* 添加底部菜单-高级-使用双列预览 */
$jq("#htmlon").parent().append($jq(`
使用双列预览
`));
$jq("#postformdouble").on("click", function () {
let obj = $jq(this);
let code_obj = obj.parent().find(".comiis_checkbox");
if (code_obj.hasClass("comiis_checkbox_close")) {
GM_setValue("preview_post_forum_by_double", true)
} else {
GM_setValue("preview_post_forum_by_double", false)
}
})
}
function addMenu_immersiveInput() {
/* 添加底部菜单-高级-使用沉浸输入 */
$jq("#htmlon").parent().append($jq(`
使用沉浸输入
`));
$jq("#immersiveinput").on("click", function () {
let obj = $jq(this);
let code_obj = obj.parent().find(".comiis_checkbox");
console.log(code_obj.attr("class"));
if (code_obj.hasClass("comiis_checkbox_close")) {
$jq(".comiis_wzpost ul li.comiis_flex").hide(); /* 板块、标题 */
$jq(".comiis_wzpost ul li.comiis_styli.kmquote").hide(); /* 回复别人的quote */
$jq("#pollchecked").parent().parent().hide(); /* 投票,最多可填写 20 个选项 */
$jq("#pollm_c_1").hide(); /* 投票,增加一项 */
$jq(".comiis_polloption_add+div.f_0").hide(); /* 投票,增加一项(编辑状态下) */
$jq(".comiis_wzpost ul li.comiis_thread_content:contains('内容')").hide(); /* 投票,内容 */
} else {
$jq(".comiis_wzpost ul li.comiis_flex").show();
$jq(".comiis_wzpost ul li.comiis_styli.kmquote").show();
$jq("#pollchecked").parent().parent().show();
$jq("#pollm_c_1").show();
$jq(".comiis_polloption_add+div.f_0").show();
$jq(".comiis_wzpost ul li.comiis_thread_content:contains('内容')").show();
}
window.dispatchEvent(new Event("resize"));
})
}
const smiliesDictionaries = {
/* 表情字典 */
"[呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq001.gif",
"[撇嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq002.gif",
"[色]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq003.gif",
"[发呆]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq004.gif",
"[得意]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq005.gif",
"[流泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq006.gif",
"[害羞]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq007.gif",
"[闭嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq008.gif",
"[睡]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq009.gif",
"[大哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq010.gif",
"[尴尬]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq011.gif",
"[发怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq012.gif",
"[调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq013.gif",
"[呲牙]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq014.gif",
"[惊讶]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq015.gif",
"[难过]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq016.gif",
"[酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq017.gif",
"[冷汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq018.gif",
"[抓狂]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq019.gif",
"[吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq020.gif",
"[偷笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq021.gif",
"[可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq022.gif",
"[白眼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq023.gif",
"[傲慢]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq024.gif",
"[饥饿]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq025.gif",
"[困]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq026.gif",
"[惊恐]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq027.gif",
"[流汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq028.gif",
"[憨笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq029.gif",
"[装逼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq030.gif",
"[奋斗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq031.gif",
"[咒骂]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq032.gif",
"[疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq033.gif",
"[嘘]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq034.gif",
"[晕]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq035.gif",
"[折磨]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq036.gif",
"[衰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq037.gif",
"[骷髅]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq038.gif",
"[敲打]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq039.gif",
"[再见]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq040.gif",
"[擦汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq041.gif",
"[抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq042.gif",
"[鼓掌]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq043.gif",
"[糗大了]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq044.gif",
"[坏笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq045.gif",
"[左哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq046.gif",
"[右哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq047.gif",
"[哈欠]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq048.gif",
"[鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq049.gif",
"[委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq050.gif",
"[快哭了]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq051.gif",
"[阴脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq052.gif",
"[亲亲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq053.gif",
"[吓]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq054.gif",
"[可怜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq055.gif",
"[眨眼睛]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq056.gif",
"[笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq057.gif",
"[dogeQQ]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq058.gif",
"[泪奔]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq059.gif",
"[无奈]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq060.gif",
"[托腮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq061.gif",
"[卖萌]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq062.png",
"[斜眼笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq063.gif",
"[喷血]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq064.gif",
"[惊喜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq065.gif",
"[骚扰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq066.gif",
"[小纠结]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq067.gif",
"[我最美]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq068.gif",
"[菜刀]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq069.gif",
"[西瓜]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq070.gif",
"[啤酒]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq071.gif",
"[篮球]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq072.gif",
"[乒乓]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq073.gif",
"[咖啡]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq074.gif",
"[饭]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq075.gif",
"[猪]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq076.gif",
"[玫瑰]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq077.gif",
"[凋谢]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq078.gif",
"[示爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq079.gif",
"[爱心]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq080.gif",
"[心碎]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq081.gif",
"[蛋糕]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq082.gif",
"[闪电]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq083.gif",
"[炸弹]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq084.gif",
"[刀]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq085.gif",
"[足球]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq086.gif",
"[瓢虫]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq087.gif",
"[便便]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq088.gif",
"[月亮]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq089.gif",
"[太阳]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq090.gif",
"[礼物]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq091.gif",
"[抱抱]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq092.gif",
"[喝彩]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq93.gif",
"[祈祷]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq94.gif",
"[棒棒糖]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq95.gif",
"[药]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq96.gif",
"[赞]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq097.gif",
"[差劲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq098.gif",
"[握手]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq099.gif",
"[胜利]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq100.gif",
"[抱拳]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq101.gif",
"[勾引]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq102.gif",
"[拳头]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq103.gif",
"[差劲]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq104.gif",
"[爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq105.gif",
"[NO]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq106.gif",
"[OK]": "https://cdn-bbs.mt2.cn/static/image/smiley/qq/qq107.gif",
"[#呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_1.png",
"[#滑稽]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_10.png",
"[#吐舌]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_3.png",
"[#哈哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_2.png",
"[#啊]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_23.png",
"[#酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_22.png",
"[#怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_13.png",
"[#开心]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_39.png",
"[#汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_14.png",
"[#泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_16.png",
"[#黑线]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_15.png",
"[#鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_21.png",
"[#不高兴]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_12.png",
"[#真棒]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_17.png",
"[#钱]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_40.png",
"[#疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_26.png",
"[#阴险]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_20.png",
"[#吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_34.png",
"[#咦]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_41.png",
"[#委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_29.png",
"[#花心]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_6.png",
"[#呼~]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_42.png",
"[#激动]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_5.png",
"[#冷]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_43.png",
"[#可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_4.png",
"[#What?]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_25.png",
"[#勉强]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_38.png",
"[#狂汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_24.png",
"[#酸爽]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_27.png",
"[#乖]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_8.png",
"[#雅美蝶]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_28.png",
"[#睡觉]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_31.png",
"[#惊哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_19.png",
"[#哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_44.png",
"[#笑尿]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_32.png",
"[#惊讶]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_30.png",
"[#小乖]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_7.png",
"[#喷]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_18.png",
"[#抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_33.png",
"[#捂嘴笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_9.png",
"[#你懂的]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_11.png",
"[#犀利]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_35.png",
"[#小红脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_36.png",
"[#懒得理]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_37.png",
"[#爱心]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_45.png",
"[#心碎]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_46.png",
"[#玫瑰]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_47.png",
"[#礼物]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_48.png",
"[#彩虹]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_49.png",
"[#太阳]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_50.png",
"[#月亮]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_51.png",
"[#钱币]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_52.png",
"[#咖啡]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_53.png",
"[#蛋糕]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_54.png",
"[#大拇指]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_55.png",
"[#胜利]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_56.png",
"[#爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_57.png",
"[#OK]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_58.png",
"[#弱]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_59.png",
"[#沙发]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_60.png",
"[#纸巾]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_61.png",
"[#香蕉]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_62.png",
"[#便便]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_63.png",
"[#药丸]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_64.png",
"[#红领巾]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_65.png",
"[#蜡烛]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_66.png",
"[#三道杠]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_67.png",
"[#音乐]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_68.png",
"[#灯泡]": "https://cdn-bbs.mt2.cn/static/image/smiley/comiis_tb/tb_69.png",
"[doge]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/1.png",
"[doge思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/2.png",
"[doge再见]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/3.png",
"[doge生气]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/4.png",
"[doge气哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/5.png",
"[doge笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/7.png",
"[doge调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/6.png",
"[doge啊哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/8.png",
"[doge原谅TA]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/9.png",
"[miao]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/10.png",
"[miao思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/11.png",
"[miao拜拜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/12.png",
"[miao生气]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/13.png",
"[miao气哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/14.png",
"[二哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/15.png",
"[摊手]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/19.png",
"[w并不简单]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/20.png",
"[w滑稽]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/21.png",
"[w色]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/22.png",
"[w爱你]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/23.png",
"[w拜拜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/24.png",
"[w悲伤]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/25.png",
"[w鄙视]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/26.png",
"[w馋嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/27.png",
"[w冷汗]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/28.png",
"[w打哈欠]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/29.png",
"[w打脸]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/30.png",
"[w敲打]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/31.png",
"[w生病]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/32.png",
"[w闭嘴]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/33.png",
"[w鼓掌]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/34.png",
"[w哈哈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/35.png",
"[w害羞]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/36.png",
"[w呵呵]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/37.png",
"[w黑线]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/38.png",
"[w哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/39.png",
"[w调皮]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/40.png",
"[w可爱]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/41.png",
"[w可怜]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/42.png",
"[w酷]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/43.png",
"[w困]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/44.png",
"[w懒得理你]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/45.png",
"[w流泪]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/46.png",
"[w怒]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/47.png",
"[w怒骂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/48.png",
"[w钱]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/49.png",
"[w亲亲]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/50.png",
"[w傻眼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/51.png",
"[w便秘]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/52.png",
"[w失望]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/53.png",
"[w衰]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/54.png",
"[w睡觉]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/55.png",
"[w思考]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/56.png",
"[w开心]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/57.png",
"[w色舔]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/58.png",
"[w偷笑]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/59.png",
"[w吐]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/60.png",
"[w抠鼻]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/61.png",
"[w委屈]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/62.png",
"[w笑哭]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/63.png",
"[w嘻嘻]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/64.png",
"[w嘘]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/65.png",
"[w阴险]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/66.png",
"[w疑问]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/67.png",
"[w抓狂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/70.png",
"[w晕]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/69.png",
"[w右哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/68.png",
"[w左哼哼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/71.png",
"[w肥皂]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/77.png",
"[w奥特曼]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/78.png",
"[w草泥马]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/79.png",
"[w兔子]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/80.png",
"[w熊猫]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/81.png",
"[w猪头]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/82.png",
"[w→_→]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/83.png",
"[w给力]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/84.png",
"[w囧]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/85.png",
"[w萌]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/86.png",
"[w神马]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/87.png",
"[w威武]": "https://cdn-bbs.mt2.cn/static/image/smiley/doge/88.png",
}
function clickEvent(e) {
/* 预览按钮点击事件 */
if ($jq("#polldatas").length) {
/* 当前是投票帖子 */
replaceVote();
}
if (!$jq(this).find("i.comiis_font").hasClass("f_0")) {
$jq(".gm_plugin_previewpostforum_html").css("display", "block");
let replaecdText = replaceText($jq("#needmessage").val());
$jq(".gm_plugin_previewpostforum_html .comiis_message_table")[0].innerHTML = replaecdText;
if (open_double) {
$jq(".gm_plugin_previewpostforum_html.double-preview .comiis_over_box.comiis_input_style").css("height", $jq("#needmessage").css("height"));
}
} else {
$jq(".gm_plugin_previewpostforum_html").hide();
}
};
function replaceText(text) {
/* 替换内容 */
let attachimgmatch = text.match(/\[attachimg\]([\s\S]+?)\[\/attachimg\]/g);
if (attachimgmatch) {
attachimgmatch.forEach(item => {
let aimgidMatch = item.match(/\[attachimg\]([\s\S]+?)\[\/attachimg\]/);
let aimg_id = aimgidMatch ? aimgidMatch[aimgidMatch.length - 1] : "";
let imgtitle = $jq(`#aimg_${aimg_id}`).attr("title");
let imgsrc = $jq(`#aimg_${aimg_id}`).attr("src");
if (!imgsrc) {
imgtitle = "该图片不存在";
}
text = text.replace(item, `
`);
});
}
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]*?)\[\/img\]/g);
if (img) {
img.forEach(item => {
let match_content = item.match(/\[img\]([\s\S]*?)\[\/img\]/);
let content = match_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\]/ig);
if (password) {
password.forEach(item => {
console.log(item);
text = item.replace(/\[password\](.*?)\[\/password\]/ig, "");
$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 + `
${v.value}
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 = (a) => {
unsafeWindow.$('#needmessage').comiis_insert(a);
unsafeWindow.$("#needmessage")[0].dispatchEvent(new Event('input'));
}
}
addMenu_doubleColumnPreview();
addMenu_preview();
addMenu_immersiveInput();
if (open_double) {
/* box-shadow: -1px 0px 8px; */
$jq("#needmessage").parent().css("display", "flex");
$jq("#needmessage").after($jq(`
`));
} else {
$jq("#comiis_post_tab").append($jq(`
`));
}
$jq("#needmessage").on("propertychange input", keyUpEvent);
$jq(".gm_plugin_previewpostforum").on("click", clickEvent);
},
quickUBB: {
code: {
"rainbow1": {
"key": "转普通彩虹",
"value": "",
"isFunc": true,
"num": 1
},
"rainbow2": {
"key": "转黑白彩虹",
"value": "",
"isFunc": true,
"num": 2
},
"rainbow3": {
"key": "转黑红彩虹",
"value": "",
"isFunc": true,
"num": 3
},
"rainbow4": {
"key": "转蓝绿彩虹",
"value": "",
"isFunc": true,
"num": 4
},
"size": {
"key": "size",
"value": "[size=][/size]",
"tagL": "=",
"tagR": "]",
"L": "[size=]",
"R": "[/size]",
"cursorL": "[size=",
"cursorLength": 6,
"quickUBBReplace": "[size=14]replace[/size]"
},
"color": {
"key": "color",
"value": "[color=][/color]",
"tagL": "=",
"tagR": "]",
"L": "[color=]",
"R": "[/color]",
"cursorL": "[color=",
"cursorLength": 7,
"quickUBBReplace": "[color=#000]replace[/color]"
},
"b": {
"key": "加粗",
"value": "[b][/b]",
"tagL": "]",
"tagR": "[",
"L": "[b]",
"R": "[/b]",
"cursorR": "[/b]",
"cursorLength": 4,
"quickUBBReplace": "[b]replace[/b]"
},
"u": {
"key": "下划线",
"value": "[u][/u]",
"tagL": "]",
"tagR": "[",
"L": "[u]",
"R": "[/u]",
"cursorR": "[/u]",
"cursorLength": 4,
"quickUBBReplace": "[u]replace[/u]"
},
"i": {
"key": "倾斜",
"value": "[i][/i]",
"tagL": "]",
"tagR": "[",
"L": "[i]",
"R": "[/i]",
"cursorR": "[/i]",
"cursorLength": 4,
"quickUBBReplace": "[i]replace[/i]"
},
"s": {
"key": "中划线",
"value": "[s][/s]",
"tagL": "]",
"tagR": "[",
"L": "[s]",
"R": "[/s]",
"cursorR": "[/s]",
"cursorLength": 4,
"quickUBBReplace": "[s]replace[/s]"
},
"lineFeed": {
"key": "换行",
"value": "[*]",
"L": "",
"R": "[*]",
"cursorL": "[*]",
"cursorLength": 3,
"quickUBBReplace": "replace[*]"
},
"longHorizontalLine": {
"key": "水平线",
"value": "[hr]",
"L": "",
"R": "[hr]",
"cursorL": "[hr]",
"cursorLength": 4,
"quickUBBReplace": "replace[hr]"
},
"link": {
"key": "链接",
"value": "[url=][/url]",
"tagL": "=",
"tagR": "]",
"L": "[url=]",
"R": "[/url]",
"cursorL": "[url=",
"cursorLength": 5,
"quickUBBReplace": "[url=replace]replace[/url]"
},
"hide": {
"key": "隐藏",
"value": "[hide][/hide]",
"tagL": "]",
"tagR": "[",
"L": "[hide]",
"R": "[/hide]",
"cursorR": "[/hide]",
"cursorLength": 7,
"quickUBBReplace": "[hide]replace[/hide]"
},
"quote": {
"key": "引用",
"value": "[quote][/quote]",
"tagL": "]",
"tagR": "[",
"L": "[quote]",
"R": "[/quote]",
"cursorR": "[/quote]",
"cursorLength": 8,
"quickUBBReplace": "[quote]replace[/quote]"
},
"email": {
"key": "邮件",
"value": "[email=][/email]",
"tagL": "=",
"tagR": "]",
"L": "[email=]",
"R": "[/email]",
"cursorL": "[email=",
"cursorLength": 7,
"quickUBBReplace": "[email=replace]replace[/email]"
}
},
insertQuickReplyUBB: () => {
/* 快捷回复 */
$jq.each(mobile.quickUBB.code, function (index, value) {
let ubbs = $jq(`
${value["key"]}`);
ubbs.on("click", function () {
$jq("#comiis_insert_ubb_tab div.comiis_post_urlico ul li.quickUBBs a.comiis_xifont").removeClass("f_0").addClass("f_d");
$jq(this).find(".comiis_xifont").removeClass("f_d").addClass("f_0");
popup2.confirm({
text: `
`,
mask: true,
only: true,
callback: () => {
let userInput = $jq(".quickinsertbbsdialog").val().trim();
if (userInput == null || userInput.trim() == "") {
return;
}
if (value["isFunc"]) {
comiis_addsmilies(mobile.quickUBB.set_rainbow(value["num"], userInput)); /* 插入贴内 */
} else if (value["quickUBBReplace"]) {
comiis_addsmilies(value["quickUBBReplace"].replaceAll("replace", userInput)); /* 插入贴内 */
} else {
comiis_addsmilies(userInput); /* 插入贴内 */
}
popup2.confirm_close();
/* if (value["isFunc"]) {
userInput = mobile.quickUBB.set_rainbow(value["num"], userInput);
}*/
}
})
})
$jq("#comiis_insert_ubb_tab div.comiis_post_urlico ul").append(ubbs[0]);
})
},
insertReplayUBB: () => {
/* 具体回复 */
let insertDOM = $jq(".comiis_post_urlico");
if (!insertDOM) {
console.log("未找到插入元素");
return;
}
GM_addStyle(`
#comiis_post_tab .comiis_input_style .comiis_post_urlico li a.f_0{
color: #53bcf5 !important;
}
`);
let parentEle = $jq(".comiis_post_urlico > ul")[0];
let contentEle = $jq("#comiis_post_qydiv > ul");
let childNums = $jq("#comiis_post_qydiv ul li").length;
mobile.quickUBB.jqueryExtraFunction();
$jq("#comiis_post_tab .comiis_input_style .comiis_post_urlico li").on("click", function () {
$jq("#comiis_post_tab .comiis_input_style .comiis_post_urlico li a").removeClass("f_0");
$jq("#comiis_post_tab .comiis_input_style .comiis_post_urlico li a").addClass("f_d");
$jq(this).find("a").attr("class", "comiis_xifont f_0");
$jq("#comiis_post_qydiv ul li").hide().eq($jq(this).index()).fadeIn();
})
$jq.each(mobile.quickUBB.code, function (key, value) {
let ubbs = $jq(`
${value["key"]}`);
ubbs.on("click", (e) => {
let bottomEle = $jq(`#comiis_post_qydiv li[data-key='${value.key}']`);
if (!bottomEle.length) {
console.log("未找到该元素");
return
}
let contentIndex = childNums + Object.keys(mobile.quickUBB.code).indexOf(key);
console.log(contentIndex);
$jq("#comiis_post_qydiv ul li").hide().eq(contentIndex).fadeIn();
$jq.each($jq("#comiis_post_tab div.comiis_post_urlico ul li a.comiis_xifont"), (i, v) => {
v.className = "comiis_xifont f_d";
if (v == e.target) {
v.className = "comiis_xifont f_0";
}
});
})
parentEle.append(ubbs[0]);
let ubbs_content = document.createElement("li");
ubbs_content.setAttribute("style", "display: none;");
ubbs_content.setAttribute("data-key", value["key"]);
ubbs_content.innerHTML = `
`;
contentEle.append(ubbs_content);
$jq(`.comiis_sendbtn[data-keyI="${key}"]`).on("click", () => {
let text = $jq(`#comiis_input_${key}`).val();
if (text == '') {
popup2.toast('请输入需要插入的内容');
return;
}
if (mobile.quickUBB.code[key]["isFunc"]) {
text = mobile.quickUBB.set_rainbow(mobile.quickUBB.code[key]["num"], text);
}
if (mobile.quickUBB.code[key].hasOwnProperty("L")) {
text = mobile.quickUBB.code[key]['L'] + text + mobile.quickUBB.code[key]['R'];
}
$jq("#needmessage").insertAtCaret(text);
/*
if (mobile.quickUBB.code[key]["tagL"] != undefined || mobile.quickUBB.code[key]["tagR"] != undefined) {
$jq("#needmessage").moveCursorInCenterByText(mobile.quickUBB.code[key]["tagL"], mobile.quickUBB.code[key]["tagR"]);
}*/
if (mobile.quickUBB.code[key].hasOwnProperty("cursorL")) {
$jq("#needmessage").moveCursorToCenterByTextWithLeft(mobile.quickUBB.code[key]["cursorL"], mobile.quickUBB.code[key]["cursorLength"]);
}
if (mobile.quickUBB.code[key].hasOwnProperty("cursorR")) {
$jq("#needmessage").moveCursorToCenterByTextWithRight(mobile.quickUBB.code[key]["cursorR"], mobile.quickUBB.code[key]["cursorLength"]);
}
})
});
},
set_rainbow: (num, text) => {
if (text == "") {
return '';
}
var wr_text = text;
var wr_code, wr_rgb, r, g, b, i, j, istep
var wr_rgb1, wr_rgb2, r1, g1, b1, r2, g2, b2
r1 = g1 = b1 = r2 = g2 = b2 = 0;
r = 0;
g = 0;
b = 0;
istep = 0;
wr_code = '';
if (num == 1) {
istep = 40;
r = 255;
i = 1;
j = 0;
do {
if (wr_text.charCodeAt(j) != 32) {
if (g + istep < 256) {
if (i == 1) g += istep;
} else if (i == 1) {
i = 2;
g = 255;
}
if (r - istep > -1) {
if (i == 2) r -= istep;
} else if (i == 2) {
i = 3;
r = 0;
}
if (b + istep < 256) {
if (i == 3) b += istep;
} else if (i == 3) {
i = 4;
b = 255;
}
if (g - istep > -1) {
if (i == 4) g -= istep;
} else if (i == 4) {
i = 5;
g = 0;
}
if (r + istep < 256) {
if (i == 5) r += istep;
} else if (i == 5) {
i = 6;
r = 255;
}
if (b - istep > -1) {
if (i == 6) b -= istep;
} else if (i == 6) {
i = 1;
b = 0;
}
wr_rgb = '';
wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(j) + '[/color]';
} else {
wr_code += wr_text.charAt(j);
}
j++;
} while (j < wr_text.length);
} else if (num == 2) {
istep = 255 / wr_text.length;
for (i = 1; i < wr_text.length + 1; i++) {
if (wr_text.charCodeAt(i - 1) != 32) {
r += istep;
g += istep;
b += istep;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
wr_rgb = '';
wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(i - 1) + '[/color]';
} else {
wr_code += wr_text.charAt(i - 1);
}
}
} else if (num == 3) {
istep = 255 / wr_text.length;
for (i = 1; i < wr_text.length + 1; i++) {
if (wr_text.charCodeAt(i - 1) != 32) {
r += istep;
g = 29;
b = 36;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
wr_rgb = '';
wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(i - 1) + '[/color]';
} else {
wr_code += wr_text.charAt(i - 1);
}
}
} else if (num == 4) {
istep = 255 / wr_text.length;
for (i = 1; i < wr_text.length + 1; i++) {
if (wr_text.charCodeAt(i - 1) != 32) {
r = 0;
g = 174;
b += istep;
if (r > 255) r = 255;
if (g > 255) g = 255;
if (b > 255) b = 255;
wr_rgb = '';
wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
wr_rgb += parseInt(255 - b).toString(16).length == 1 ? 0 + parseInt(255 - b).toString(16) : parseInt(255 - b).toString(16);
wr_rgb = wr_rgb.toUpperCase();
wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(i - 1) + '[/color]';
} else {
wr_code += wr_text.charAt(i - 1);
}
}
}
return wr_code;
},
jqueryExtraFunction: () => {
$jq.fn.extend({
insertAtCaret: function (myValue) {
var $t = $jq(this)[0];
if (document.selection) {
this.focus();
var sel = document.selection.createRange();
sel.text = myValue;
this.focus();
} else
if ($t.selectionStart || $t.selectionStart == '0') {
var startPos = $t.selectionStart;
var endPos = $t.selectionEnd;
var scrollTop = $t.scrollTop;
$t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
this.focus();
$t.selectionStart = startPos + myValue.length;
$t.selectionEnd = startPos + myValue.length;
$t.scrollTop = scrollTop;
} else {
this.value += myValue;
this.focus();
}
},
selectRange: function (start, end) {
if (end === undefined) {
end = start;
}
return this.each(function () {
if ('selectionStart' in this) {
this.selectionStart = start;
this.selectionEnd = end;
} else if (this.setSelectionRange) {
this.setSelectionRange(start, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', start);
range.select();
}
});
},
getCursorPosition: function () {
var el = $jq(this)[0];
var pos = 0;
if ('selectionStart' in el) {
pos = el.selectionStart;
} else if ('selection' in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
Sel.moveStart('character', -el.value.length);
pos = Sel.text.length - SelLength;
}
return pos;
},
moveCursorInCenterByText: function (leftTextFlag, rightTextFlag) {
var el = $jq(this)[0];
var el_text = el.value;
for (let i = el.selectionStart - 1; i > 0; i--) {
let LText = el_text[i - 1];
let currentText = el_text[i];
if (LText == leftTextFlag && currentText == rightTextFlag) {
this.selectRange(i);
break;
}
}
},
moveCursorToCenterByTextWithLeft: function (leftMatchText, _length_) {
var el = $jq(this)[0];
var el_text = el.value;
for (let i = el.selectionStart - 1; i > 0; i--) {
let lTexts = el_text.substring(i - _length_, i);
if (lTexts == leftMatchText) {
this.selectRange(i);
break;
}
}
},
moveCursorToCenterByTextWithRight: function (rightMatchText, _length_) {
var el = $jq(this)[0];
var el_text = el.value;
for (let i = el.selectionStart - 1; i > 0; i--) {
let rTexts = el_text.substring(i, i + _length_);
if (rTexts == rightMatchText) {
this.selectRange(i + _length_);
break;
}
}
}
});
}
},
recoveryIMGWidth() {
/* 修复图片宽度 */
if (GM_getValue("v16") && window.location.href.match(mt_config.rexp.forum_post)) {
GM_addStyle(`
.comiis_messages img{
max-width: 100% !important;
}
`)
}
},
removeForumPostCommentFontStyle() {
/* 移除评论区字体效果 */
if (GM_getValue("v3") && window.location.href.match(mt_config.rexp.forum_post)) {
var hide = document.getElementsByTagName('font');
var postForumMain = document.querySelector(".comiis_ordertype") ? document.querySelector(".comiis_postlist.kqide .comiis_postli").innerHTML : '';
for (let i = 0; i < hide.length; i++) {
if (postForumMain.indexOf(hide[i].innerHTML) == -1) {
console.log(hide[i].innerHTML);
hide[i].removeAttribute('color');
hide[i].removeAttribute('style');
hide[i].removeAttribute('size');
}
}
var content = document.getElementsByClassName("comiis_message bg_f view_all cl message");
for (let i = 0; i < content.length; i++) {
if (postForumMain.indexOf(content[i].innerHTML) == -1) {
content[i].innerHTML = content[i].innerHTML.replace(mt_config.rexp.font_special, '');
}
}
}
},
removeForumPostFontStyle() {
/* 移除帖子内的字体style */
if (GM_getValue("v1") && window.location.href.match(mt_config.rexp.forum_post)) {
if ($jq(".comiis_a.comiis_message_table.cl").eq(0).html()) {
$jq(".comiis_a.comiis_message_table.cl").eq(0).html($jq(".comiis_a.comiis_message_table.cl").eq(0).html().replace(mt_config.rexp.font_special, ''));
}
}
},
repairClearSearchInput() {
/* 修复搜索的清空按钮 */
if (GM_getValue("v36") && window.location.href.match(mt_config.rexp.search_url)) {
let $search_input = $jq(".ssclose.bg_e.f_e");
if ($search_input) {
$search_input.click(function (e) {
e.preventDefault();
$jq("#scform_srchtxt").val("")
})
} else {
log.error("搜索界面: 获取清空按钮失败");
}
}
},
repairUnableToEnterOtherSpaceCorrectly() {
/* 修复无法正确进入别人的空间 */
if (!GM_getValue("v37")) {
return;
};
if (window.location.href.match(mt_config.rexp.home_url_brief)) {
let href_params = window.location.href.match(/home.php\?(.+)/gi);
href_params = href_params[href_params.length - 1];
let params_split = href_params.split("&");
if (params_split.length == 2 && href_params.indexOf("uid=") != -1 && href_params.indexOf("mod=space") != -1) {
window.location.href = window.location.href + "&do=profile";
}
}
if (window.location.href.match(mt_config.rexp.home_url_at)) {
let href_params = window.location.href.match(/space-uid-(.+).html/i);
href_params = href_params[href_params.length - 1];
window.location.href = `https://bbs.binmt.cc/home.php?mod=space&uid=${href_params}&do=profile`;
}
},
searchHistory() {
/* 搜索历史 */
if (GM_getValue("v19") && location.href.match(mt_config.rexp.search_url)) {
function search_event() {
/* 搜索历史事件 */
/* 搜索界面增加关闭按钮事件,清空input内容 */
/* 点击搜索保存搜索记录 */
$jq("#scform_submit").click(function () {
let getsearchtext = $jq("#scform_srchtxt").val();
if ((getsearchtext != null) && (getsearchtext != "")) {
let search_history_array = new Array(getsearchtext);
let has_history = GM_getValue("search_history");
if (has_history != null) {
if ($jq.inArray(getsearchtext, has_history) != -1) {
console.log("已有该搜索历史记录")
search_history_array = has_history
} else {
console.log("无该记录,追加");
search_history_array = search_history_array.concat(has_history);
}
} else {
console.log("空记录,添加")
}
GM_setValue("search_history", search_history_array);
}
})
}
function add_search_history() {
/* 搜索界面添加搜索历史记录 */
$jq("#scform_srchtxt").attr("list", "search_history");
var search_history_list = GM_getValue("search_history");
var dom_datalist = document.createElement("datalist");
dom_datalist.id = "search_history";
var option_text = "";
if (search_history_list) {
for (var i = 0; i < search_history_list.length; i++) {
option_text = option_text + '
';
}
dom_datalist.innerHTML = option_text;
$jq(".comiis_flex").append(dom_datalist);
}
}
function add_clear_history() {
/* 搜索界面添加清理历史记录和历史记录个数 */
let search_history_list = GM_getValue("search_history");
let search_history_nums = 0;
if (search_history_list != null) {
search_history_nums = search_history_list.length;
}
let clear_history_innerHTML =
`搜索记录个数: ` +
search_history_nums +
`清理记录
`;
let insertdom = $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_search_history();
add_clear_history();
}
},
selectPostingSection() {
/* 在发帖/编辑帖子时选择发帖板块 */
if (!window.location.href.match(mt_config.rexp.post_forum) &&
!window.location.href.match(mt_config.rexp.edit_forum)) {
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.rexp.post_forum)) {
/* 发帖 */
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": `
请选择
BUG反馈
意见反馈
论坛问题
已解决 `
},
"站务专区": {
"className": "gm_user_select_depot",
"optionHTML": `
请选择
版主申请
职位调整 `
}
}
if (classifyClassNameDict[section_dict[fid]]) {
if ($jq(".comiis_post_from .styli_tit:contains('分类')").length) {
$jq(".comiis_post_from .styli_tit:contains('分类')").parent().remove();
}
$jq(".comiis_stylino.comiis_needmessage").before($jq(`
分类
`));
} else {
Object.keys(classifyClassNameDict).forEach(function (key) {
$jq(".comiis_post_from ." + classifyClassNameDict[key]["className"]).remove();
})
}
$jq('#postform').attr('action', postSection);
});
} else {
selectNode.attr("disabled", true);
}
selectNode.val(currentSection).trigger('change');
},
shieldPlate() {
/* 屏蔽板块 */
if (window.location.href.match(mt_config.rexp.forum_guide_url)) {
let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li");
let black_list = GM_getValue("blacklistplate") || "";
let black_list_array = black_list.split("、");
Array.from(infos).forEach((info) => {
let from_plate = (info.querySelector(".forumlist_li_time a.f_d") || info.querySelector(".comiis_xznalist_bk.cl")).outerText;
from_plate = from_plate.replace(//g, "");
from_plate = from_plate.replace(/\s*/g, "");
from_plate = from_plate.replace("来自", "");
if (black_list_array.indexOf(from_plate) != -1) {
console.log("屏蔽目标板块:" + from_plate);
info.setAttribute("style", "display:none !important;");
}
})
}
},
shieldUser() {
/* 屏蔽用户 */
if (window.location.href.match(mt_config.rexp.forum_guide_url) ||
window.location.href.match(mt_config.rexp.plate_url) ||
window.location.href.match(mt_config.rexp.forum_post)) {
let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li"); /* 帖子外 */
if (!infos.length) {
/* 帖子内 */
infos = document.querySelectorAll(".comiis_postlist .comiis_postli");
if (!infos.length) {
return;
}
}
let black_list = GM_getValue("blacklistuid") ? GM_getValue("blacklistuid") : "";
let black_list_array = black_list.split(",");
Array.from(infos).forEach((info) => {
let usr = info.getElementsByClassName("wblist_tximg");
if (!usr.length) {
usr = info.getElementsByClassName("postli_top_tximg");
if (!usr.length) {
return;
}
}
usr = usr[0].href;
let usr_uid = usr.match(mt_config.rexp.mt_uid)[1];
if (black_list_array.indexOf(usr_uid) != -1) {
console.log("屏蔽用户:" + usr_uid);
info.setAttribute("style", "display:none !important;");
}
})
}
},
showSignInRanking() {
/* 显示签到的最先几个人,最多10个,和顶部的今日签到之星 */
if (window.location.href.match(mt_config.rexp.k_misign_sign)) {
let today_ranking_ele = document.querySelector(".comiis_topnv .comiis_flex .flex");
today_ranking_ele.after($jq(`
今日最先 `)[0]);
let getMaxPage = (urlextra) => {
return new Promise(res => {
GM_xmlhttpRequest({
url: "https://bbs.binmt.cc/k_misign-sign.html?operation=" + urlextra,
async: false,
responseType: 'html',
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
},
onload: function (resp) {
let last_page = $jq(resp.responseText).find("#J_list_detail .pg span");
if (last_page.length && typeof last_page[0].title != "undefined") {
let last_page_match = last_page[0].title.match(/([0-9]+)/);
if (last_page_match.length == 2) {
res(last_page_match[last_page_match.length - 1]);
} else {
popup2.toast("获取页失败");
res(0);
}
} else {
popup2.toast("请求最先签到的页失败");
res(0);
}
},
onerror: function (resp) {
console.log(resp);
popup2.toast("网络异常,请重新获取");
res(0);
}
})
})
}
let getPagePeople = (page) => {
return new Promise(res => {
GM_xmlhttpRequest({
url: "https://bbs.binmt.cc/k_misign-sign.html?operation=list&op=&page=" + page,
async: false,
responseType: 'html',
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
},
onload: function (resp) {
let peoples = $jq(resp.responseText).find("#J_list_detail tbody tr");
let ret_array = [];
if (peoples.length == 2 && peoples[0].textContent.indexOf("暂无内容") != -1) {
res(ret_array);
return;
}
for (let i = 1; i <= peoples.length - 2; i++) {
let people = peoples[i];
let ret_json = {};
let user_name = people.children[0].getElementsByTagName("a")[0].textContent;
let space_url = people.children[0].getElementsByTagName("a")[0].href;
let uid = space_url.match(/space-uid-([0-9]*)/)[1];
let sign_all_days = people.children[1].textContent;
let sign_month_days = people.children[2].textContent;
let sign_time = people.children[3].textContent;
let sign_reward = people.children[5].textContent;
ret_json["user"] = user_name;
ret_json["uid"] = uid;
ret_json["avatar"] = "https://avatar-bbs.mt2.cn/uc_server/avatar.php?uid=" + uid + "&size=small";
ret_json["days"] = sign_all_days;
ret_json["monthDays"] = sign_month_days;
ret_json["time"] = sign_time;
ret_json["reward"] = sign_reward;
ret_array = ret_array.concat(ret_json);
}
res(ret_array)
},
onerror: function (resp) {
console.log(resp);
res({});
}
})
})
}
function changeRankList(data, listtype) {
$jq("#ranklist").html(data);
$jq('#ranklist').attr('listtype', listtype);
}
ajaxlist = async (listtype) => {
listtype = listtype;
if (listtype == 'today') {
loadingdelay = false;
urlextra = 'list&op=today';
} else if (listtype == 'month') {
loadingdelay = false;
urlextra = 'list&op=month';
} else if (listtype == 'zong') {
loadingdelay = false;
urlextra = 'list&op=zong';
} else if (listtype == 'calendar') {
loadingdelay = true;
urlextra = 'calendar';
} else {
loadingdelay = false;
urlextra = 'list';
}
/* alert(loadingdelay); */
if (listtype == 'todayLatest') {
loadingdelay = false;
urlextra = 'list&op=&page=0';
let maxPage = await getMaxPage(urlextra);
if (maxPage == 0) {
return
};
let latestPeople = await getPagePeople(maxPage);
latestPeople.reverse();
if (latestPeople.length < 10) {
let latestPeople_2 = await getPagePeople(maxPage - 1);
latestPeople_2.reverse();
latestPeople = latestPeople.concat(latestPeople_2);
latestPeople.reverse();
}
let peopleHTML = '';
latestPeople.reverse();
console.log(latestPeople);
latestPeople.forEach(people => {
peopleHTML = peopleHTML + `
` + people["user"] + ` ` + people["time"] + ` 总天数 ` + people["days"] + `天
月天数 ` + people["monthDays"] + ` 天
,
上次奖励
` + people["reward"] + `
`
})
let latestHTML = `
`
changeRankList(latestHTML, listtype)
} else {
$jq.ajax({
type: 'GET',
url: "plugin.php?id=k_misign:sign&operation=" + urlextra,
async: false,
dataType: 'html',
success: function (data) {
/* console.log(data); */
data = data.replace(`今日排行`, `今日排行
今日最先 `);
changeRankList(data, listtype);
},
complete: function (XHR, TS) {
XHR = null
}
});
}
}
}
},
showTodayStar() {
/* 显示今日之星,在签到页上 */
if (GM_getValue("v33") && window.location.href.match(mt_config.rexp.k_misign_sign)) {
let todayStarParent = $jq(".pg_k_misign .comiis_qdinfo");
let todayStar = document.createElement("ul");
GM_xmlhttpRequest({
url: "/k_misign-sign.html",
method: 'get',
async: false,
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
},
onload: (r) => {
let html = $jq(r.responseText);
let todatastarele = html.find("#pt span.xg1");
if (!todatastarele.length) {
return;
}
let todaypeople = todatastarele[0].textContent.replace("今日签到之星:", '');
todayStar.innerHTML = '
今日签到之星 ' + todaypeople + '';
let comiis_space_box_height = getComputedStyle($jq(".comiis_space_box")[0], null)["height"].replace("px", "");
let comiis_space_box_padding_bottom = getComputedStyle($jq(".comiis_space_box")[0], null)["padding-bottom"].replace("px", "");
comiis_space_box_height = parseInt(comiis_space_box_height);
comiis_space_box_padding_bottom = parseInt(comiis_space_box_padding_bottom);
let total_height = comiis_space_box_height + comiis_space_box_padding_bottom + 50;
GM_addStyle(`
.comiis_space_box{
height: ${total_height}px;
background-size: 100% 100%;
}
.pg_k_misign .comiis_qdinfo{
height: 110px !important;
}`);
todayStarParent.append(todayStar);
},
onerror: (r) => {
console.log(r);
log.error("请求今日之星失败");
}
})
}
},
showUserUID() {
/* 显示用户的uid */
if (GM_getValue("v15") &&
((window.location.href.match(mt_config.rexp.forum_post_guide_url) ||
(window.location.href.match(mt_config.rexp.forum_post)) ||
(window.location.href.match(mt_config.rexp.plate_url)) ||
(window.location.href.match(mt_config.rexp.search_url)) ||
window.location.href.match(/bbs.binmt.cc\/home.php\?mod=space&do=thread&view=me/) ||
window.location.href.match(/home.php\?mod=space&uid=.+&do=thread&view=me/)
))) {
if (!window.GM_isaddShowUidCss) {
window.GM_isaddShowUidCss = true;
GM_addStyle(`
.postli_top_tximg + h2{
height: auto;
}
`);
}
window.findUserFormList = false;
window.findUserFormListNums = 0;
let findSetInval = setInterval(function () {
let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : [];
formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList;
formList = formList.length == 0 ? mt_config.dom_obj.comiis_mmlist() : formList;
window.findUserFormList = formList.length ? true : false;
if (findUserFormListNums >= 16) {
console.log("已循环16次,未找到帖子");
clearInterval(findSetInval);
}
if (window.findUserFormList) {
GM_addStyle(`
.comiis_postli_top.bg_f.b_t h2{
height: auto;
}`);
function matchUIDByArray(data) {
for (let i = 0; i < data.length; i++) {
let url = data[i].href;
let uid = url.match(mt_config.rexp.mt_uid);
if (uid) {
return uid[1];
}
}
return null
}
$jq.each(formList, (index, value) => {
let mtUIDOM = value.getElementsByClassName("mt_uid_set");
if (!mtUIDOM.length) {
let childrenByATagetElement = value.getElementsByTagName("a");
let mt_uid = null;
mt_uid = matchUIDByArray(childrenByATagetElement);
if (mt_uid != null) {
let uid_control = document.createElement("a");
let mtUidDomInsertElement = value.getElementsByClassName("top_lev")[0];
let uid_control_height = getComputedStyle(mtUidDomInsertElement, null)["height"];
let uid_control_margin = getComputedStyle(mtUidDomInsertElement, null)["margin"];
let uid_control_padding = getComputedStyle(mtUidDomInsertElement, null)["padding"];
let uid_control_line_height = getComputedStyle(mtUidDomInsertElement, null)["line-height"];
let uid_control_font = getComputedStyle(mtUidDomInsertElement, null)["font"];
let uid_control_bg_color = "#FF7600";
uid_control.className = "mt_uid_set";
uid_control.style = `
font: ${uid_control_font};
background: ${uid_control_bg_color};
color: white;
float: left;
margin: ${uid_control_margin};
padding: ${uid_control_padding};
height: ${uid_control_height};
line-height: ${uid_control_line_height};
border-radius: 1.5px;`;
uid_control.innerHTML = "UID:" + mt_uid;
uid_control.onclick = function () {
try {
GM_setClipboard(mt_uid);
popup2.toast(`${mt_uid}已复制`);
console.log("复制:", mt_uid)
} catch (err) {
popup2.toast(`${mt_uid}复制失败`);
console.log("复制失败:" + mt_uid, err);
}
}
mtUidDomInsertElement.parentElement.append(uid_control);
}
}
})
console.log("成功找到帖子DOM");
clearInterval(findSetInval);
} else {
findUserFormListNums += 1;
}
}, 800)
}
},
userCheckBoxSettings() {
/* 侧边栏配置项 */
function checkboxNode() {
return $jq(".whitesevcheckbox");
}
function selectedNodeText() {
let selectedVal = selectNode().val();
return $jq(`.beauty-select option[value='${selectedVal}']`).text();
}
function selectNode() {
return $jq(".beauty-select");
}
function setCodeNodeCheckedStatus(status) {
/* 设置 开关的状态 */
status ? checkboxNode().removeClass("comiis_checkbox_close") : checkboxNode().addClass("comiis_checkbox_close");
}
function setLastClickItem() {
/* 初始化设置上次点击的select内容 */
let selectNodeNormalVal = GM_getValue("last") == null ? "v2" : GM_getValue("last");
selectNode().val(selectNodeNormalVal);
setCodeNodeCheckedStatus(GM_getValue(selectNodeNormalVal) != null ? true : false);
}
function setSelectNodeChangeEvent() {
/* 设置选项的change事件 */
selectNode().change(function () {
let selected_value = $jq('.beauty-select').val();
GM_setValue("last", selected_value);
let check_value = GM_getValue(selected_value) != null ? true : false;
setCodeNodeCheckedStatus(check_value);
});
}
function setCodeNodeClickEvent() {
/* 设置开关的click事件 */
checkboxNode().on("click", (e) => {
let selected_value = selectNode().val();
let check_value = GM_getValue(selected_value) != null ? false : true;
check_value ? GM_setValue(selected_value, true) : GM_deleteValue(selected_value);
let showText = check_value ? '设置-开启' : '设置-关闭';
popup2.toast(showText);
setCodeNodeCheckedStatus(check_value);
})
}
function setSelectNodeCSS() {
GM_addStyle(`
.beauty-select{
background-color: #fff;
height:28px;
width: 160px;
line-height:28px;
border: 1px solid #ececec;
background: url(w.png) no-repeat;
background-position: 95% 50%;
-webkit-appearance: none; /*去掉样式 for chrome*/
appearance:none;/*去掉样式*/
-moz-appearance:none;/*去掉样式*/
}`);
}
if (window.location.href.match(mt_config.rexp.bbs)) {
var setting_content = document.createElement("li");
setting_content.className = "comiis_left_Touch";
setting_content.innerHTML = '
' +
'识别链接<\/option>' +
' 自动签到<\/option>' +
' 自动展开帖子<\/option>' +
' 自适应帖子内图片的宽度<\/option>' +
' 显示用户的UID<\/option>' +
' 显示搜索历史<\/option>' +
' 移除帖子字体效果<\/option>' +
' 移除评论区字体效果<\/option>' +
' 评论区开启点评<\/option>' +
' 自动加载上一页评论<\/option>' +
' 自动加载下一页评论<\/option>' +
' 小黑屋<\/option>' +
' 今日签到之星<\/option>' +
' 帖外预览图片<\/option>' +
' 修复搜索的清空按钮<\/option>' +
' 修复无法正确进入别人的空间<\/option>' +
' 聊天内图床<\/option>' +
' 付费主题白嫖提醒<\/option>' +
' 页面小窗浏览帖子<\/option>' +
' 代码块上方新增复制按钮<\/option>' +
' 蓝奏云功能<\/option>' +
' 编辑器优化-快捷<\/option>' +
' 编辑器优化-完整<\/option>' +
'<\/select>' +
'
' +
'<\/div>';
/* Array.from(document.querySelectorAll(".comiis_myinfo_list.bg_f.cl")).forEach((ele) => {
if (ele.innerText.match(/风格配色|夜间模式|最近访客|改名申请|手机绑定设置/)) {
ele.appendChild(setting_content);
return;
}
}) */
GM_addStyle(`
.comiis_sidenv_box ul.comiis_left_Touch.bdew li:nth-last-child(1) {
margin-bottom: 10px;
}
`);
$jq(".comiis_sidenv_box .sidenv_li .comiis_left_Touch.bdew").append(setting_content);
tryCatch(setSelectNodeCSS);
tryCatch(setLastClickItem);
tryCatch(setCodeNodeClickEvent);
tryCatch(setSelectNodeChangeEvent);
/* tryCatch(loadCheckboxTipResource); */
}
},
}
function Hooks() {
/* hook?用不到 */
return {
initEnv: function () {
Function.prototype.hook = function (realFunc, hookFunc, context) {
var _context = null; /* 函数上下文 */
var _funcName = null; /* 函数名 */
_context = context || window;
_funcName = getFuncName(this);
_context['realFunc_' + _funcName] = this;
console.log(window);
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
console.log("Already has been hooked,unhook first");
return false;
}
function getFuncName(fn) {
/* 获取函数名 */
var strFunc = fn.toString();
var _regex = /function\s+(\w+)\s*\(/;
var patten = strFunc.match(_regex);
if (patten) {
return patten[1];
};
return '';
}
try {
eval('_context[_funcName] = function ' + _funcName + '(){\n' +
'var args = Array.prototype.slice.call(arguments,0);\n' +
'var obj = this;\n' +
'hookFunc.apply(obj,args);\n' +
"return _context['realFunc_" + _funcName + "'].apply(obj,args);\n" +
'};');
_context[_funcName].prototype.isHooked = true;
return true;
} catch (e) {
console.log("Hook failed,check the params.");
return false;
}
}
Function.prototype.unhook = function (realFunc, funcName, context) {
var _context = null;
var _funcName = null;
_context = context || window;
_funcName = funcName;
if (!_context[_funcName].prototype.isHooked) {
console.log("No function is hooked on");
return false;
}
_context[_funcName] = _context['realFunc' + _funcName];
delete _context['realFunc_' + _funcName];
return true;
}
},
cleanEnv: function () {
if (Function.prototype.hasOwnProperty("hook")) {
delete Function.prototype.hook;
}
if (Function.prototype.hasOwnProperty("unhook")) {
delete Function.prototype.unhook;
}
return true;
}
};
}
function entrance() {
/* 这是入口 */
var UA = navigator.userAgent.match(mt_config.rexp.pc_useragent);
if (UA != null) {
tryCatch(pc.repairPCNoLoadResource);
$jq(document).ready(function () {
tryCatch(pc.main);
});
} else {
$jq(document).ready(function () {
tryCatch(mobile.main);
})
}
};
if (envCheck()) {
$jq(document).ready(function () {
entrance();
console.log(`执行完毕,耗时${Date.now()-mt_config.GMRunStartTime}ms`);
});
}
})();