From d6a568a0d642e7b58ea626cd2a13a531d1af37f2 Mon Sep 17 00:00:00 2001 From: Mute Date: Fri, 26 Jan 2024 23:44:18 +0000 Subject: [PATCH] Add mpphc.user.js --- mpphc.user.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 mpphc.user.js diff --git a/mpphc.user.js b/mpphc.user.js new file mode 100644 index 0000000..aa0546c --- /dev/null +++ b/mpphc.user.js @@ -0,0 +1,52 @@ +// ==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 = _ => ` +.chatArea { + font-family: 'Laila', serif; + font-size: 14px; +} +div.chatArea > textarea { + color: #fff; + background-color: #333; + 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)) + +})()