Initial release: PokeRogue Type Effectiveness extension
Chrome/Firefox MV3 extension that shows move type effectiveness during PokeRogue battles. Features: - Auto-detects battle state via Phaser game bridge (MAIN world) - Shows effectiveness multiplier, base power, and physical/special category - Supports single and double battles - Manual type calculator mode as fallback - Draggable overlay with dark theme matching PokeRogue aesthetic - Settings popup with position, opacity, and display options - Complete Gen 6+ type chart (18 types) from PokeRogue source data - Type colors matching PokeRogue's own color scheme
This commit is contained in:
246
popup/popup.css
Normal file
246
popup/popup.css
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* PokeRogue Type Effectiveness - Popup Styles
|
||||
*/
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 280px;
|
||||
background: #1a1a2e;
|
||||
color: #e0e0e0;
|
||||
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.popup {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
/* ─── Header ──────────────────────────────────────────────────── */
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.popup-icon {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.popup-subtitle {
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
/* ─── Sections ────────────────────────────────────────────────── */
|
||||
|
||||
.popup-section {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.popup-label {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #888;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.popup-hint {
|
||||
font-size: 10px;
|
||||
color: #666;
|
||||
margin-top: 3px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.popup-divider {
|
||||
height: 1px;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
/* ─── Toggle Switch ───────────────────────────────────────────── */
|
||||
|
||||
.popup-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.popup-toggle input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.toggle-slider {
|
||||
width: 36px;
|
||||
height: 20px;
|
||||
background: #333;
|
||||
border-radius: 10px;
|
||||
position: relative;
|
||||
transition: background 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.toggle-slider::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: #888;
|
||||
border-radius: 50%;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.popup-toggle input:checked + .toggle-slider {
|
||||
background: #4AA500;
|
||||
}
|
||||
|
||||
.popup-toggle input:checked + .toggle-slider::after {
|
||||
left: 18px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
font-size: 13px;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
/* ─── Position Grid ───────────────────────────────────────────── */
|
||||
|
||||
.popup-position-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.pos-btn {
|
||||
padding: 6px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 6px;
|
||||
color: #aaa;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.pos-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.pos-btn.active {
|
||||
background: rgba(74, 165, 0, 0.2);
|
||||
border-color: #4AA500;
|
||||
color: #4AA500;
|
||||
}
|
||||
|
||||
/* ─── Range Slider ────────────────────────────────────────────── */
|
||||
|
||||
.popup-slider {
|
||||
width: 100%;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
height: 4px;
|
||||
background: #333;
|
||||
border-radius: 2px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.popup-slider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background: #4AA500;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
transition: transform 0.1s;
|
||||
}
|
||||
|
||||
.popup-slider::-webkit-slider-thumb:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
.popup-slider::-moz-range-thumb {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background: #4AA500;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ─── Checkboxes ──────────────────────────────────────────────── */
|
||||
|
||||
.popup-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 3px 0;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.popup-checkbox input {
|
||||
accent-color: #4AA500;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
/* ─── Footer ──────────────────────────────────────────────────── */
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 12px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.popup-btn {
|
||||
padding: 5px 14px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 6px;
|
||||
color: #ccc;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.popup-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.14);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.popup-version {
|
||||
font-size: 10px;
|
||||
color: #555;
|
||||
}
|
||||
86
popup/popup.html
Normal file
86
popup/popup.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>PokeRogue Type Effectiveness</title>
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="popup">
|
||||
<div class="popup-header">
|
||||
<img src="../icons/icon-32.png" alt="icon" class="popup-icon">
|
||||
<div>
|
||||
<h1 class="popup-title">Type Effectiveness</h1>
|
||||
<p class="popup-subtitle" id="statusText">Connecting...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="popup-section">
|
||||
<label class="popup-toggle">
|
||||
<input type="checkbox" id="enableToggle" checked>
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Enable Overlay</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="popup-section">
|
||||
<label class="popup-toggle">
|
||||
<input type="checkbox" id="manualMode">
|
||||
<span class="toggle-slider"></span>
|
||||
<span class="toggle-label">Manual Mode</span>
|
||||
</label>
|
||||
<p class="popup-hint">Use type calculator instead of auto-detection</p>
|
||||
</div>
|
||||
|
||||
<div class="popup-divider"></div>
|
||||
|
||||
<div class="popup-section">
|
||||
<label class="popup-label">Position</label>
|
||||
<div class="popup-position-grid">
|
||||
<button class="pos-btn" data-pos="top-left" title="Top Left">↖</button>
|
||||
<button class="pos-btn" data-pos="top-right" title="Top Right">↗</button>
|
||||
<button class="pos-btn" data-pos="bottom-left" title="Bottom Left">↙</button>
|
||||
<button class="pos-btn" data-pos="bottom-right" title="Bottom Right">↘</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="popup-section">
|
||||
<label class="popup-label">
|
||||
Opacity
|
||||
<span id="opacityValue">90%</span>
|
||||
</label>
|
||||
<input type="range" id="opacitySlider" min="30" max="100" value="90" class="popup-slider">
|
||||
</div>
|
||||
|
||||
<div class="popup-divider"></div>
|
||||
|
||||
<div class="popup-section">
|
||||
<label class="popup-label">Display Options</label>
|
||||
<label class="popup-checkbox">
|
||||
<input type="checkbox" id="showMoveNames" checked>
|
||||
<span>Show move names</span>
|
||||
</label>
|
||||
<label class="popup-checkbox">
|
||||
<input type="checkbox" id="showPower" checked>
|
||||
<span>Show base power</span>
|
||||
</label>
|
||||
<label class="popup-checkbox">
|
||||
<input type="checkbox" id="showCategory" checked>
|
||||
<span>Show physical/special</span>
|
||||
</label>
|
||||
<label class="popup-checkbox">
|
||||
<input type="checkbox" id="compactMode">
|
||||
<span>Compact mode</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="popup-footer">
|
||||
<button id="refreshBtn" class="popup-btn">Refresh</button>
|
||||
<span class="popup-version">v1.0.0</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
168
popup/popup.js
Normal file
168
popup/popup.js
Normal file
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* PokeRogue Type Effectiveness - Popup Script
|
||||
* Handles settings UI and communicates with content script
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const storage = (typeof browser !== 'undefined' && browser.storage)
|
||||
? browser.storage
|
||||
: chrome.storage;
|
||||
const tabs = (typeof browser !== 'undefined' && browser.tabs)
|
||||
? browser.tabs
|
||||
: chrome.tabs;
|
||||
|
||||
const DEFAULT_SETTINGS = {
|
||||
enabled: true,
|
||||
position: 'top-right',
|
||||
opacity: 90,
|
||||
showPower: true,
|
||||
showCategory: true,
|
||||
showMoveNames: true,
|
||||
compactMode: false,
|
||||
manualMode: false,
|
||||
manualEnemyTypes: []
|
||||
};
|
||||
|
||||
// DOM elements
|
||||
const enableToggle = document.getElementById('enableToggle');
|
||||
const manualMode = document.getElementById('manualMode');
|
||||
const opacitySlider = document.getElementById('opacitySlider');
|
||||
const opacityValue = document.getElementById('opacityValue');
|
||||
const showMoveNames = document.getElementById('showMoveNames');
|
||||
const showPower = document.getElementById('showPower');
|
||||
const showCategory = document.getElementById('showCategory');
|
||||
const compactMode = document.getElementById('compactMode');
|
||||
const refreshBtn = document.getElementById('refreshBtn');
|
||||
const statusText = document.getElementById('statusText');
|
||||
const posButtons = document.querySelectorAll('.pos-btn');
|
||||
|
||||
let currentSettings = { ...DEFAULT_SETTINGS };
|
||||
|
||||
// ─── Load Settings ─────────────────────────────────────────────
|
||||
|
||||
function loadSettings() {
|
||||
storage.local.get(['settings'], (result) => {
|
||||
currentSettings = { ...DEFAULT_SETTINGS, ...result.settings };
|
||||
applyToUI(currentSettings);
|
||||
});
|
||||
}
|
||||
|
||||
function applyToUI(s) {
|
||||
enableToggle.checked = s.enabled;
|
||||
manualMode.checked = s.manualMode;
|
||||
opacitySlider.value = s.opacity;
|
||||
opacityValue.textContent = s.opacity + '%';
|
||||
showMoveNames.checked = s.showMoveNames;
|
||||
showPower.checked = s.showPower;
|
||||
showCategory.checked = s.showCategory;
|
||||
compactMode.checked = s.compactMode;
|
||||
|
||||
posButtons.forEach(btn => {
|
||||
btn.classList.toggle('active', btn.dataset.pos === s.position);
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Save Settings ─────────────────────────────────────────────
|
||||
|
||||
function saveSettings() {
|
||||
currentSettings = {
|
||||
...currentSettings,
|
||||
enabled: enableToggle.checked,
|
||||
manualMode: manualMode.checked,
|
||||
opacity: parseInt(opacitySlider.value),
|
||||
showMoveNames: showMoveNames.checked,
|
||||
showPower: showPower.checked,
|
||||
showCategory: showCategory.checked,
|
||||
compactMode: compactMode.checked
|
||||
};
|
||||
|
||||
storage.local.set({ settings: currentSettings });
|
||||
}
|
||||
|
||||
// ─── Event Listeners ───────────────────────────────────────────
|
||||
|
||||
enableToggle.addEventListener('change', saveSettings);
|
||||
manualMode.addEventListener('change', saveSettings);
|
||||
showMoveNames.addEventListener('change', saveSettings);
|
||||
showPower.addEventListener('change', saveSettings);
|
||||
showCategory.addEventListener('change', saveSettings);
|
||||
compactMode.addEventListener('change', saveSettings);
|
||||
|
||||
opacitySlider.addEventListener('input', () => {
|
||||
opacityValue.textContent = opacitySlider.value + '%';
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
posButtons.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
posButtons.forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
currentSettings.position = btn.dataset.pos;
|
||||
saveSettings();
|
||||
|
||||
// Reset overlay position so it re-applies the new corner
|
||||
sendToContentScript({
|
||||
type: 'UPDATE_SETTINGS',
|
||||
settings: { ...currentSettings, _resetPosition: true }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
refreshBtn.addEventListener('click', () => {
|
||||
sendToContentScript({ type: 'REQUEST_REFRESH' });
|
||||
refreshBtn.textContent = 'Refreshed!';
|
||||
setTimeout(() => {
|
||||
refreshBtn.textContent = 'Refresh';
|
||||
}, 800);
|
||||
});
|
||||
|
||||
// ─── Communication ─────────────────────────────────────────────
|
||||
|
||||
function sendToContentScript(message) {
|
||||
tabs.query({ active: true, currentWindow: true }, (tabList) => {
|
||||
if (tabList && tabList[0]) {
|
||||
const sendMsg = (typeof browser !== 'undefined' && browser.tabs)
|
||||
? browser.tabs.sendMessage
|
||||
: chrome.tabs.sendMessage;
|
||||
sendMsg(tabList[0].id, message, () => {
|
||||
// Ignore errors (content script may not be loaded)
|
||||
if (chrome.runtime.lastError) { /* intentional */ }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getStatus() {
|
||||
tabs.query({ active: true, currentWindow: true }, (tabList) => {
|
||||
if (!tabList || !tabList[0]) {
|
||||
statusText.textContent = 'No active tab';
|
||||
return;
|
||||
}
|
||||
|
||||
const url = tabList[0].url || '';
|
||||
if (!url.includes('pokerogue.net')) {
|
||||
statusText.textContent = 'Navigate to pokerogue.net';
|
||||
return;
|
||||
}
|
||||
|
||||
const sendMsg = (typeof browser !== 'undefined' && browser.tabs)
|
||||
? browser.tabs.sendMessage
|
||||
: chrome.tabs.sendMessage;
|
||||
sendMsg(tabList[0].id, { type: 'GET_STATUS' }, (response) => {
|
||||
if (chrome.runtime.lastError || !response) {
|
||||
statusText.textContent = 'Extension loading...';
|
||||
return;
|
||||
}
|
||||
statusText.textContent = response.status || 'Connected';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Init ──────────────────────────────────────────────────────
|
||||
|
||||
loadSettings();
|
||||
getStatus();
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user