How to Install scripts? (Click here)
If you like my work, please consider supporting it! (Cryptos / Patreon / Ko-Fi / BuyMeACoffee https://cyber-sec0.github.io)
📢 Why You Need This Script
Tired of "Audio Clutter"?
You are listening to music on YouTube. You open a new tab to watch a quick news clip or a Twitter video. Suddenly, both are blasting audio at the same time. You have to frantically hunt for the music tab to pause it, watch your clip, and then go back to unpause it.
Stop doing that manually.
Audio Master is your browser's intelligent sound engineer. It creates a seamless, single-stream audio experience across all your tabs.
- ⚡ Zero Effort: Just play a video. The script instantly silences everything else.
- 🧠 It Remembers: Paused your new video? The script remembers what you were listening to before and automatically resumes it for you.
- 👁️ "God Mode" Detection: Unlike other scripts that fail on complex websites, this uses advanced Prototype Hijacking to detect ANY audio source—including Shadow DOMs, IFrames, and even Browser Games (Web Audio API).
Make your browser smarter today.
And stop using random extensions that also "Auto Mute Tabs When Multiple Tabs Audible".
🛠️ How It Works (Example)
Imagine you have Limit set to 20 (default):
- Tab A: You are jamming to Spotify/YouTube Music.
- Tab B: You open a Reddit thread and play a funny video.
👉 Action: Tab A (Music) instantly Mutes. Tab B becomes the "Master".
Tab B: You finish the video and hit Pause.
👉 Action: The script looks at its history, sees Tab A was playing before, and Unmutes it instantly.
Your music flows back in automatically. No clicking required.
⚙️ Important Setup Instructions
1. Customize Your History (Stack Limit)
The script remembers your audio history (the "Stack"). By default, it remembers the last 20 active audio tabs.
- To Change this: Click the Tampermonkey Icon in your browser toolbar -> Select "Set Stack Limit".
- Enter a number (e.g.,
5 or 20). This ensures the script knows exactly how far back in your history to auto-resume.
2. Enable Private Mode Sync (Incognito)
Do you want your Normal windows to mute when you play something in a Private/Incognito window? You must change one setting in Tampermonkey:
- Open the Tampermonkey Dashboard.
- Go to the Settings tab.
- Scroll down to Security.
- Find "Store data in incognito mode".
- Change it from Temporary to Permanent.
This allows the script to share the "Audio Status" between your private and normal sessions, giving you total control over your browser's sound.
Personal Dev notes
Code versions that don't require changing TM settings to work for normal/private browsing interoperability.
Hybrid FAST version using both JSONBlob and GOD MODE hijacking for normal/private browsing interoperability
// ==UserScript==
// @name Audio Master: Smart Hybrid (v29)
// @namespace http://tampermonkey.net/
// @version 29.0
// @description Instant local sync for Normal tabs. Cloud sync ONLY for Private tabs.
// @author hacker09
// @match *://*/*
// @tag MINE!
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addValueChangeListener
// @connect jsonblob.com
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// --- CONFIG ---
// You can use this ID or generate a new UUID online
const BLOB_ID = "019b30e4-5058-73ba-b777-378a27d19e5e";
const BLOB_URL = `https://api.jsonblob.com/api/jsonBlob/${BLOB_ID}`;
const POLL_RATE = 2000;
const TAB_ID = Math.random().toString(36).slice(2) + "-" + Date.now();
const MAX_STACK = 20;
// --- 1. PRIVATE MODE DETECTION ---
let isPrivate = false;
// A simple, non-intrusive check:
// In Tampermonkey, Private tabs usually have empty storage compared to Normal tabs.
// We can also try a FileSystem check (Chrome specific):
if ('storage' in navigator && 'estimate' in navigator.storage) {
navigator.storage.estimate().then(estimate => {
// Incognito usually has a quota < 120MB (approx 1.2e+8)
if (estimate.quota < 120000000) {
isPrivate = true;
console.log("Audio Master: Incognito Detected. Enabling Cloud Sync.");
startCloudSync();
} else {
console.log("Audio Master: Normal Mode Detected. Local Sync Only.");
}
});
}
// --- 2. LOCAL ENGINE (Instant) ---
function getLocalStack() {
return GM_getValue('audioStack', []);
}
function updateLocalStack(action) {
let stack = getLocalStack();
stack = stack.filter(id => id !== TAB_ID);
if (action === 'CLAIM') {
stack.push(TAB_ID);
if (stack.length > MAX_STACK) stack = stack.slice(stack.length - MAX_STACK);
// INSTANT UNMUTE
applyMute(false);
}
GM_setValue('audioStack', stack);
// If we are Normal mode, we still WRITE to cloud so Private tabs can hear us.
// But we don't READ from cloud constantly.
updateCloudStack(action);
}
// --- 3. CLOUD ENGINE ---
function updateCloudStack(action) {
// We write to cloud regardless of mode (Normal writes so Private can see it)
GM_xmlhttpRequest({
method: "GET",
url: BLOB_URL,
onload: (res) => {
let data = { stack: [] };
try { data = JSON.parse(res.responseText); } catch(e) {}
let stack = data.stack || [];
stack = stack.filter(id => id !== TAB_ID);
if (action === 'CLAIM') {
stack.push(TAB_ID);
if (stack.length > 20) stack = stack.slice(stack.length - 20);
}
GM_xmlhttpRequest({
method: "PUT",
url: BLOB_URL,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ stack: stack, time: Date.now() }),
onload: () => {}
});
}
});
}
function startCloudSync() {
// ONLY run this interval if isPrivate = true
setInterval(() => {
GM_xmlhttpRequest({
method: "GET",
url: BLOB_URL,
onload: (res) => {
try {
const data = JSON.parse(res.responseText);
const stack = data.stack || [];
if (stack.length > 0) {
const cloudMaster = stack[stack.length - 1];
// If cloud says someone else is master, MUTE.
if (cloudMaster !== TAB_ID) {
applyMute(true);
}
}
} catch(e) {}
}
});
}, POLL_RATE);
}
// --- 4. DECISION LOGIC ---
function checkLocalState() {
const stack = getLocalStack();
if (stack.length === 0) {
applyMute(false);
return;
}
const masterId = stack[stack.length - 1];
// If I am local master, I'm good.
if (masterId === TAB_ID) {
applyMute(false);
} else {
// Only mute if we are SURE we aren't master
// (Cloud logic handles the Private overlap)
applyMute(true);
}
}
GM_addValueChangeListener('audioStack', checkLocalState);
// --- 5. MUTE FUNCTION ---
function applyMute(shouldMute) {
document.querySelectorAll('video, audio').forEach(el => {
if (shouldMute) {
if (!el.paused && !el.ended && !el.muted) el.muted = true;
} else {
if (el.muted) el.muted = false;
}
});
if (window.audioContexts) {
window.audioContexts.forEach(ctx => {
if (ctx.state === 'closed') return;
if (shouldMute) { if (ctx.state === 'running') ctx.suspend(); }
else { if (ctx.state === 'suspended') ctx.resume(); }
});
}
}
// --- 6. GOD MODE (HIJACK) ---
window.audioContexts = [];
const OriginalAudioContext = window.AudioContext || window.webkitAudioContext;
if (OriginalAudioContext) {
window.AudioContext = window.webkitAudioContext = function(...args) {
const ctx = new OriginalAudioContext(...args);
window.audioContexts.push(ctx);
ctx.addEventListener('statechange', () => {
if (ctx.state === 'running') updateLocalStack('CLAIM');
});
return ctx;
};
window.AudioContext.prototype = OriginalAudioContext.prototype;
}
const originalPlay = HTMLMediaElement.prototype.play;
const originalPause = HTMLMediaElement.prototype.pause;
HTMLMediaElement.prototype.play = function() {
updateLocalStack('CLAIM');
return originalPlay.apply(this, arguments);
};
HTMLMediaElement.prototype.pause = function() {
const result = originalPause.apply(this, arguments);
if (this.paused) {
setTimeout(() => {
const stillPlaying = Array.from(document.querySelectorAll('video, audio'))
.some(el => !el.paused && el !== this);
if (!stillPlaying) updateLocalStack('YIELD');
}, 100);
}
return result;
};
window.addEventListener('focus', () => {
const tagsActive = Array.from(document.querySelectorAll('video, audio'))
.some(el => !el.paused && !el.ended);
if (tagsActive) updateLocalStack('CLAIM');
});
window.addEventListener('beforeunload', () => updateLocalStack('YIELD'));
})();
Normal/Private browsing version using only JSONBlob (slow)
// ==UserScript==
// @name Audio Master: Hardcoded Sync
// @namespace http://tampermonkey.net/
// @version 21.0
// @description Mutes background tabs. Uses your specific JSONBlob ID.
// @author hacker09
// @match *://*/*
// @tag MINE!
// @grant GM_xmlhttpRequest
// @connect jsonblob.com
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// --- CONFIG ---
// We are using the ID you successfully created manually
const BLOB_ID = "019b30e4-5058-73ba-b777-378a27d19e5e";
const BLOB_URL = `https://api.jsonblob.com/api/jsonBlob/${BLOB_ID}`;
const TAB_ID = Math.random().toString(36).slice(2) + "-" + Date.now();
const POLL_RATE = 2000;
console.log("Audio Master: Loaded. ID:", TAB_ID);
// --- CLOUD SYNC ENGINE ---
function updateRemoteStack(action) {
// READ first
GM_xmlhttpRequest({
method: "GET",
url: BLOB_URL,
onload: (res) => {
let data = { stack: [] };
try { data = JSON.parse(res.responseText); } catch(e) {}
let stack = data.stack || [];
// MODIFY
stack = stack.filter(id => id !== TAB_ID);
if (action === 'CLAIM') {
stack.push(TAB_ID);
if (stack.length > 20) stack = stack.slice(stack.length - 20);
}
// WRITE back
GM_xmlhttpRequest({
method: "PUT",
url: BLOB_URL,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ stack: stack, last_update: Date.now() }),
onload: () => checkGlobalState(stack)
});
},
onerror: (err) => {
console.error("Audio Master: Connection Blocked!", err);
alert("Audio Master Error:\nPlease click the Tampermonkey icon and select 'Always Allow' for jsonblob.com");
}
});
}
function checkRemoteStack() {
GM_xmlhttpRequest({
method: "GET",
url: BLOB_URL,
onload: (res) => {
try {
const data = JSON.parse(res.responseText);
checkGlobalState(data.stack || []);
} catch(e) {}
}
});
}
// --- CORE LOGIC ---
function checkGlobalState(stack) {
if (!stack || stack.length === 0) {
applyMute(false);
return;
}
const masterId = stack[stack.length - 1];
applyMute(masterId !== TAB_ID);
}
function applyMute(shouldMute) {
// Tags
document.querySelectorAll('video, audio').forEach(el => {
if (shouldMute) {
if (!el.paused && !el.ended) el.muted = true;
} else {
if (el.muted) el.muted = false;
}
});
// Web Audio
if (window.audioContexts) {
window.audioContexts.forEach(ctx => {
if (ctx.state === 'closed') return;
if (shouldMute) { if (ctx.state === 'running') ctx.suspend(); }
else { if (ctx.state === 'suspended') ctx.resume(); }
});
}
}
// --- GOD MODE (Prototype Hijack) ---
window.audioContexts = [];
const OriginalAudioContext = window.AudioContext || window.webkitAudioContext;
if (OriginalAudioContext) {
window.AudioContext = window.webkitAudioContext = function(...args) {
const ctx = new OriginalAudioContext(...args);
window.audioContexts.push(ctx);
ctx.addEventListener('statechange', () => {
if (ctx.state === 'running') updateRemoteStack('CLAIM');
});
return ctx;
};
window.AudioContext.prototype = OriginalAudioContext.prototype;
}
const originalPlay = HTMLMediaElement.prototype.play;
const originalPause = HTMLMediaElement.prototype.pause;
HTMLMediaElement.prototype.play = function() {
updateRemoteStack('CLAIM');
return originalPlay.apply(this, arguments);
};
HTMLMediaElement.prototype.pause = function() {
const result = originalPause.apply(this, arguments);
if (this.paused) {
setTimeout(() => {
const stillPlaying = Array.from(document.querySelectorAll('video, audio'))
.some(el => !el.paused && el !== this);
if (!stillPlaying) updateRemoteStack('YIELD');
}, 50);
}
return result;
};
// --- LISTENERS ---
window.addEventListener('focus', () => {
const tagsActive = Array.from(document.querySelectorAll('video, audio'))
.some(el => !el.paused && !el.ended);
if (tagsActive) updateRemoteStack('CLAIM');
});
window.addEventListener('beforeunload', () => updateRemoteStack('YIELD'));
// --- INIT ---
// Start polling immediately using the hardcoded ID
setInterval(checkRemoteStack, POLL_RATE);
// Initial check
checkRemoteStack();
})();