// ==UserScript== // @name 编程猫使用优化 // @namespace https://shequ.codemao.cn/user/438403 // @version 1.19.126 // @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://code.jquery.com/jquery-3.6.1.min.js // @require https://unpkg.com/sweetalert/dist/sweetalert.min.js // @require https://cdn.jsdelivr.net/npm/lil-gui@0.16 // @license 616 SB License // @downloadURL none // ==/UserScript== (function () { 'use strict'; if (window.location.href.indexOf("writer") != -1 || window.location.href.indexOf("publish") != -1) { return false } function titleChange(content) { if (document.querySelector("title") && document.querySelector("title").innerHTML != content) { document.querySelector("title").innerHTML = content } } $('head').append('') setInterval(() => { try { if (window.location.href.indexOf("community") != -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 + " | 编程猫社区") } else { titleChange("工作室 | 编程猫社区") } } if (window.location.href.indexOf("discover") != -1) { titleChange("发现 | 编程猫社区") } if (window.location.href.indexOf("gallery") != -1) { if (parseInt(window.location.href.slice(25 + 8,)) && document.querySelector(".r-gallery-r-detail--name")) { titleChange("活动 | " + document.querySelector(".r-gallery-r-detail--name").innerHTML + " | 编程猫社区") } else { titleChange("活动 | 编程猫社区") } } if (window.location.href.indexOf("user") != -1) { titleChange("个人中心 | " + document.querySelector(".r-user-c-banner--name").innerHTML + " | 编程猫社区") } if (window.location.href.indexOf("work") != -1) { titleChange("作品 | " + document.querySelector(".r-work-c-work_info--work_name").innerHTML + " | 编程猫社区") } if (window.location.href.indexOf("studio") != -1) { titleChange("活动 | " + document.querySelector(".r-studio--studio_title").innerHTML + " | 编程猫社区") } if (window.location.href.indexOf("setting") != -1) { titleChange("设置 | 编程猫社区") } if (window.location.href.indexOf("course") != -1) { titleChange("课程 | 编程猫社区") } if (window.location.href.indexOf("mall") != -1) { titleChange("素材 | 编程猫社区") } if (window.location.href.indexOf("my") != -1) { titleChange("作品管理 | 编程猫社区") } if (document.querySelector(".r-404--container") != null) { titleChange("404 | 编程猫社区") if (document.querySelector("a").innerHTML == "返回首页") { document.querySelector("a").innerHTML = "3秒后返回首页" } else { if (document.querySelector("a").innerHTML != "返回首页喽~") { document.querySelector("a").innerHTML = ((parseFloat(document.querySelector("a").innerHTML.slice(0,)) * 10 - 1) / 10) + "秒后返回首页" } if (Math.ceil(parseFloat(document.querySelector("a").innerHTML.slice(0,))) == "0") { window.location.href = "https://shequ.codemao.cn/" document.querySelector("a").innerHTML = "返回首页喽~" } } } } catch (e) { } }, 100) GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/creation-tools/v1/user/center/honor", data: document.cookie, binary: true, async onload({ response }) { $(".c-navigator--logo_wrap img").remove() $(".c-navigator--logo_wrap").append("PICKCAT") $("li[data-watch_event='下载APP-入口tab']").after(`
隐藏未发布的
") $('.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: "请输入作品ID!", 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--board_item", ".r-home-c-work_card--work_card" ] 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) { if (!$(i).hasClass('yzf-animate')) { $(i).addClass("yzf-animate") $(i).css({ position: 'relative', overflow: 'hidden', transition: '0.1s ease-in' }) if (i == ".r-home-c-community_star--user_recommend_item") { $(i).children("a").mousedown(addRipple) } else { $(i).mousedown(addRipple) } } } //尝试制作防劫持 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 + 10,)) && document.querySelector('iframe')) { $('iframe').css('position', 'inherit') } 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)) { if (Boolean(localStorage.getItem('md-use')) && document.getElementsByClassName("r-community-c-forum_sender--option")[0].style.display != 'none') { bcx_markdown() } 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.documentElement.scrollTop = 0 document.querySelector('.r-community--forum_list .c-pagination--btn.c-pagination--page-container li:last-child').click() } } 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)) { /* if (document.querySelector('.r-community--forum_list2') == null) { $('.r-community--forum_list').after("") } if (document.querySelector('.r-community--forum_list div:not(div[class])') != null && document.querySelector(".r-community--forum_filter") != null && document.querySelector("#fan") == null) { var forum_list = document.querySelectorAll('.r-community--forum_list div:not(div[class])') for (i of forum_list) { let oCopy = i.cloneNode(true) $('.r-community--forum_list2').append(oCopy) } $('.r-community--forum_list div:not(div[class])').css('display', 'none') $('.r-community--forum_filter').after(document.querySelector('.r-community--forum_list2').innerHTML) $('.r-community--forum_list').append("") }*/ } 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(() => { $('.c-dialog--dialog_wrap').removeClass('c-dialog--visiable c-dialog--show') $(".c-dialog--dialog_wrap").css("opacity", ""); $("#yzf-settings").css("display", "none") }, 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 $(".c-dialog--dialog_wrap").addClass('c-dialog--visiable c-dialog--show') }); 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)'); } if ((window.location.href.indexOf("user") != -1) && (JSON.parse(response).user_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.documentElement.style.setProperty('--person-bg', 'url(https://cdn-community.codemao.cn/community_frontend/asset/banner_65b4a.png)'); document.documentElement.style.setProperty('--person-color', ''); } else { document.documentElement.style.setProperty('--person-bg', 'url(' + JSON.parse(response).user_cover + ')'); document.documentElement.style.setProperty('--person-color', ''); } } }) } } }) $("head").append(` `); //声明一下,这个是经过冷鱼授权的了(他的委托),所以并上去了 function bcx_markdown() { try { var box = document.querySelector('.mce-tinymce') box.style.display = 'none'; document.getElementsByClassName("r-community-c-forum_sender--container")[0].style.width = '100%'; document.getElementsByClassName("r-community-c-forum_sender--option")[0].style.display = 'none'; var doNotShield = { obj: { height: 380, mddata: '带全屏按钮+文本', banner: '', lx: '', lxx: '', fq: '', cs: 0, id: 0, name: '', xjm: '', cookie: '', tzidc: '', gs: '', ram: 0, user: '', avatar_url: '', bcmid: '', csa: 0, yqtz: '', size: '', js: '' }, beign: async () => { if (doNotShield.obj.csa == 1) { alert('你目前在测试,无法进行创建正式帖哦!请刷新网页再试!'); } else { if (document.getElementsByClassName("r-community-c-forum_sender--title_input")[0].value == '') { alert('请先在 (【发帖关键字】请输入标题(5-50字符以内】)输入框内写上本次文章标题。'); } else { doNotShield.obj.name = document.getElementsByClassName("r-community-c-forum_sender--title_input")[0].value; if (doNotShield.obj.cs == 0) { doNotShield.obj.cs += 1; GM_xmlhttpRequest({ method: "get", url: "https://api.codemao.cn/web/users/details", data: document.cookie, binary: true, async onload({ response }) { doNotShield.obj.id = JSON.parse(response).id; doNotShield.obj.user = JSON.parse(response).nickname; doNotShield.obj.avatar_url = JSON.parse(response).avatar_url; GM_xmlhttpRequest({ method: "get", url: "https://api.bcmcreator.cn/MD/edit/examples/savea.php?id=" + doNotShield.obj.id + "&name=" + doNotShield.obj.name, binary: true, async onload({ response }) { doNotShield.obj.xjm = response; var p = document.createElement('iframe'); p.height = "1000px"; p.width = "100%"; p.id = "myFrame"; p.src = "https://api.bcmcreator.cn/MD/edit/examples/full.php?id=" + doNotShield.obj.id + "&xjm=" + doNotShield.obj.xjm + "&name=" + doNotShield.obj.name; p.scrolling = "no"; box.parentNode.insertBefore(p, box); }, }); }, }); } else { alert('你已经创建Markdown帖子了,不能再创建,请在帖子内修改。'); } } } }, run: async () => { if (doNotShield.obj.csa == 1) { alert('你目前在测试,无法进行发布哦!只有正式帖才能发布,请刷新网页吧!'); } else { try { if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '热门活动') { doNotShield.obj.fq = '17'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '积木编程乐园') { doNotShield.obj.fq = '2'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '工作室&师徒') { doNotShield.obj.fq = '10'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '你问我答') { doNotShield.obj.fq = '5'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '神奇代码岛') { doNotShield.obj.fq = '3'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '图书馆') { doNotShield.obj.fq = '27'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == 'CoCo应用创作') { doNotShield.obj.fq = '2'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == 'Python乐园') { doNotShield.obj.fq = '11'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '源码精灵') { doNotShield.obj.fq = '26'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == 'NOC编程猫比赛') { doNotShield.obj.fq = '13'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '灌水池塘') { doNotShield.obj.fq = '7'; } if (document.getElementsByClassName("r-community-c-forum_sender--active")[0].innerText == '训练师小课堂') { doNotShield.obj.fq = '28'; } if (doNotShield.obj.mddata == '带全屏按钮+文本') { doNotShield.obj.lx = '1'; doNotShield.obj.lxx = '2'; } else { doNotShield.obj.lx = '2'; doNotShield.obj.lxx = '3'; } doNotShield.obj.ram = Math.ceil(Math.random() * 999999999); doNotShield.obj.gs = new Object(); doNotShield.obj.gs.content = '