42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
(() => {
|
|
const tauriInvoke = window.__TAURI_INTERNALS__?.invoke;
|
|
|
|
// Disable text selection globally, but keep inputs editable.
|
|
document.addEventListener("selectstart", (event) => {
|
|
const target = event.target;
|
|
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
|
return;
|
|
}
|
|
event.preventDefault();
|
|
});
|
|
|
|
async function applyProductionGuards() {
|
|
if (!tauriInvoke) {
|
|
return;
|
|
}
|
|
|
|
let isDebugBuild = false;
|
|
try {
|
|
isDebugBuild = await tauriInvoke("is_debug_build");
|
|
} catch {
|
|
return;
|
|
}
|
|
|
|
if (isDebugBuild) {
|
|
return;
|
|
}
|
|
|
|
document.addEventListener("contextmenu", (event) => event.preventDefault());
|
|
document.addEventListener("keydown", (event) => {
|
|
if (event.key === "F12") {
|
|
event.preventDefault();
|
|
}
|
|
if ((event.ctrlKey || event.metaKey) && event.shiftKey && ["I", "C", "J"].includes(event.key.toUpperCase())) {
|
|
event.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
|
|
void applyProductionGuards();
|
|
})();
|