misc/mpphc.user.js

84 lines
2.7 KiB
JavaScript

// ==UserScript==
// @name MPPHC
// @version 0.0.poc
// @description Mute's Project Pandora Hacks Collection (proof of concept)
// @author codename.mute@proton.me
// @namespace https://code.fleshless.org/mute/
// @match https://project-pandora.com/*
// @match https://www.project-pandora.com/*
// @sandbox DOM
// @grant GM_xmlhttpRequest
// @connect fonts.gstatic.com
// ==/UserScript==
(function() {
"use strict";
if (window.MPPHC) throw new Error("MPPHC found, aborting loading")
window.MPPHC = {}
const FONT = weight => ({weight, style: "normal", display: "swap", unicodeRange: "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"})
const CSS = _ => `
div.roomScreen {
padding: 0;
gap: 0;
}
div.tab-container > ul.header {
padding: 0 0.5em 0 0;
}
div.chatArea {
font-family: 'Laila', serif;
}
div.chatArea > div.messages > div.Scrollbar > div.direction-column > div.message > span.info {
font-style: normal;
font-family: 'Saira', sans-serif;
position: relative;
right: -13em;
margin-left: -10em;
padding: 0 0.5em;
}
div.chatArea > div.messages > div.Scrollbar > div.direction-column > div.message:hover > span.info {
right: -1em;
background: #000;
}
div.chatArea > div.messages > div.Scrollbar > div.direction-column > div.message.me {
font-style: italic;
}
div.chatArea > div.messages > div.Scrollbar > div.direction-column > div.message.serverMessage {
background-color: inherit;
border-left: none;
margin: 0;
padding: 0 0 0 0.25em;
font-style: italic;
}
div.chatArea > div.messages > div.Scrollbar > div.direction-column > div.message.serverMessage:before {
content: "[Server] ";
font-style: normal;
}
div.chatArea > textarea {
color: #fff;
font-family: 'Saira', sans-serif;
font-size: 22px;
height: 4.75em;
border: none;
outline: none;
}
div.chatArea > textarea:focus {
background-color: #000;
}
`
const css = document.createElement("style")
css.textContent = CSS()
document.head.appendChild(css)
async function webfont(name, url, props) {
const r = await GM.xmlHttpRequest({url, method: "GET", responseType: "blob", anonymous: true})
if (r.status !== 200) throw new Error('Font load failed')
const buf = await r.response.arrayBuffer()
const font = new FontFace(name, buf, props)
await font.load()
document.fonts.add(font)
}
webfont('Laila', "https://fonts.gstatic.com/s/laila/v15/LYjBdG_8nE8jDLypozNHjV8.woff2", FONT(500))
webfont('Saira', "https://fonts.gstatic.com/s/sairasemicondensed/v13/U9MD6c-2-nnJkHxyCjRcnMHcWVWV1cWRRX8MaOY.woff2", FONT(400))
})()