Vencord/src/plugins/settings.ts

43 lines
1.7 KiB
TypeScript
Raw Normal View History

import definePlugin from "../utils/types";
import gitHash from "git-hash";
import { Devs } from "../utils/constants";
export default definePlugin({
name: "Settings",
description: "Adds Settings UI and debug info",
2022-09-30 20:27:28 -04:00
authors: [Devs.Ven],
2022-08-30 22:07:16 -04:00
required: true,
patches: [{
2022-09-27 08:34:57 -04:00
find: "().versionHash",
replacement: [
{
2022-09-27 08:34:57 -04:00
match: /\w\.createElement\(.{1,2}.Fragment,.{0,30}\{[^}]+\},"Host ".+?\):null/,
replace: m => {
const idx = m.indexOf("Host") - 1;
const template = m.slice(0, idx);
2022-10-03 18:52:42 -04:00
let r = `${m}, ${template}"Vencord ", "${gitHash}${IS_WEB ? " (Web)" : ""}"), " ")`;
if (!IS_WEB) {
r += `,${template} "Electron ",VencordNative.getVersions().electron)," "),`;
r += `${template} "Chrome ",VencordNative.getVersions().chrome)," ")`;
}
return r;
}
}
]
}, {
find: "Messages.ACTIVITY_SETTINGS",
replacement: {
2022-09-27 08:34:57 -04:00
match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/,
replace: (m, mod) => {
const updater = !IS_WEB ? '{section:"VencordUpdater",label:"Updater",element:Vencord.Components.Updater},' : "";
return (
`{section:${mod}.ID.HEADER,label:"Vencord"},` +
'{section:"VencordSetting",label:"Vencord",element:Vencord.Components.Settings},' +
updater +
`{section:${mod}.ID.DIVIDER},${m}`
);
}
}
}]
2022-09-16 16:59:34 -04:00
});