add diva.net script instructions to import page

This commit is contained in:
Pinapelz
2025-10-12 17:31:06 -07:00
parent fc206b5245
commit a2dd1a1f29
4 changed files with 221 additions and 39 deletions
@@ -0,0 +1,128 @@
import type { SupportedGame } from "../../types/game";
interface DivaNetModalProps {
isOpen: boolean;
onClose: () => void;
game: SupportedGame | undefined;
renderAsCard?: () => void;
}
const DivaNetModal = ({
isOpen,
onClose,
game,
renderAsCard
}: DivaNetModalProps) => {
if (renderAsCard) {
return (
<div className="bg-slate-800 rounded-lg border border-slate-700 p-6 hover:border-violet-500 transition-colors">
<div className="w-12 h-12 bg-green-600/20 rounded-lg flex items-center justify-center mb-4">
<svg
className="w-6 h-6 text-green-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg>
</div>
<h4 className="text-white font-semibold mb-2">
DIVA.NET Play History
</h4>
<p className="text-slate-400 text-sm mb-4">
Import via scraping your playdata from SEGA DIVA.NET
</p>
<button
onClick={renderAsCard}
className="w-full bg-green-600 hover:bg-green-700 text-white py-2 px-3 sm:px-4 rounded-md text-sm sm:text-base font-medium transition-colors"
>
Export DIVA.NET
</button>
</div>
);
}
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 (
<div className="fixed inset-0 z-50 overflow-y-auto">
{/* Backdrop */}
<div
className="fixed inset-0 bg-black/50 backdrop-blur-sm transition-opacity"
onClick={handleClose}
/>
{/* Modal */}
<div className="flex min-h-full items-center justify-center p-4">
<div className="relative bg-slate-900 rounded-lg border border-slate-700 w-full max-w-xl p-6 shadow-xl">
{/* Header */}
<div className="mb-6">
<h3 className="text-xl font-bold text-white mb-2">
Import {game.formattedName} Data
</h3>
<p className="text-slate-400 text-sm">
Follow the instructions below to import your data
</p>
</div>
{/* Instructions */}
<div className="mb-4 rounded-md bg-slate-800 border border-slate-700 p-4">
<h4 className="text-sm font-semibold text-slate-300 mb-2">
Instructions:
</h4>
<ol className="text-sm text-slate-400 space-y-1 list-decimal list-inside">
<li>Log into your DIVA.NET account</li>
<li>
Navigate to the Play History () Page
</li>
<li>
Install the userscript to your browser (use an extension such
as Tampermonkey).
</li>
<li>
A button will appear on the page that you can click to start the scraping process.
</li>
<li>Upload the resulting JSON file into Mirage using the Batch-Manual Upload functionality</li>
<li>Verify that all data has been imported correctly</li>
</ol>
</div>
{/* Additional Info */}
<div className="mb-6 rounded-md bg-blue-500/10 border border-blue-500/20 p-3">
<p className="text-sm text-blue-400">
<a
href="https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/projectdiva-arcade/diva_net_history.user.js"
className="underline"
>
DIVA.NET Score Export Userscript
</a>
</p>
</div>
{/* Actions */}
<div className="flex justify-center">
<button
onClick={handleClose}
className="px-6 py-2 bg-violet-600 hover:bg-violet-700 text-white rounded-md font-medium transition-colors"
>
Got it
</button>
</div>
</div>
</div>
</div>
);
};
export default DivaNetModal;
@@ -5,13 +5,54 @@ interface EamusementUploadModalProps {
isOpen: boolean;
onClose: () => void;
game: SupportedGame | undefined;
renderAsCard?: () => void;
}
const scriptLinkMap = {
"dancerush": "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/dancerush/dancerush_play_history.user.js",
"dancearound": "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/dancearound/dancearound_play_history.user.js",
}
const EamusementUploadModal = ({
isOpen,
onClose,
game,
renderAsCard
}: EamusementUploadModalProps) => {
if (renderAsCard) {
return (
<div className="bg-slate-800 rounded-lg border border-slate-700 p-6 hover:border-violet-500 transition-colors">
<div className="w-12 h-12 bg-blue-600/20 rounded-lg flex items-center justify-center mb-4">
<svg
className="w-6 h-6 text-blue-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg>
</div>
<h4 className="text-white font-semibold mb-2">
e-amusement Play History
</h4>
<p className="text-slate-400 text-sm mb-4">
Import via scraping your playdata from KONAMI e-amusement
</p>
<button
onClick={renderAsCard}
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-3 sm:px-4 rounded-md text-sm sm:text-base font-medium transition-colors"
>
Export e-amusement
</button>
</div>
);
}
if (!isOpen) return null;
const handleClose = () => {
@@ -92,8 +133,12 @@ const EamusementUploadModal = ({
{/* Additional Info */}
<div className="mb-6 rounded-md bg-blue-500/10 border border-blue-500/20 p-3">
<p className="text-sm text-blue-400">
This feature is currently under development. Please check back
later for the full implementation.
<a
href={scriptLinkMap[game.internalName as keyof typeof scriptLinkMap]}
className="underline"
>
{game.formattedName} Userscript Download
</a>
</p>
</div>
+46 -37
View File
@@ -7,6 +7,7 @@ import SessionExpiredPopup from "../components/SessionExpiredPopup";
import type { SupportedGame } from "../types/game";
import { uploadScore } from "../utils/scoreUpload";
import { NavBar } from "../components/NavBar";
import DivaNetModal from "../components/modals/DivaNetModal";
const Import = () => {
const { user, isLoading, logout } = useAuth();
@@ -14,6 +15,7 @@ const Import = () => {
const [selectedGame, setSelectedGame] = useState("");
const [isJsonModalOpen, setIsJsonModalOpen] = useState(false);
const [isEamusementModalOpen, setIsEamusementModalOpen] = useState(false);
const [isDivaNetModalOpen, setIsDivaNetModalOpen] = useState(false);
const [supportedGames, setSupportedGames] = useState<SupportedGame[]>([]);
const [gamesLoading, setGamesLoading] = useState(true);
const [uploadStatus, setUploadStatus] = useState<{
@@ -121,52 +123,49 @@ const Import = () => {
</div>
);
const EamusementScrapeUploadCard = () => (
<>
{/* e-amusement Card */}
<div className="bg-slate-800 rounded-lg border border-slate-700 p-6 hover:border-violet-500 transition-colors">
<div className="w-12 h-12 bg-blue-600/20 rounded-lg flex items-center justify-center mb-4">
<svg
className="w-6 h-6 text-blue-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg>
</div>
<h4 className="text-white font-semibold mb-2">
e-amusement Play History
</h4>
<p className="text-slate-400 text-sm mb-4">
Import via scraping your playdata from KONAMI e-amusement
</p>
<button
onClick={() => setIsEamusementModalOpen(true)}
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-3 sm:px-4 rounded-md text-sm sm:text-base font-medium transition-colors"
>
Connect e-amusement
</button>
</div>
</>
);
// Component removed - moved to EamusementModal.tsx
const renderImportOptions = () => {
switch (selectedGame) {
case "dancerush":
return (
<>
{/* JSON Upload Card */}
<JsonUploadCard />
<EamusementScrapeUploadCard />
<EamusementModal
isOpen={false}
onClose={() => {}}
game={supportedGames.find((g) => g.internalName === selectedGame)}
renderAsCard={() => setIsEamusementModalOpen(true)}
/>
</>
);
break;
case "dancearound":
return (
<>
<JsonUploadCard />
<EamusementModal
isOpen={false}
onClose={() => {}}
game={supportedGames.find((g) => g.internalName === selectedGame)}
renderAsCard={() => setIsEamusementModalOpen(true)}
/>
</>
);
break;
case "diva":
return (
<>
<JsonUploadCard />
<DivaNetModal
isOpen={false}
onClose={() => {}}
game={supportedGames.find((g) => g.internalName === selectedGame)}
renderAsCard={() => setIsDivaNetModalOpen(true)}
/>
</>
);
break;
default:
return <JsonUploadCard />;
}
@@ -293,6 +292,16 @@ const Import = () => {
undefined
}
/>
{/* DivaNet Modal */}
<DivaNetModal
isOpen={isDivaNetModalOpen}
onClose={() => setIsDivaNetModalOpen(false)}
game={
supportedGames.find((g) => g.internalName === selectedGame) ||
undefined
}
/>
</div>
);
};