feat: improve Clipboard Sniffer extension integration and UI fixes
This commit is contained in:
34
extension/popup.js
Normal file
34
extension/popup.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// popup.js
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const soundToggle = document.getElementById('soundToggle');
|
||||
|
||||
// Load saved setting
|
||||
chrome.storage.local.get(['playSound'], (result) => {
|
||||
soundToggle.checked = result.playSound !== false; // Default to true
|
||||
});
|
||||
|
||||
// Save setting on change
|
||||
soundToggle.addEventListener('change', () => {
|
||||
chrome.storage.local.set({ playSound: soundToggle.checked });
|
||||
|
||||
// Play test sound if enabled
|
||||
if (soundToggle.checked) {
|
||||
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
const oscillator = audioContext.createOscillator();
|
||||
const gainNode = audioContext.createGain();
|
||||
|
||||
oscillator.connect(gainNode);
|
||||
gainNode.connect(audioContext.destination);
|
||||
|
||||
oscillator.type = 'sine';
|
||||
oscillator.frequency.setValueAtTime(500, audioContext.currentTime);
|
||||
oscillator.frequency.exponentialRampToValueAtTime(1000, audioContext.currentTime + 0.1);
|
||||
|
||||
gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
|
||||
gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.1);
|
||||
|
||||
oscillator.start();
|
||||
oscillator.stop(audioContext.currentTime + 0.1);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user