您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
MPP Custom Tags (MPPCT)
当前为
// ==UserScript== // @name MPP Custom Tags // @namespace http://tampermonkey.net/ // @version 1.9 // @description MPP Custom Tags (MPPCT) // @author НУУЕ (!НУУЕ2004#4440) // @match *://multiplayerpiano.net/* // @match *://better.mppclone.me/* // @license MIT // @icon https://www.google.com/s2/favicons?sz=64&domain=mppclone.com // ==/UserScript== console.log('%cLoaded MPPCT! uwu','color:orange; font-size:15px;'); if (!localStorage.tag) localStorage.tag = JSON.stringify({text: 'None', color: '#000000'}); const ver = '1.9'; const tag = JSON.parse(localStorage.tag); MPP.client.on('hi', () => { MPP.client.sendArray([{m: '+custom'}]); setTimeout(function() { //slow internet connection fix updtag(tag.text, tag.color, MPP.client.getOwnParticipant()._id, tag.gradient); askForTags(); }, 1500); }); const allowedGradients = ['linear-gradient', 'radial-gradient', 'repeating-radial-gradient', 'conic-gradient', 'repeating-conic-gradient']; function updtag(text, color, _id, gradient) { if (text.length > 50) { return; } if (!document.getElementById(`namediv-${_id}`)) return; if (document.getElementById(`nametag-${_id}`) != null) { document.getElementById(`nametag-${_id}`).remove(); } /*knownTags[_id] = {text: text, color: color}; localStorage.knownTags = JSON.stringify(knownTags);*/ let tagDiv = document.createElement('div') tagDiv.className = 'nametag'; tagDiv.id = `nametag-${_id}`; tagDiv.style['background-color'] = color; if (gradient) { if (!gradient.includes('"') && !gradient.includes(';') && !gradient.includes(':')) { let gradientAllowed = false; allowedGradients.forEach((Gradient) => { if (gradient.startsWith(Gradient)) { if (gradientAllowed) return; else gradientAllowed = true; tagDiv.style.background = gradient; /*knownTags[_id].gradient = gradient; localStorage.knownTags = JSON.stringify(knownTags);*/ } }); } } tagDiv.innerText = text; document.getElementById(`namediv-${_id}`).prepend(tagDiv); document.getElementById(`namediv-${_id}`).title = 'This is an MPPCT user.'; } let sendTagLocked = false;//to prevent spam function sendTag(id) { if (sendTagLocked && !id) return; if (id) MPP.client.sendArray([{m: "custom", data: {m: "mppct", text: tag.text, color: tag.color, gradient: tag.gradient}, target: { mode: "id", id: id } }]); else MPP.client.sendArray([{m: "custom", data: {m: "mppct", text: tag.text, color: tag.color, gradient: tag.gradient}, target: { mode: "subscribed" } }]); sendTagLocked = true; setTimeout(function() { sendTagLocked = false; }, 750) } function askForTags() { MPP.client.sendArray([{m: "custom", data: {m: "mppctreq"}, target: { mode: "subscribed" } }]); } MPP.client.on('custom', (data) => { if (data.data.m == 'mppct') { if (data.data.text && (data.data.color || data.data.gradient)) { if (MPP.client.ppl[data.p]) { updtag(data.data.text || 'None', data.data.color || '#000000', data.p, data.data.gradient); } } } if (data.data.m == 'mppctreq') { if (MPP.client.ppl[data.p] != undefined) { sendTag(data.p); } } }); MPP.client.on('p', (p) => { if (p._id == MPP.client.getOwnParticipant()._id) { updtag(tag.text, tag.color, MPP.client.getOwnParticipant()._id, tag.gradient); sendTag(); } }); MPP.client.on('ch', (p) => { if (!p.hasOwnProperty('p')) return; askForTags(); sendTag(); }); // Tags in chat /*MPP.client.on('a', (msg) => { //too many problems if (!knownTags[msg.p._id]) return; let aTag; if (msg.p._id == MPP.client.getOwnParticipant()._id) aTag = tag; else aTag = knownTags[msg.p._id]; if (document.getElementById(`nametext-${msg.p._id}`)) { if (document.getElementById(`nametag-${msg.p._id}`).innerText != knownTags[msg.p._id].text) { delete knownTags[msg.p._id]; localStorage.knownTags = JSON.stringify(knownTags); return; } } let chatMessage = $('.message').last()[0]; let Span = document.createElement('span'); // <span style="background-color: ${aTag.color};color:#ffffff;" class="nametag">${aTag.text}</span> Span.style['background-color'] = aTag.color; if (knownTags[msg.p._id]) Span.style.background = aTag.gradient; Span.style.color = '#ffffff'; Span.className = 'nametag'; Span.innerText = aTag.text; chatMessage.appendChild(Span); }); MPP.client.on('c', (msg) => { if (!msg.c) return; if (!Array.isArray(msg.c)) return; msg.c.forEach((a, i) => { if (a.m == 'dm') return; let p = a.p; if (!knownTags[p._id]) return; let aTag; if (p._id == MPP.client.getOwnParticipant()._id) aTag = tag; else aTag = knownTags[p._id]; setTimeout(function() { if (document.getElementById(`nametext-${p._id}`)) { // xd if (p._id != MPP.client.getOwnParticipant()._id) { if (document.getElementById(`nametag-${p._id}`).innerText != aTag.text) { delete knownTags[p._id]; localStorage.knownTags = JSON.stringify(knownTags); return; } } } }, 2000); let chatMessage = $('.message')[i]; let Span = document.createElement('span'); // <span style="background-color: ${aTag.color};color:#ffffff;" class="nametag">${aTag.text}</span> Span.style['background-color'] = aTag.color; if (knownTags[p._id]) Span.style.background = aTag.gradient; Span.style.color = '#ffffff'; Span.className = 'nametag'; Span.innerText = aTag.text; chatMessage.appendChild(Span); }); });*/ // Buttons const a = document.createElement('input'); a.name = 'tag'; a.type = 'text'; a.placeholder = 'Tag'; a.maxLength = '50'; a.className = 'text'; a.style = 'width: 100px; height: 20px;'; document.body.getElementsByClassName('dialog').rename.appendChild(a); const q = document.createElement('input'); q.name = 'tagcolor'; q.type = 'color'; q.placeholder = ''; q.maxlength = '7'; q.className = 'color'; document.body.getElementsByClassName('dialog').rename.appendChild(q); const e = document.createElement('button'); e.addEventListener('click', () => { if ($('#rename input[name=tag]').val() == '') return; let newTag = JSON.parse(localStorage.tag); newTag.text = $('#rename input[name=tag]').val() || 'None'; newTag.color = $('#rename input[name=tagcolor]').val() || '#000000'; localStorage.tag = JSON.stringify(newTag); tag = newTag; updtag(newTag.text, newTag.color, MPP.client.getOwnParticipant()._id, newTag.gradient); sendTag(); }); e.innerText = 'SET TAG'; e.className = 'top-button'; e.style.position = 'fixed'; e.style.height = '30px'; document.body.getElementsByClassName('dialog').rename.appendChild(e); $('#rename input[name=tag]').val(tag.text); $('#rename input[name=tagcolor]').val(tag.color); //Version checker function checkVersion() { fetch('https://raw.githubusercontent.com/Hyye123/MPPCT/main/version.json').then(r => r.json().then(json => { if (ver != json.latest) { setInterval(function() { MPP.chat.receive({ "m": "a", "t": Date.now(), "a": "Please update MPPCT via Greasy Fork镜像( https://gf.qytechs.cn/ru/scripts/455137-mpp-custom-tags ) or github( https://github.com/Hyye123/MPPCT )", "p": { "_id": "MPPCT", "name": "MPPCT (eng)", "color": "#ffffff", "id": "MPPCT" } }); MPP.chat.receive({ "m": "a", "t": Date.now(), "a": "Пожалуйста обновите MPPCT через Greasy Fork镜像( https://gf.qytechs.cn/ru/scripts/455137-mpp-custom-tags ) или github( https://github.com/Hyye123/MPPCT )", "p": { "_id": "MPPCT", "name": "MPPCT (rus)", "color": "#ffffff", "id": "MPPCT" } }); }, 30000); } })); } setInterval(checkVersion, 300000); setTimeout(checkVersion, 5000);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址