2024-04-17 14:29:47 -04:00
|
|
|
/*
|
2024-06-04 18:11:28 -04:00
|
|
|
* Vencord, a Discord client mod
|
|
|
|
* Copyright (c) 2024 Vendicated and contributors
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2024-04-17 14:29:47 -04:00
|
|
|
|
2024-06-01 14:32:22 -04:00
|
|
|
import { definePluginSettings } from "@api/Settings";
|
2024-04-18 19:15:01 -04:00
|
|
|
import { EquicordDevs } from "@utils/constants";
|
2024-04-17 14:29:47 -04:00
|
|
|
import definePlugin, { OptionType } from "@utils/types";
|
|
|
|
|
2024-06-04 18:11:28 -04:00
|
|
|
import { getStyle } from "./style";
|
|
|
|
|
|
|
|
let [styles, Classes]: [string, object] = ["", {}];
|
2024-04-17 14:29:47 -04:00
|
|
|
|
|
|
|
const settings = definePluginSettings({
|
|
|
|
hoverToView: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "When hovering over a message, show the contents.",
|
|
|
|
default: false,
|
|
|
|
onChange: () => {
|
2024-06-01 14:32:22 -04:00
|
|
|
console.log(settings.store.hoverToView);
|
|
|
|
updateClassList("hover-to-view", settings.store.hoverToView);
|
2024-04-17 14:29:47 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
keybind: {
|
|
|
|
type: OptionType.STRING,
|
|
|
|
description: "The keybind to show the contents of a message.",
|
|
|
|
default: "Insert",
|
|
|
|
restartNeeded: false,
|
|
|
|
},
|
|
|
|
enableForStream: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
description: "Blur all messages in streamer mode.",
|
|
|
|
default: false,
|
|
|
|
onChange: () => {
|
2024-06-01 14:32:22 -04:00
|
|
|
console.log(settings.store.enableForStream);
|
2024-06-04 18:11:28 -04:00
|
|
|
updateClassList(
|
|
|
|
"hide-in-streamer-mode",
|
|
|
|
settings.store.enableForStream
|
|
|
|
);
|
2024-04-17 14:29:47 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default definePlugin({
|
2024-06-01 14:32:22 -04:00
|
|
|
name: "Do Not Leak!",
|
2024-04-17 14:29:47 -04:00
|
|
|
description: "Hide all message contents and attachments when you're streaming or sharing your screen.",
|
2024-04-18 19:15:01 -04:00
|
|
|
authors: [EquicordDevs.Perny],
|
2024-04-17 14:29:47 -04:00
|
|
|
settings,
|
|
|
|
start() {
|
2024-06-04 18:11:28 -04:00
|
|
|
[styles, Classes] = getStyle();
|
|
|
|
|
|
|
|
const style = document.createElement("style");
|
|
|
|
style.setAttribute("id", "vc-dont-leak-style");
|
|
|
|
style.innerHTML = styles;
|
|
|
|
document.head.appendChild(style);
|
|
|
|
|
2024-04-17 14:29:47 -04:00
|
|
|
document.addEventListener("keyup", keyUpHandler);
|
|
|
|
document.addEventListener("keydown", keyDownHandler);
|
2024-06-01 14:32:22 -04:00
|
|
|
updateClassList("hover-to-view", settings.store.hoverToView);
|
2024-06-04 18:11:28 -04:00
|
|
|
updateClassList(
|
|
|
|
"hide-in-streamer-mode",
|
|
|
|
settings.store.enableForStream
|
|
|
|
);
|
2024-04-17 14:29:47 -04:00
|
|
|
},
|
|
|
|
stop() {
|
|
|
|
document.removeEventListener("keyup", keyUpHandler);
|
|
|
|
document.removeEventListener("keydown", keyDownHandler);
|
2024-06-04 18:11:28 -04:00
|
|
|
document.getElementById("vc-dont-leak-style")?.remove();
|
2024-04-17 14:29:47 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
function updateClassList(className, condition) {
|
|
|
|
if (condition) {
|
2024-06-01 14:32:22 -04:00
|
|
|
document.body.classList.add(`vc-dnl-${className}`);
|
2024-04-17 14:29:47 -04:00
|
|
|
return;
|
|
|
|
}
|
2024-06-01 14:32:22 -04:00
|
|
|
document.body.classList.remove(`vc-dnl-${className}`);
|
2024-04-17 14:29:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function keyUpHandler(e: KeyboardEvent) {
|
|
|
|
if (e.key !== settings.store.keybind) return;
|
2024-06-01 14:32:22 -04:00
|
|
|
updateClassList("show-messages", false);
|
2024-04-17 14:29:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function keyDownHandler(e: KeyboardEvent) {
|
|
|
|
if (e.key !== settings.store.keybind) return;
|
2024-06-01 14:32:22 -04:00
|
|
|
updateClassList("show-messages", true);
|
2024-04-17 14:29:47 -04:00
|
|
|
}
|