From babaaa631d8c3a46be3b9fe23e643b971333937b Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 26 Oct 2025 14:47:50 -0700 Subject: generalize eamusement userscript method into 1 template modal --- .../src/components/modals/DanceAroundModal.tsx | 159 ------------------- frontend/src/components/modals/DancerushModal.tsx | 158 ------------------- .../modals/EamusementUserscriptModal.tsx | 172 +++++++++++++++++++++ frontend/src/pages/Import.tsx | 48 +++--- 4 files changed, 196 insertions(+), 341 deletions(-) delete mode 100644 frontend/src/components/modals/DanceAroundModal.tsx delete mode 100644 frontend/src/components/modals/DancerushModal.tsx create mode 100644 frontend/src/components/modals/EamusementUserscriptModal.tsx diff --git a/frontend/src/components/modals/DanceAroundModal.tsx b/frontend/src/components/modals/DanceAroundModal.tsx deleted file mode 100644 index 43c71eb..0000000 --- a/frontend/src/components/modals/DanceAroundModal.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import type { SupportedGame } from "../../types/game"; - -interface DanceAroundModalProps { - isOpen: boolean; - onClose: () => void; - game: SupportedGame | undefined; - renderAsCard?: () => void; -} - -const DanceAroundModal = ({ - isOpen, - onClose, - game, - renderAsCard, -}: DanceAroundModalProps) => { - if (renderAsCard) { - return ( -
-
- - - -
-

- Dance aROUND e-amusement Play History -

-

- Import via scraping your Dance aROUND playdata from KONAMI e-amusement -

- -
- ); - } - - if (!isOpen) return null; - - const handleClose = () => { - onClose(); - }; - if (game === undefined) { - return "Sorry, due to some extreme error the game you're looking for doesn't seem to exist..."; - } - return ( -
- {/* Backdrop */} -
- - {/* Modal */} -
-
- {/* Header */} -
-

- Import Dance aROUND Data -

-

- Follow the instructions below to import your data -

-
- - {/* Warning */} -
-

- You may or may need to be subscribed to{" "} - - KONAMI's e-amusement Basic and/or Premium course - {" "} - to view a exportable playdata history for certain games. -

-
- - {/* Instructions */} -
-

- Instructions: -

-
    -
  1. - Log into the{" "} - - DANCE aROUND e-amusement page - -
  2. -
  3. - Navigate to the{" "} - - DANCE aROUND Play History Page - {" "} -
  4. -
  5. - Install the relevant userscript (use a browser extension such as{" "} - Tampermonkey) -
  6. - {/* Additional Info */} - -
  7. - A button will appear on the page that you can click to start the scraping process. -
  8. -
  9. - Upload the resulting JSON file into Mirage using the - Batch-Manual Upload functionality -
  10. -
  11. Verify that all data has been imported correctly
  12. -
-
- - - {/* Actions */} -
- -
-
-
-
- ); -}; - -export default DanceAroundModal; diff --git a/frontend/src/components/modals/DancerushModal.tsx b/frontend/src/components/modals/DancerushModal.tsx deleted file mode 100644 index f350a5a..0000000 --- a/frontend/src/components/modals/DancerushModal.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import type { SupportedGame } from "../../types/game"; - -interface DancerushModalProps { - isOpen: boolean; - onClose: () => void; - game: SupportedGame | undefined; - renderAsCard?: () => void; -} - -const DancerushModal = ({ - isOpen, - onClose, - game, - renderAsCard -}: DancerushModalProps) => { - if (renderAsCard) { - return ( -
-
- - - -
-

- DANCERUSH e-amusement Play History -

-

- Import via scraping your DANCERUSH playdata from KONAMI e-amusement -

- -
- ); - } - - if (!isOpen) return null; - - const handleClose = () => { - onClose(); - }; - if(game === undefined){ - return "Sorry, due to some extreme error the game you're looking for doesn't seem to exist..." - } - return ( -
- {/* Backdrop */} -
- - {/* Modal */} -
-
- {/* Header */} -
-

- Import DANCERUSH e-amusement Data -

-

- Follow the instructions below to import your data -

-
- - {/* Warning */} -
-

- You may or may need to be subscribed to{" "} - - KONAMI's e-amusement Basic and/or Premium course - {" "} - to view a exportable playdata history for certain games. -

-
- - {/* Instructions */} -
-

- Instructions: -

-
    -
  1. - Log into the{" "} - - DANCERUSH e-amusement page - -
  2. -
  3. - Navigate to the{" "} - - DANCERUSH Play History Page - {" "} -
  4. -
  5. - Install the relevant userscript (use a browser extension such as{" "} - Tampermonkey) -
  6. - {/* Additional Info */} - -
  7. - A button will appear on the page that you can click to start the scraping process. -
  8. -
  9. - Upload the resulting JSON file into Mirage using the - Batch-Manual Upload functionality -
  10. -
  11. Verify that all data has been imported correctly
  12. -
-
- - {/* Actions */} -
- -
-
-
-
- ); -}; - -export default DancerushModal; diff --git a/frontend/src/components/modals/EamusementUserscriptModal.tsx b/frontend/src/components/modals/EamusementUserscriptModal.tsx new file mode 100644 index 0000000..d7dc03a --- /dev/null +++ b/frontend/src/components/modals/EamusementUserscriptModal.tsx @@ -0,0 +1,172 @@ +interface UserScript { + name: string; + url: string; +} + +interface EamusementUserscriptModalProps { + isOpen: boolean; + onClose: () => void; + mainGameName: string; + userPage: string; + importPage: string; + scripts: UserScript[]; +} + +interface EamusementUserscriptCardProps { + mainGameName: string; + onClick: () => void; +} + +export const EamusementUserscriptCard = ({ mainGameName, onClick }: EamusementUserscriptCardProps) => { + return ( +
+
+ + + +
+

+ {mainGameName} e-amusement Play History (Userscript) +

+

+ Import via scraping your {mainGameName} playdata from KONAMI e-amusement +

+ +
+ ) +} + +const EamusementUserscriptModal = ({ + isOpen, + onClose, + mainGameName, + userPage, + importPage, + scripts, +}: EamusementUserscriptModalProps) => { + if (!isOpen) return null; + + const handleClose = () => { + onClose(); + }; + if(mainGameName === undefined){ + return "Sorry, due to some extreme error the game you're looking for doesn't seem to exist..." + } + return ( +
+ {/* Backdrop */} +
+ + {/* Modal */} +
+
+ {/* Header */} +
+

+ Import {mainGameName} e-amusement Data +

+

+ Follow the instructions below to import your data +

+
+ + {/* Warning */} +
+

+ You may or may need to be subscribed to{" "} + + KONAMI's e-amusement Basic and/or Premium course + {" "} + to view a exportable playdata history for certain games. +

+
+ + {/* Instructions */} +
+

+ Instructions: +

+
    +
  1. + Log into the{" "} + + {mainGameName} e-amusement page + +
  2. +
  3. + Navigate to the{" "} + + {mainGameName} Play History Page + {" "} +
  4. +
  5. + Install the relevant userscript (use a browser extension such as{" "} + Tampermonkey) +
  6. + {/* Additional Info */} +
    +

    + {scripts.map(userscript => ( + + {userscript.name} + + ))} +

    +
    +
  7. + A button will appear on the page that you can click to start the scraping process. +
  8. +
  9. + Upload the resulting JSON file into Mirage using the + Batch-Manual Upload functionality +
  10. +
  11. Verify that all data has been imported correctly
  12. +
+
+ + {/* Actions */} +
+ +
+
+
+
+ ); +}; + +export default EamusementUserscriptModal; diff --git a/frontend/src/pages/Import.tsx b/frontend/src/pages/Import.tsx index c72f597..f798b51 100644 --- a/frontend/src/pages/Import.tsx +++ b/frontend/src/pages/Import.tsx @@ -5,10 +5,10 @@ import SessionExpiredPopup from "../components/SessionExpiredPopup"; import type { SupportedGame } from "../types/game"; import { uploadScore } from "../utils/scoreUpload"; import { NavBar } from "../components/NavBar"; +import { EamusementUserscriptCard } from "../components/modals/EamusementUserscriptModal"; const JsonUploadModal = lazy(() => import("../components/modals/JsonUploadModal")); -const DancerushModal = lazy(() => import("../components/modals/DancerushModal")); -const DanceAroundModal = lazy(() => import("../components/modals/DanceAroundModal")); +const EamusementUserscriptModal = lazy(() => import("../components/modals/EamusementUserscriptModal")); const DivaNetModal = lazy(() => import("../components/modals/DivaNetModal")); const MusicDiverModal = lazy(() => import("../components/modals/MusicDiverModal")); @@ -128,19 +128,15 @@ const Import = () => {
); - // Component removed - moved to EamusementModal.tsx - const renderImportOptions = () => { switch (selectedGame) { case "dancerush": return ( <> - {}} - game={supportedGames.find((g) => g.internalName === selectedGame)} - renderAsCard={() => setIsDancerushModalOpen(true)} + setIsDancerushModalOpen(true)} /> ); @@ -148,11 +144,9 @@ const Import = () => { return ( <> - {}} - game={supportedGames.find((g) => g.internalName === selectedGame)} - renderAsCard={() => setIsDanceAroundModalOpen(true)} + setIsDanceAroundModalOpen(true)} /> ); @@ -300,23 +294,29 @@ const Import = () => { /> )} {isDancerushModalOpen && ( - setIsDancerushModalOpen(false)} - game={ - supportedGames.find((g) => g.internalName === selectedGame) || - undefined - } + mainGameName="DANCERUSH" + userPage="https://p.eagate.573.jp/game/dan/1st/top/entrance.html" + importPage="https://p.eagate.573.jp/game/dan/1st/top/index.html#play_his" + scripts={[{ + name: "e-amusement Recently Played Score Export Userscript (Last 20 Played)", + url: "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/dancerush/dancerush_play_history.user.js" + }]} /> )} {isDanceAroundModalOpen && ( - setIsDanceAroundModalOpen(false)} - game={ - supportedGames.find((g) => g.internalName === selectedGame) || - undefined - } + mainGameName="DANCE aROUND" + userPage="https://p.eagate.573.jp/game/around/1st/top/index.html" + importPage="https://p.eagate.573.jp/game/around/1st/top/index.html#play_hist" + scripts={[{ + name: "e-amusement Recently Played Score Export Userscript (Last 20 Played)", + url: "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/dancearound/dancearound_play_history.user.js" + }]} /> )} {isDivaNetModalOpen && ( -- cgit v1.2.3