constants.ts 979 B

1234567891011121314151617181920212223
  1. import type { LogLevel } from "./types";
  2. const modeRaw = "{{MODE}}";
  3. const branchRaw = "{{BRANCH}}";
  4. /** The mode in which the script was built (production or development) */
  5. export const mode = (modeRaw.match(/^{{.+}}$/) ? "production" : modeRaw) as "production" | "development";
  6. /** The branch to use in various URLs that point to the GitHub repo */
  7. export const branch = (branchRaw.match(/^{{.+}}$/) ? "main" : branchRaw) as "main" | "develop";
  8. /**
  9. * How much info should be logged to the devtools console
  10. * 0 = Debug (show everything) or 1 = Info (show only important stuff)
  11. */
  12. export const defaultLogLevel: LogLevel = mode === "production" ? 1 : 0;
  13. /** Info about the userscript, parsed from the userscript header (tools/post-build.js) */
  14. export const scriptInfo = {
  15. name: GM.info.script.name,
  16. version: GM.info.script.version,
  17. namespace: GM.info.script.namespace,
  18. buildNumber: "{{BUILD_NUMBER}}" as string, // assert as generic string instead of literal
  19. };