// ==UserScript== // @name 编程猫使用优化 // @namespace https://shequ.codemao.cn/user/438403 // @version 1.45.268 // @description 对于在使用编程猫中遇到的各种问题的部分优化 // @author 小鱼yuzifu // @match *://shequ.codemao.cn/* // @icon https://static.codemao.cn/coco/player/unstable/B1F3qc2Hj.image/svg+xml?hash=FlHXde3J3HLj1PtOWGgeN9fhcba3 // @grant GM_xmlhttpRequest // @require https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/sweetalert/2.1.2/sweetalert.min.js // @require https://fastly.jsdelivr.net/npm/lil-gui@0.16 // @require https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/tldjs/2.3.1/tld.min.js // @require https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/viewerjs/1.10.4/viewer.min.js // @require https://greasyfork.org/scripts/465118-librarycomment/code/libraryComment.js?version=1229105 // @license 616 SB License // @downloadURL none // ==/UserScript== (function () { "use strict"; if (window.location.href.indexOf("writer") != -1) { return false; } if (window.location.href.indexOf("publish") != -1) { let publish_on = setInterval(() => { if (window.location.href.indexOf("publish") == -1) { window.location.reload(); clearInterval(publish_on); } }, 100); return false; } function titleChange(content) { if (document.querySelector("title") && document.querySelector("title").innerHTML != content) { document.querySelector("title").innerHTML = content; } } // 白名单 let whiteList = ["box3.codemao.cn", "pickduck.cn", "shequ.codemao.cn", "player.codemao.cn", "static.yuzifu.top", "blog.yzf.moe", "player.bilibili.com", "bcmcreator.cn"]; // 感谢刘andy提供的代码awa unsafeWindow._dangerouslyOpenNewWindow = unsafeWindow.open; unsafeWindow.openurl = (url) => { // console.log("捕获"); if ((url.includes("community") || url.includes("wiki/forum")) && (parseInt(url.split("/")[2]) || parseInt(url.split("/")[3]))) { // console.log("发现为帖子"); let id = ""; if (url.includes("community")) { id = url.split("/")[2]; } else { id = url.split("/")[3]; } // console.log(id); $.ajax({ type: "GET", url: `https://api.codemao.cn/web/forums/posts/${id}/details`, contentType: "application/json;charset=UTF-8", async: true, xhrFields: { withCredentials: true, }, success: function (obj) { let a = document.createElement("div"); a.innerHTML = obj.content; // console.log(a); if (a.querySelector("iframe,embed")) { for (let i of a.querySelectorAll("iframe,embed")) { // console.log(i.getAttribute("src"), tldjs.parse(i.getAttribute("src")).hostname); if (i.getAttribute("src") && !whiteList.includes(tldjs.parse(i.getAttribute("src")).hostname)) { if (i.getAttribute("src").indexOf("https://static.codemao.cn/yuque/preview/") === 0) { $.ajax({ type: "GET", url: i.getAttribute("src"), async: true, success: function (obj) { let a = document.createElement("div"); a.innerHTML = obj; if (a.querySelector("script:not(script[src])").innerHTML.includes("viewer.setDocument")) { return unsafeWindow._dangerouslyOpenNewWindow(url); } else { swal({ title: "危险", text: "即将访问的帖子存在风险!", icon: "error", dangerMode: true, buttons: { visit: "继续访问(不推荐)", danger: "立即退出(推荐)" }, }).then((x) => { if (x == "visit") { swal({ title: "警告", text: "您真的要继续访问吗?", dangerMode: true, buttons: { visit: "继续访问(不推荐)", danger: "立即退出(推荐)" }, }).then((x) => { if (x == "visit") { return unsafeWindow._dangerouslyOpenNewWindow(url); } return null; }); document.querySelector(".swal-button-container:last-child button").focus(); } return null; }); document.querySelector(".swal-button-container:last-child button").focus(); } }, }); } else { swal({ title: "危险", text: "即将访问的帖子存在风险!", icon: "error", dangerMode: true, buttons: { visit: "继续访问(不推荐)", danger: "立即退出(推荐)" }, }).then((x) => { if (x == "visit") { swal({ title: "警告", text: "您真的要继续访问吗?", dangerMode: true, buttons: { visit: "继续访问(不推荐)", danger: "立即退出(推荐)" }, }).then((x) => { if (x == "visit") { return unsafeWindow._dangerouslyOpenNewWindow(url); } return null; }); document.querySelector(".swal-button-container:last-child button").focus(); } return null; }); document.querySelector(".swal-button-container:last-child button").focus(); } } else { return unsafeWindow._dangerouslyOpenNewWindow(url); } } } else { return unsafeWindow._dangerouslyOpenNewWindow(url); } }, error: function (res) { swal({ title: "警告", text: "无法甄别即将访问的帖子是否危险!", icon: "warning", buttons: { visit: "暂不访问", danger: "继续访问" }, closeOnClickOutside: false, }).then((x) => { if (x == "danger") { return unsafeWindow._dangerouslyOpenNewWindow(url); } return null; }); // console.log(res.responseJSON); }, }); } else { // console.log("catched go"); return unsafeWindow._dangerouslyOpenNewWindow(url); } }; unsafeWindow.open = unsafeWindow.openurl; $("head").append( ` ` ); if (!document.querySelector('meta[name="theme-color"]')) { $("head").append(``); } setInterval(() => { //尝试制作防劫持 if ( window.location.href.indexOf("message") != -1 || ((window.location.href.indexOf("community") != -1 || window.location.href.indexOf("wiki/forum/") != -1) && parseInt(window.location.href.slice(25 + 11)) && document.querySelector("iframe")) || window.location.href.indexOf("reader") != -1 ) { var iframes = document.querySelectorAll("iframe"); for (var i = 0; i < iframes.length; i++) { if (!whiteList.includes(tldjs.getDomain(iframes[i].getAttribute("src")))) { iframes[i].style.position = "inherit"; if (!iframes[i].getAttribute("sandbox") && iframes[i] != document.querySelector(".mce-edit-area iframe")) { iframes[i].setAttribute("sandbox", "allow-forms allow-scripts allow-same-origin allow-popups"); iframes[i].setAttribute("src", "https://static.yuzifu.top/bcm/iframe.php?url=" + iframes[i].getAttribute("src")); } } } var embeds = document.querySelectorAll("embed"); for (i = 0; i < embeds.length; i++) { if (!whiteList.includes(tldjs.getDomain(embeds[i].getAttribute("src")))) { var embed_to_iframe = document.createElement("iframe"); embed_to_iframe.style.width = embeds[i].style.width; embed_to_iframe.style.height = embeds[i].style.height; embed_to_iframe.setAttribute("src", embeds[i].getAttribute("src")); embeds[i].parentNode.replaceChild(embed_to_iframe, embeds[i]); } } } }, 10); setInterval(() => { GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/creation-tools/v1/user/center/honor", data: document.cookie, binary: true, onload({ response }) { localStorage.setItem("twikoo", `{"nick":"${JSON.parse(response).nickname}","mail":"","link":"${"https://shequ.codemao.cn/user/" + JSON.parse(response).user_id}"}`); }, }); try { if (window.location.href.indexOf("community") != -1 || window.location.href.indexOf("wiki/forum") != -1) { titleChange("论坛 | 编程猫社区"); } if (window.location.href.indexOf("work_shop") != -1) { if (parseInt(window.location.href.slice(25 + 10)) && document.querySelector(".r-work_shop-r-details--details_wrap .r-work_shop-r-details--header_cont .r-work_shop-r-details--title p")) { titleChange("工作室 | " + document.querySelector(".r-work_shop-r-details--details_wrap .r-work_shop-r-details--header_cont .r-work_shop-r-details--title p").innerHTML + " | 编程猫社区"); if (document.querySelector(".c-model_box--show:not(.target,.abc) .r-work_shop-r-details-component-project_dialog--project_box_wrap")) { document.querySelector(".c-model_box--show:not(.target)").classList.add("target"); document.querySelector(".c-model_box--show .r-work_shop-r-details-component-project_dialog--project_box_wrap").classList.add("target"); $(".c-model_box--show .r-work_shop-r-details-component-project_dialog--project_box_wrap").after("
"); $(".c-model_box--show .r-work_shop-r-details-component-project_dialog--project_box_wrap.target").remove(); $(".c-model_box--show .r-work_shop-r-details-component-project_dialog--project_box_wrap").append( `隐藏未发布的
"); $(copymefuck).before(`原作品ID:${JSON.parse(response).id}
`); $(".pubornot").on("click", function () { if (document.querySelector(".pubornot").id == "hidenotpub") { $('tr[published="0"]').css("display", "none"); document.querySelector(".swal-title").innerHTML = "有" + document.querySelectorAll('tr[published="1"]').length + "个再创作并发布的了!"; document.querySelector(".pubornot").id = "shownotpub"; document.querySelector(".pubornot").innerHTML = "显示未发布的"; } else { $('tr[published="0"]').css("display", ""); document.querySelector(".swal-title").innerHTML = "有" + s[0].length + "个再创作了!"; document.querySelector(".pubornot").id = "hidenotpub"; document.querySelector(".pubornot").innerHTML = "隐藏未发布的"; } }); } else { swal({ title: "好耶!", text: "目前没有人再创作并发布此作品!", icon: "success", }); } } }, }); } else { swal({ title: "错误", text: "请输入作品ID!", icon: "error", }); } } }); }); $("#username-btn").on("click", () => { var inputment = document.createElement("input"); inputment.className = "swal-content__input"; swal({ title: "请输入你要更改的登录用户名", text: "这个用户名将作为你的登录账号使用", content: inputment, }).then((value) => { if (value) { if (inputment.value != "") { swal({ title: "警告", text: `你的用户名是:${inputment.value}\n这里作再三强调,只能修改一次\n你确定吗?`, icon: "warning", dangerMode: true, buttons: true, }).then((value) => { if (value) { $.ajax({ type: "PATCH", url: "https://api.codemao.cn/tiger/v3/web/accounts/username", contentType: "application/json;charset=UTF-8", data: JSON.stringify({ username: inputment.value, }), dataType: "json", xhrFields: { withCredentials: true, }, success: function () { swal({ title: "成功", text: `你现在的用户名是:${inputment.value}\n以后你就可以用这个来登录你的编程猫账号了!`, icon: "success", }); }, error: function (res) { swal({ title: "错误", text: res.responseJSON.error_message, icon: "error", }); // console.log(res.responseJSON); }, }); } }); } else { swal({ title: "错误", text: "请输入用户名!", icon: "error", }); } } }); }); /*这里不知道为啥不能for整,所以只好这样*/ $("#mess-del-btn").on("click", () => { swal({ text: "开始清除!", buttons: false, timer: 3000, }); GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/message-record?query_type=LIKE_FORK&limit=200&offset=0", data: document.cookie, binary: true, async onload({ response }) { for (var y = 0; y < JSON.parse(response).total; y += 200) { messDel(y, "LIKE_FORK"); } }, }); GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/message-record?query_type=SYSTEM&limit=200&offset=0", data: document.cookie, binary: true, async onload({ response }) { for (var y = 0; y < JSON.parse(response).total; y += 200) { messDel(y, "SYSTEM"); } }, }); GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/message-record?query_type=COMMENT_REPLY&limit=200&offset=0", data: document.cookie, binary: true, async onload({ response }) { for (var y = 0; y < JSON.parse(response).total; y += 200) { messDel(y, "COMMENT_REPLY"); } swal({ text: "你的铃铛红点已清除,再也不会急死强迫症的你了~", buttons: false, timer: 3000, }); }, }); }); async function messDel(offset, types) { GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/message-record?query_type=" + types + "&limit=200&offset=" + offset, data: document.cookie, binary: true, async onload({ response }) {}, }); } const addRipple = function (e) { let overlay = $(""); overlay.removeClass("animate"); const x = parseInt(e.pageX - $(this).offset().left) - overlay.width() / 2; const y = parseInt(e.pageY - $(this).offset().top) - overlay.height() / 2; overlay .css({ left: x, top: y, }) .addClass("animate"); $(this).append(overlay); setTimeout(() => { overlay.remove(); }, 500); }; let rippleList = [ ".c-navigator--header-content .c-navigator--nav_wrap .c-navigator--item a", ".c-navigator--dropdown-wrap li a", ".r-community--send_btn", "li[data-watch_event='旋转-入口tab']", ".r-community-c-forum_sender--option", ".r-home-c-community_star--user_recommend_item", ".r-user-c-banner--btn", ".c-navigator--logout", ".c-navigator--cont .c-navigator--item", ".r-community-c-forum_sender--select_area span", ".r-community--forum_list div li", ".r-community--forum_list2 div li", ".r-community--board_item", ".r-home-c-work_card--work_card", ".r-community--search_container .r-community--my_options .r-community--option", ".r-gallery-c-theme_card--card_item", ]; setInterval(() => { GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/creation-tools/v1/user/center/honor", data: document.cookie, binary: true, async onload({ response }) { var options, info; if (JSON.parse(response).user_id) { if (Notification.permission !== "denied") { Notification.requestPermission().then((permission) => {}); } if (!localStorage.getItem("user" + JSON.parse(response).user_id)) { localStorage.setItem("user" + JSON.parse(response).user_id, JSON.parse(response).fans_total + "," + JSON.parse(response).liked_total); } if (localStorage.getItem("user" + JSON.parse(response).user_id).split(",")[0] != JSON.parse(response).fans_total) { info = JSON.parse(response).fans_total - localStorage.getItem("user" + JSON.parse(response).user_id).split(",")[0] > 0 ? "多" : "少"; options = { body: `现在你的粉丝数为:${JSON.parse(response).fans_total},比上次${info}了${Math.abs(JSON.parse(response).fans_total - localStorage.getItem("user" + JSON.parse(response).user_id).split(",")[0])}个`, icon: "https://static.codemao.cn/coco/player/unstable/B1F3qc2Hj.image/svg+xml?hash=FlHXde3J3HLj1PtOWGgeN9fhcba3", tag: "fans_total", }; if (n) n.close(); var n = new Notification("粉丝数", options); // 显示通知 } if (localStorage.getItem("user" + JSON.parse(response).user_id).split(",")[1] != JSON.parse(response).liked_total) { info = JSON.parse(response).liked_total - localStorage.getItem("user" + JSON.parse(response).user_id).split(",")[1] > 0 ? "多" : "少"; options = { body: `现在你的点赞数为:${JSON.parse(response).liked_total},比上次${info}了${Math.abs(JSON.parse(response).liked_total - localStorage.getItem("user" + JSON.parse(response).user_id).split(",")[1])}个`, icon: "https://static.codemao.cn/coco/player/unstable/B1F3qc2Hj.image/svg+xml?hash=FlHXde3J3HLj1PtOWGgeN9fhcba3", tag: "liked_total", }; if (k) k.close(); var k = new Notification("点赞数", options); // 显示通知 } localStorage.setItem("user" + JSON.parse(response).user_id, JSON.parse(response).fans_total + "," + JSON.parse(response).liked_total); } }, }); GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/message-record/count", data: document.cookie, binary: true, async onload({ response }) { try { $("li[data-watch_event='消息-评论'] a .c-navigator--reply_count").css("display", "none"); $("li[data-watch_event='消息-赞'] a .c-navigator--reply_count").css("display", "none"); $("li[data-watch_event='消息-系统'] a .c-navigator--reply_count").css("display", "none"); $(".c-navigator--message span").css("display", "none"); } catch (error) {} if (JSON.parse(response)[0]) { if (JSON.parse(response)[0].count == 0) { if (document.querySelector("li[data-watch_event='消息-评论'] a .c-navigator--reply_count")) { $("li[data-watch_event='消息-评论'] a .c-navigator--reply_count").css("display", "none"); } else if (document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.0'] .index__reply_count___1nqAb")) { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.0'] .index__reply_count___1nqAb").css("display", "none"); } } else { if (document.querySelector("li[data-watch_event='消息-评论'] a .c-navigator--reply_count")) { $("li[data-watch_event='消息-评论'] a .c-navigator--reply_count:first-child").css("display", ""); document.querySelector("li[data-watch_event='消息-评论'] a .c-navigator--reply_count").innerHTML = `(${JSON.parse(response)[0].count})`; } else { $("li[data-watch_event='消息-评论'] a").append(`(${JSON.parse(response)[0].count})`); } if (document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.0'] .index__reply_count___1nqAb")) { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.0'] a span.index__reply_count___1nqAb:nth-child(2)").css("display", ""); document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.0'] .index__reply_count___1nqAb").innerHTML = `(${JSON.parse(response)[0].count})`; } else { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.0'] a").append(`(${JSON.parse(response)[0].count})`); } } if (JSON.parse(response)[1].count == 0) { if (document.querySelector("li[data-watch_event='消息-赞'] a .c-navigator--reply_count")) { $("li[data-watch_event='消息-赞'] a .c-navigator--reply_count").css("display", "none"); } else if (document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.1'] .index__reply_count___1nqAb")) { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.1'] .index__reply_count___1nqAb").css("display", "none"); } } else { if (document.querySelector("li[data-watch_event='消息-赞'] a .c-navigator--reply_count")) { $("li[data-watch_event='消息-赞'] a .c-navigator--reply_count:first-child").css("display", ""); document.querySelector("li[data-watch_event='消息-赞'] a .c-navigator--reply_count").innerHTML = `(${JSON.parse(response)[1].count})`; } else { $("li[data-watch_event='消息-赞'] a").append(`(${JSON.parse(response)[1].count})`); } if (document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.1'] .index__reply_count___1nqAb")) { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.1'] a span.index__reply_count___1nqAb:nth-child(2)").css("display", ""); document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.1'] .index__reply_count___1nqAb").innerHTML = `(${JSON.parse(response)[1].count})`; } else { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.1'] a").append(`(${JSON.parse(response)[1].count})`); } } if (JSON.parse(response)[2].count == 0) { if (document.querySelector("li[data-watch_event='消息-系统'] a .c-navigator--reply_count")) { $("li[data-watch_event='消息-系统'] a .c-navigator--reply_count").css("display", "none"); } else if (document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.2'] .index__reply_count___1nqAb")) { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.2'] .index__reply_count___1nqAb").css("display", "none"); } } else { if (document.querySelector("li[data-watch_event='消息-系统'] a .c-navigator--reply_count")) { $("li[data-watch_event='消息-系统'] a .c-navigator--reply_count:first-child").css("display", ""); document.querySelector("li[data-watch_event='消息-系统'] a .c-navigator--reply_count").innerHTML = `(${JSON.parse(response)[2].count})`; } else { $("li[data-watch_event='消息-系统'] a").append(`(${JSON.parse(response)[2].count})`); } if (document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.2'] .index__reply_count___1nqAb")) { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.2'] a span.index__reply_count___1nqAb:nth-child(2)").css("display", ""); document.querySelector("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.2'] .index__reply_count___1nqAb").innerHTML = `(${JSON.parse(response)[2].count})`; } else { $("li[data-reactid='.0.0.0.0.0.3.0.0.1.0.2'] a").append(`(${JSON.parse(response)[2].count})`); } } if (JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count == 0) { if (document.querySelector(".c-navigator--message span")) { $(".c-navigator--message span").css("display", "none"); } else if (document.querySelector(".index__user_wrap___11XZU .index__message___3tAMD span")) { $(".index__user_wrap___11XZU .index__message___3tAMD span").css("display", "none"); } } else { if (document.querySelector(".c-navigator--message span")) { $(".c-navigator--message span:first-child").css("display", ""); document.querySelector(".c-navigator--message span").innerHTML = `${ JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count > 99 ? "99+" : JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count }`; } else { $(".c-navigator--message").append( `${ JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count > 99 ? "99+" : JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count }` ); } if (document.querySelector(".index__user_wrap___11XZU .index__message___3tAMD span")) { $(".index__user_wrap___11XZU .index__message___3tAMD span:first-child").css("display", ""); document.querySelector(".index__user_wrap___11XZU .index__message___3tAMD span").innerHTML = `${ JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count > 99 ? "99+" : JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count }`; } else { $(".index__user_wrap___11XZU .index__message___3tAMD").append( `${ JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count > 99 ? "99+" : JSON.parse(response)[0].count + JSON.parse(response)[1].count + JSON.parse(response)[2].count }` ); } } } }, }); }, 1000); let url; setInterval(() => { try { $(".r-home-c-creativityComponent--creativity .r-home-c-creativityComponent--box .r-home-c-creativityComponent--detail .r-home-c-creativityComponent--text-box .r-home-c-creativityComponent--introduction img").attr( "src", "https://static.codemao.cn/coco/player/unstable/r1Z2a8yEj.image/png?hash=Fpf08Z93Z-LgvoMLKzbyACyAvroC" ); } catch (e) {} for (i of rippleList) { for (h of document.querySelectorAll(i)) { if (!$(h).hasClass("yzf-animate")) { $(h).addClass("yzf-animate"); $(h).css({ position: "relative", overflow: "hidden", transition: "0.1s ease-in", }); if (i == ".r-home-c-community_star--user_recommend_item") { $(h).children("a").mousedown(addRipple); } else { $(h).mousedown(addRipple); } } } } if ( (window.location.href.indexOf("community") != -1 || window.location.href.indexOf("wiki") != -1) && !parseInt(window.location.href.slice(25 + 10)) && window.location.href.indexOf("wiki/forum/") == -1 && window.location.href.indexOf("wiki/book") == -1 && window.location.href.indexOf("wiki/cartoon") == -1 && window.location.href.indexOf("wiki/novel") == -1 ) { if (Boolean(localStorage.getItem("md-use")) && document.getElementsByClassName("r-community-c-forum_sender--option")[0].style.display != "none") { bcm_markdown(); } if (Boolean(localStorage.getItem("md-use"))) { $(".forum_editor .mce-tinymce.mce-container.mce-panel").hide(); } var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; $(".r-community--scroll_to_top").remove(); if (document.querySelector("#yzfnb") == null) { $(".r-index--main_cont").after(''); } if (scrollTop + windowHeight >= scrollHeight) { try { if (Boolean(localStorage.getItem("auto-turn")) && !document.querySelector("#loading")) { // document.documentElement.scrollTop = scrollHeight - windowHeight - 10; document.querySelector(".r-community--forum_list .c-pagination--btn.c-pagination--page-container li:last-child").click(); if (!document.querySelector(".r-community--forum_list .c-pagination--btn.c-pagination--page-container li:last-child.c-pagination--nomore")) { $(".r-community--forum_list2").after("加载中
"); } } } catch (err) {} } } try { var reactTinymce = document.querySelector(".mce-edit-area iframe"); for (i of reactTinymce.contentWindow.document.querySelectorAll("img")) { if (i.className.indexOf("encode") == -1) { i.src = i.src; i.className = "encode"; i.removeAttribute("alt"); } } } catch (e) {} if ((window.location.href.indexOf("community") != -1 || window.location.href.indexOf("wiki/forum/") != -1) & Boolean(localStorage.getItem("auto-turn"))) { if (document.querySelector(".r-community--forum_list2") == null) { $(".r-community--forum_list").after(""); url = []; } if ( document.querySelector(".r-community--forum_list div:not(div[class])") != null && (document.querySelector(".r-community--forum_filter") != null || document.querySelector(".r-community--content_my_container") != null) && (document.querySelector("#fan") == null || document.querySelector(".r-community--content_my_container") != null) ) { if (!document.querySelector(".c-pagination--activePage") || document.querySelector(".c-pagination--activePage").innerHTML == "1") { $(".r-community--forum_list2").empty(); url = []; } var forum_list = document.querySelectorAll(".r-community--forum_list div:not(div[class])"); for (i of forum_list) { unsafeWindow.geturl = (u) => { // console.log(u); url.push(u); }; unsafeWindow.open = unsafeWindow.geturl; i.querySelector("li").click(); let oCopy = i.cloneNode(true); oCopy.querySelector("li").classList.remove("yzf-animate"); $(".r-community--forum_list2").append(oCopy); } unsafeWindow.open = unsafeWindow.openurl; // console.log(url); $(".r-community--forum_list div:not(div[class])").css("display", "none").addClass("dec"); for (i = 0; i < document.querySelectorAll(".r-community--forum_list2 div:not(div[class]) li").length; i++) { let onurl = url[i]; document.querySelectorAll(".r-community--forum_list2 div:not(div[class]) li")[i].onclick = () => { unsafeWindow.open(onurl); // console.log(onurl); }; } if (Boolean(localStorage.getItem("auto-turn"))) { $(".r-community--page_contianer").hide(); } $(".r-community--forum_list").append(""); $("#loading").remove(); } } if (window.location.href.indexOf("/message") != -1) { scrollTop = document.documentElement.scrollTop || document.body.scrollTop; windowHeight = document.documentElement.clientHeight || document.body.clientHeight; scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; try { document.querySelector(".r-message--load_more").style.opacity = 0; } catch (err) {} if (scrollTop + windowHeight >= scrollHeight) { try { document.querySelector(".r-message--load_more").click(); } catch (err) {} } var user_face; for (user_face of document.querySelectorAll(".r-message-c-comments--user_face")) { if (user_face.className.indexOf("encode") == -1) { user_face.classList.add("encode"); user_face_now(user_face); } } for (user_face of document.querySelectorAll(".r-message-c-buy--user_face")) { if (user_face.className.indexOf("encode") == -1) { user_face.classList.add("encode"); user_face_now(user_face); } } for (user_face of document.querySelectorAll(".r-message-c-system_message--user_face")) { if (user_face.className.indexOf("encode") == -1) { user_face.classList.add("encode"); user_face_now(user_face); } } } }, 100); function user_face_now(user_face) { GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/creation-tools/v1/user/center/honor?user_id=" + user_face.href.slice(25 + 5), data: document.cookie, binary: true, async onload({ response }) { if (!JSON.parse(response).avatar_url) { user_face.style.backgroundImage = "url('https://cdn-community.codemao.cn/47/community/d2ViXzEwMDFfMTYwMTg3NDJfMTYwMTg3NDJfMTYyNjU3ODkzOTI2M185MGJlYmIyNQ.png')"; user_face.style.filter = "grayscale(1)"; } else { user_face.style.backgroundImage = "url('" + JSON.parse(response).avatar_url + "')"; } }, }); } document.querySelector("#custom-sett textarea").value = localStorage.getItem("custom-sett"); document.querySelector("#custom-setts").innerHTML = document.querySelector("#custom-sett textarea").value; $("head").append(` `); $("head").append(` `); $("li[data-watch_event='设置-入口tab']").click(function () { $("#yzf-settings").css("display", "block"); $("#yzf-settings").css("transform", "translateY(0)"); $("#yzf-close").click(() => { $(".c-dialog--dialog_wrap").css("opacity", "0"); $("#yzf-settings").css("transform", "translateY(-20px)"); setTimeout(() => { if (document.querySelector(".c-dialog--dialog_wrap")) { $(".c-dialog--dialog_wrap").removeClass("c-dialog--visiable c-dialog--show"); $(".c-dialog--dialog_wrap").css("opacity", ""); $("#yzf-settings").css("display", "none"); } else { $(".c-dialog--dialog_cover").fadeOut(200); $("#yzf-settings").fadeOut(200); } }, 200); }); $("#main-color").val(localStorage.getItem("main-color") || "#fec433"); $("#second-color").val(localStorage.getItem("second-color") || "#f6b206"); $("#person-color").val(localStorage.getItem("person-color") || "#000"); $("#highlight-color").val(localStorage.getItem("highlight-color") || "#ec443d"); document.querySelector("input#md-use").checked = Boolean(localStorage.getItem("md-use")) ? true : false; document.querySelector("input#auto-turn").checked = Boolean(localStorage.getItem("auto-turn")) ? true : false; if (document.querySelector(".c-dialog--dialog_wrap")) { $(".c-dialog--dialog_wrap").addClass("c-dialog--visiable c-dialog--show"); } else { $(".c-dialog--dialog_cover").css("zIndex", "100").fadeIn(200); } }); if (localStorage.getItem("theme") == "light" || localStorage.getItem("theme") == null) { document.querySelector('input[value="light"]').checked = true; to_light(); } else if (localStorage.getItem("theme") == "dark") { document.querySelector('input[value="dark"]').checked = true; to_dark(); } else { if (localStorage.getItem("theme") == "auto") { document.querySelector('input[value="auto"]').checked = true; const themeMedia = window.matchMedia("(prefers-color-scheme: light)"); if (!themeMedia.matches) { to_dark(); } else { to_light(); } themeMedia.addListener((e) => { if (localStorage.getItem("theme") == "auto") { if (!e.matches) { to_dark(); } else { to_light(); } } }); } } if (localStorage.getItem("person-setting") == "color") { document.querySelector('input[value="color"]').checked = true; document.querySelector("#person-bg-btn").style.display = "none"; document.querySelector("#person-color").style.display = "block"; document.documentElement.style.setProperty("--person-color", localStorage.getItem("person-color") || "#000"); document.documentElement.style.setProperty("--person-bg", ""); } else { document.querySelector('input[value="pic"]').checked = true; document.querySelector("#person-bg-btn").style.display = "block"; document.querySelector("#person-color").style.display = "none"; document.documentElement.style.setProperty("--person-color", ""); document.documentElement.style.setProperty("--person-bg", localStorage.getItem("person-bg") || "url(https://cdn-community.codemao.cn/community_frontend/asset/banner_65b4a.png)"); } GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/users/details", data: document.cookie, binary: true, async onload({ response }) { if (window.location.href.indexOf("user") != -1 && JSON.parse(response).id != parseInt(window.location.href.slice(25 + 5))) { GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/creation-tools/v1/user/center/honor?user_id=" + parseInt(window.location.href.slice(25 + 5)), data: document.cookie, binary: true, async onload({ response }) { if (JSON.parse(response).user_cover == "") { document.querySelector(".r-user-c-banner--banner .r-user-c-banner--background").style.setProperty("background-image", "url(https://cdn-community.codemao.cn/community_frontend/asset/banner_65b4a.png)", "important"); } else { document.querySelector(".r-user-c-banner--banner .r-user-c-banner--background").style.setProperty("background-image", "url(" + JSON.parse(response).user_cover + ")", "important"); } }, }); } }, }); } }, 100); })(); $("head").append(` `); function remove_md() { if (document.querySelector(".forum_editor.ne-doc-major-editor")) { $(".yuque-sender,#preview,#yuque").remove(); $(".forum_editor .mce-tinymce.mce-container.mce-panel,.r-community-c-forum_sender--bottom_options .r-community-c-forum_sender--option").show(); document.querySelector(".forum_editor").classList.remove("ne-doc-major-editor"); } } function bcm_markdown() { if (document.querySelector(".forum_editor:not(.ne-doc-major-editor)")) { document.querySelector(".forum_editor").classList.add("ne-doc-major-editor"); $(".r-community-c-forum_sender--bottom_options .r-community-c-forum_sender--option").after($(".r-community-c-forum_sender--bottom_options .r-community-c-forum_sender--option").clone(true).addClass("yuque-sender")).hide(); $(".forum_editor").append(``); $("body").append(``); document.querySelector(".r-community-c-forum_sender--bottom_options .r-community-c-forum_sender--option.yuque-sender").onclick = async (e) => { let tag; e.preventDefault(); try { if (document.getElementsByClassName("r-community-c-forum_sender--title_input")[0].value.length < 5 || document.getElementsByClassName("r-community-c-forum_sender--title_input")[0].value.length > 50) { swal({ title: "错误", text: "请填写5-50字的标题", icon: "error", }); return false; } let tags = { 热门活动: 17, 积木编程乐园: 2, "工作室&师徒": 10, 你问我答: 5, 神奇代码岛: 3, 图书馆: 6, CoCo应用创作: 27, Python乐园: 11, 源码精灵: 26, NOC编程猫比赛: 13, 通天塔: 4, 灌水池塘: 7, 训练师小课堂: 28, }; tag = tags[document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText]; document.querySelector("#yuque").contentWindow.postMessage("data", "*"); //`; GM_xmlhttpRequest({ url: "https://api.codemao.cn/web/forums/boards/" + tag + "/posts", method: "POST", data: JSON.stringify({ title: document.getElementsByClassName("r-community-c-forum_sender--title_input")[0].value, content: content, }), headers: { "Content-type": "application/json;charset=UTF-8", "User-Agent": "Mozilla/4.0 (compatible; MSIE .0; Windows NT 6.1; Trident/4.0; SLCC2;)", Host: "api.codemao.cn", Cookie: document.cookie, }, async onload({ response }) { // console.log(JSON.parse(response).id); window.open("https://shequ.codemao.cn/community/" + JSON.parse(response).id); }, }); } else { texts = e.data; previewContent = `