First Commit, Code by Claude 4.7 Opus

This commit is contained in:
Tronax 2026-05-14 00:10:32 +02:00
commit ec216264b1
4 changed files with 171 additions and 0 deletions

47
content.js Normal file
View file

@ -0,0 +1,47 @@
let gainNode = null;
let audioCtx = null;
let sourceMap = new WeakMap();
function setVolume(percent) {
const factor = percent / 100;
document.querySelectorAll('video, audio').forEach(el => {
if (!sourceMap.has(el)) {
if (!audioCtx) {
audioCtx = new AudioContext();
}
try {
const src = audioCtx.createMediaElementSource(el);
const gain = audioCtx.createGain();
src.connect(gain);
gain.connect(audioCtx.destination);
sourceMap.set(el, gain);
} catch (e) {
// Element bereits in einem anderen Context
return;
}
}
sourceMap.get(el).gain.value = factor;
});
}
// Beim Laden: gespeicherten Wert anwenden
chrome.storage.local.get('volume', ({ volume }) => {
if (volume !== undefined) setVolume(volume);
});
// Auf Nachrichten vom Popup hören
chrome.runtime.onMessage.addListener(({ volume }) => {
if (volume !== undefined) setVolume(volume);
});
// Neue Media-Elemente automatisch erfassen
const observer = new MutationObserver(() => {
chrome.storage.local.get('volume', ({ volume }) => {
if (volume !== undefined && volume !== 100) {
setVolume(volume);
}
});
});
observer.observe(document.body, {
childList: true, subtree: true
});

17
manifest.json Normal file
View file

@ -0,0 +1,17 @@
{
"manifest_version": 3,
"name": "Volume Booster",
"version": "1.0",
"description": "Boost audio up to 600%",
"permissions": ["activeTab", "storage"],
"action": {
"default_popup": "popup.html",
"default_title": "Volume Booster"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}

69
popup.html Normal file
View file

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
width: 240px;
font-family: -apple-system, sans-serif;
background: #1c1c1e;
color: #fff;
padding: 16px;
}
h1 {
font-size: 13px;
font-weight: 500;
margin-bottom: 16px;
color: rgba(255,255,255,0.6);
letter-spacing: 0.5px;
}
.value {
font-size: 36px;
font-weight: 600;
line-height: 1;
margin-bottom: 16px;
}
.value span { font-size: 18px; color: rgba(255,255,255,0.5); }
input[type=range] {
width: 100%;
accent-color: #30d158;
margin-bottom: 6px;
}
.marks {
display: flex;
justify-content: space-between;
font-size: 10px;
color: rgba(255,255,255,0.3);
margin-bottom: 16px;
}
button {
width: 100%;
padding: 8px;
background: rgba(255,255,255,0.06);
border: none;
border-radius: 8px;
color: rgba(255,255,255,0.6);
font-size: 12px;
cursor: pointer;
}
button:hover { background: rgba(255,255,255,0.1); }
</style>
</head>
<body>
<h1>VOLUME BOOSTER</h1>
<div class="value">
<span id="display">100</span><span>%</span>
</div>
<input type="range" id="slider"
min="0" max="600" step="1" value="100">
<div class="marks">
<span>0%</span>
<span>200%</span>
<span>400%</span>
<span>600%</span>
</div>
<button id="reset">↺ Zurücksetzen</button>
<script src="popup.js"></script>
</body>
</html>

38
popup.js Normal file
View file

@ -0,0 +1,38 @@
const slider = document.getElementById('slider');
const display = document.getElementById('display');
const reset = document.getElementById('reset');
// Gespeicherten Wert laden
chrome.storage.local.get('volume', ({ volume }) => {
const val = volume ?? 100;
slider.value = val;
display.textContent = val;
});
// Schieberegler bewegen
slider.addEventListener('input', () => {
const val = parseInt(slider.value);
display.textContent = val;
chrome.storage.local.set({ volume: val });
// Aktiven Tab anweisen
chrome.tabs.query(
{ active: true, currentWindow: true },
([tab]) => {
chrome.tabs.sendMessage(tab.id, { volume: val });
}
);
});
// Zurücksetzen auf 100%
reset.addEventListener('click', () => {
slider.value = 100;
display.textContent = 100;
chrome.storage.local.set({ volume: 100 });
chrome.tabs.query(
{ active: true, currentWindow: true },
([tab]) => {
chrome.tabs.sendMessage(tab.id, { volume: 100 });
}
);
});