armcord/docs/examples/hello-plugin/main.js
2026-04-25 20:07:49 +02:00

20 lines
601 B
JavaScript

/**
* Main process entry example.
* Receives api from Legcord plugin manager.
*/
module.exports.activate = (api) => {
api.logger.log("main entry active");
// Example: patch BrowserWindow.getTitle globally in main process.
const unpatch = api.patcher.after("getTitle", api.electron.BrowserWindow.prototype, (_args, ret) => {
if (typeof ret === "string" && !ret.endsWith(" [HelloPlugin]")) {
return `${ret} [HelloPlugin]`;
}
return ret;
});
api.onCleanup(() => {
unpatch();
api.logger.log("main entry cleaned up");
});
};