All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.9 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. import { MODULE_NAME, premiumModuleSelector } from "./consts.js";
  2. // Should return true for anything premium
  3. export function isPremiumApplication(app, html, data, appName) {
  4. if (app.constructor.name.startsWith("SWPF")) {
  5. console.debug(`${MODULE_NAME} | ${appName} starts with 'SWPF' => add .premium`);
  6. html[0].classList.add("premium");
  7. html.closest(".app").find(".journal-entry-content").addClass(".premium");
  8. return true;
  9. }
  10. for (var key in app.document?.flags) {
  11. //prettier-ignore
  12. const sigilPremium = new RegExp(/^pf2e-ap\d{3}-/);
  13. if (sigilPremium.test(key)) {
  14. console.debug(`${MODULE_NAME} | ${appName} contains key matching '^pf2e-ap{3}-' => add .premium`);
  15. html[0].classList.add("premium");
  16. html.closest(".app").find(".journal-entry-content").addClass("premium");
  17. return true;
  18. }
  19. }
  20. for (var key in app.document?.flags) {
  21. //prettier-ignore
  22. const fvttPremium = new RegExp(/^pf2e-(beginner-box|abomination-vaults|kingmaker|km|mercenary-marketplace-vol1|pfs)/);
  23. if (fvttPremium.test(key)) {
  24. console.debug(
  25. `${MODULE_NAME} | ${appName} contains key matching '^pf2e-(beginner-box|abomination-vaults|kingmaker|km|mercenary-marketplace-vol1|pfs)' => add .premium`
  26. );
  27. html[0].classList.add("premium");
  28. html.closest(".app").find(".journal-entry-content").addClass("premium");
  29. return true;
  30. }
  31. }
  32. const isKingmaker = "pf2e-kingmaker.KingmakerJournalSheet" === app.document?.flags?.["core"]?.sheetClass;
  33. if (isKingmaker) {
  34. console.debug(`${MODULE_NAME} | ${appName} contains core flags for kingmaker => add .premium`);
  35. html[0].classList.add("premium");
  36. html.closest(".app").find(".journal-entry-content").addClass("premium");
  37. return true;
  38. }
  39. if (html[0].matches(premiumModuleSelector)) {
  40. console.debug(
  41. `${MODULE_NAME} | render${app.constructor.name} | matches premiumModuleSelector => do not add .dorako-ui`
  42. );
  43. html[0].classList.add("premium");
  44. return true;
  45. }
  46. return false;
  47. }
  48. Hooks.on("renderKingmakerJournalSheet", (app, html, data) => {
  49. console.debug(`${MODULE_NAME} | renderKingmakerJournalSheet' => add .premium`);
  50. html[0].classList.add("premium");
  51. html.closest(".app").find(".journal-entry-content").addClass(".premium");
  52. });
  53. Hooks.on("renderJournalSheet", (app, html, data) => {
  54. isPremiumApplication(app, html, data, "JournalSheet");
  55. });
  56. Hooks.on("renderJournalPageSheet", (app, html, data) => {
  57. isPremiumApplication(app, html, data, "JournalPageSheet");
  58. });
  59. Hooks.on("renderJournalTextPageSheet", (app, html, data) => {
  60. isPremiumApplication(app, html, data, "JournalTextPageSheet");
  61. });
  62. Hooks.on("renderSWPFCompendiumTOC", (app, html, appName) => {
  63. console.debug(`${MODULE_NAME} | ${appName} starts with 'SWPF' => add .premium`);
  64. html[0].classList.add("premium");
  65. // html.closest(".app").find(".journal-entry-content").addClass(".premium");
  66. });