Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hip-squids-ask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'elden-ring-github': minor
---

feat: add lost grace discovered support
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ Access settings by clicking the extension icon:
- **πŸ†• Show on PR creation**: Toggle banner display when PRs are created
- **βœ… Show on PR approve**: Toggle banner display when PRs are approved
- **πŸ”Š Play sound effect**: Toggle the iconic Elden Ring achievement sound
- **🎡 Sound Type**: Choose between different celebration sounds:
- **You Died** - The classic defeat sound
- **Lost Grace Discovered** - The grace discovery sound
- **⏱️ Banner Duration**: Choose how long celebrations last (3-10 seconds)
- **πŸ“Š Page Status**: See if you're currently on a GitHub page
- **πŸ§ͺ Test Banner**: Preview the banner effect anytime
Expand Down Expand Up @@ -99,7 +102,8 @@ src/
β”‚ β”œβ”€β”€ settings.ts # Settings interface
β”‚ └── global.d.ts # Global type declarations
└── assets/ # Static resources
β”œβ”€β”€ elden_ring_sound.mp3
β”œβ”€β”€ you-die-sound.mp3 # "You Died" sound effect
β”œβ”€β”€ lost-grace-discovered.mp3 # Lost Grace discovery sound
β”œβ”€β”€ pull-request-created.png # PR creation banner
β”œβ”€β”€ pull-request-merged.png # PR merge banner
β”œβ”€β”€ approve-pull-request.webp # PR approval banner
Expand Down
Binary file added src/assets/lost-grace-discovered.mp3
Binary file not shown.
File renamed without changes.
18 changes: 17 additions & 1 deletion src/content/content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ describe('EldenRingMerger', () => {
global.Audio = vi.fn().mockImplementation(() => mockAudio);
global.chrome.runtime.getURL = vi.fn(() => 'chrome-extension://mock/sound.mp3');

const audio = new Audio(chrome.runtime.getURL('assets/elden_ring_sound.mp3'));
const soundType = 'you-die-sound';
const audio = new Audio(chrome.runtime.getURL(`assets/${soundType}.mp3`));
audio.volume = 0.35;
audio.play();

Expand All @@ -162,6 +163,21 @@ describe('EldenRingMerger', () => {
expect(mockAudio.volume).toBe(0.35);
});

it('should support sound type selection', () => {
const soundTypes: Array<'you-die-sound' | 'lost-grace-discovered'> = [
'you-die-sound',
'lost-grace-discovered',
];

soundTypes.forEach((soundType) => {
const expectedPath = `assets/${soundType}.mp3`;
expect(expectedPath).toContain('.mp3');
expect(expectedPath).toContain(soundType);
});

expect(soundTypes.length).toBe(2);
});

it('should add event listeners to merge buttons', () => {
// Setup DOM with merge button
document.body.innerHTML = `
Expand Down
20 changes: 18 additions & 2 deletions src/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,39 @@ class EldenRingMerger {
private showOnPRMerged: boolean = true;
private showOnPRCreate: boolean = true;
private showOnPRApprove: boolean = true;
private soundType: 'you-die-sound' | 'lost-grace-discovered' = 'you-die-sound';
private soundUrl: string;

constructor() {
this.soundUrl = chrome.runtime.getURL('assets/elden_ring_sound.mp3');
this.soundUrl = this.getSoundUrl();
this.loadSettings();
this.init();
}

private getSoundUrl(): string {
return chrome.runtime.getURL(`assets/${this.soundType}.mp3`);
}

private updateSoundUrl(): void {
this.soundUrl = this.getSoundUrl();
}

private loadSettings(): void {
chrome.storage.sync.get(
['soundEnabled', 'showOnPRMerged', 'showOnPRCreate', 'showOnPRApprove'],
['soundEnabled', 'showOnPRMerged', 'showOnPRCreate', 'showOnPRApprove', 'soundType'],
(result: {
soundEnabled?: boolean;
showOnPRMerged?: boolean;
showOnPRCreate?: boolean;
showOnPRApprove?: boolean;
soundType?: 'you-die-sound' | 'lost-grace-discovered';
}) => {
this.soundEnabled = result.soundEnabled !== false; // default true
this.showOnPRMerged = result.showOnPRMerged !== false; // default true
this.showOnPRCreate = result.showOnPRCreate !== false; // default true
this.showOnPRApprove = result.showOnPRApprove !== false; // default true
this.soundType = result.soundType || 'you-die-sound'; // default you-die-sound
this.updateSoundUrl();
},
);

Expand All @@ -43,6 +55,10 @@ class EldenRingMerger {
if (changes.showOnPRApprove) {
this.showOnPRApprove = changes.showOnPRApprove.newValue;
}
if (changes.soundType) {
this.soundType = changes.soundType.newValue;
this.updateSoundUrl();
}
},
);
}
Expand Down
11 changes: 10 additions & 1 deletion src/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
Play sound effect
</label>
</div>
<div class="setting-item">
<label class="setting-label">
Sound Type:
<select id="soundType">
<option value="you-die-sound" selected>You Died</option>
<option value="lost-grace-discovered">Lost Grace Discovered</option>
</select>
</label>
</div>
<div class="setting-item">
<label class="setting-label">
Banner Duration:
Expand All @@ -80,7 +89,7 @@
</div>

<div class="footer">
<div class="version">v1.0.0</div>
<div class="version">v1.2.0</div>
</div>
</div>

Expand Down
25 changes: 19 additions & 6 deletions src/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ document.addEventListener('DOMContentLoaded', (): void => {
const soundEnabledCheckbox = document.getElementById('soundEnabled') as HTMLInputElement;
const showOnPRCreateCheckbox = document.getElementById('showOnPRCreate') as HTMLInputElement;
const showOnPRApproveCheckbox = document.getElementById('showOnPRApprove') as HTMLInputElement;
const soundTypeSelect = document.getElementById('soundType') as HTMLSelectElement;
const durationSelect = document.getElementById('duration') as HTMLSelectElement;
const pageStatusElement = document.getElementById('pageStatus') as HTMLSpanElement;

Expand All @@ -21,6 +22,7 @@ document.addEventListener('DOMContentLoaded', (): void => {
soundEnabledCheckbox?.addEventListener('change', saveSettings);
showOnPRCreateCheckbox?.addEventListener('change', saveSettings);
showOnPRApproveCheckbox?.addEventListener('change', saveSettings);
soundTypeSelect?.addEventListener('change', saveSettings);
durationSelect?.addEventListener('change', saveSettings);

function checkCurrentPage(): void {
Expand Down Expand Up @@ -54,12 +56,20 @@ document.addEventListener('DOMContentLoaded', (): void => {

function loadSettings() {
chrome.storage.sync.get(
['showOnPRMerged', 'soundEnabled', 'showOnPRCreate', 'showOnPRApprove', 'duration'],
[
'showOnPRMerged',
'soundEnabled',
'showOnPRCreate',
'showOnPRApprove',
'soundType',
'duration',
],
function (result) {
showOnPRMergedCheckbox.checked = result.showOnPRMerged !== false; // default true
soundEnabledCheckbox.checked = result.soundEnabled !== false; // default true
showOnPRCreateCheckbox.checked = result.showOnPRCreate !== false; // default true
showOnPRApproveCheckbox.checked = result.showOnPRApprove !== false; // default true
soundTypeSelect.value = result.soundType || 'you-die-sound'; // default you-die-sound
durationSelect.value = result.duration || '5000'; // default 5 seconds
},
);
Expand All @@ -71,6 +81,7 @@ document.addEventListener('DOMContentLoaded', (): void => {
soundEnabled: soundEnabledCheckbox.checked,
showOnPRCreate: showOnPRCreateCheckbox.checked,
showOnPRApprove: showOnPRApproveCheckbox.checked,
soundType: soundTypeSelect.value,
duration: parseInt(durationSelect.value),
};

Expand All @@ -85,7 +96,7 @@ document.addEventListener('DOMContentLoaded', (): void => {
chrome.scripting.executeScript({
target: { tabId: currentTab.id! },
func: updateExtensionSettings,
args: [settings],
args: [settings as EldenRingSettings],
});
}
});
Expand All @@ -109,9 +120,10 @@ function createAndShowBanner(): boolean {
document.body.appendChild(banner);

// Play sound effect if enabled
chrome.storage.sync.get(['soundEnabled'], function (soundResult) {
chrome.storage.sync.get(['soundEnabled', 'soundType'], function (soundResult) {
if (soundResult.soundEnabled !== false) {
const audio = new Audio(chrome.runtime.getURL('assets/elden_ring_sound.mp3'));
const soundType = soundResult.soundType || 'you-die-sound';
const audio = new Audio(chrome.runtime.getURL(`assets/${soundType}.mp3`));
audio.volume = 0.35;
audio.play().catch((err) => console.log('Sound playback failed:', err));
}
Expand Down Expand Up @@ -154,9 +166,10 @@ function createAndShowBanner(): boolean {
document.body.appendChild(banner);

// Play sound effect if enabled
chrome.storage.sync.get(['soundEnabled'], function (soundResult) {
chrome.storage.sync.get(['soundEnabled', 'soundType'], function (soundResult) {
if (soundResult.soundEnabled !== false) {
const audio = new Audio(chrome.runtime.getURL('assets/elden_ring_sound.mp3'));
const soundType = soundResult.soundType || 'you-die-sound';
const audio = new Audio(chrome.runtime.getURL(`assets/${soundType}.mp3`));
audio.volume = 0.35;
audio.play().catch((err) => console.log('Sound playback failed:', err));
}
Expand Down
1 change: 1 addition & 0 deletions src/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface EldenRingSettings {
duration?: number;
showOnPRCreate?: boolean;
showOnPRApprove?: boolean;
soundType?: 'you-die-sound' | 'lost-grace-discovered';
}