constants.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { LogLevel } from "./types";
  2. const modeRaw = "#{{MODE}}";
  3. const branchRaw = "#{{BRANCH}}";
  4. const hostRaw = "#{{HOST}}";
  5. /** The mode in which the script was built (production or development) */
  6. export const mode = (modeRaw.match(/^#{{.+}}$/) ? "production" : modeRaw) as "production" | "development";
  7. /** The branch to use in various URLs that point to the GitHub repo */
  8. export const branch = (branchRaw.match(/^#{{.+}}$/) ? "main" : branchRaw) as "main" | "develop";
  9. /** Path to the GitHub repo */
  10. export const repo = "Sv443/BetterYTM";
  11. /** Which host the userscript was installed from */
  12. export const host = (hostRaw.match(/^#{{.+}}$/) ? "github" : hostRaw) as "github" | "greasyfork" | "openuserjs";
  13. export const platformNames: Record<typeof host, string> = {
  14. github: "GitHub",
  15. greasyfork: "GreasyFork",
  16. openuserjs: "OpenUserJS",
  17. };
  18. /**
  19. * How much info should be logged to the devtools console
  20. * 0 = Debug (show everything) or 1 = Info (show only important stuff)
  21. */
  22. export const defaultLogLevel: LogLevel = mode === "production" ? LogLevel.Info : LogLevel.Debug;
  23. /** Info about the userscript, parsed from the userscript header (tools/post-build.js) */
  24. export const scriptInfo = {
  25. name: GM.info.script.name,
  26. version: GM.info.script.version,
  27. namespace: GM.info.script.namespace,
  28. buildNumber: "#{{BUILD_NUMBER}}" as string, // asserted as generic string instead of literal
  29. };