YouTube: remember the volume level
Saves the volume you set and restores it on every new video and after a page reload.
Code to copy
// Remember the player volume across videos and page loads
const KEY = 'jz-yt-volume';
function apply(v) {
if (!v) return;
v.volume = parseFloat(localStorage.getItem(KEY) || v.volume);
v.addEventListener('volumechange', () => {
localStorage.setItem(KEY, String(v.volume));
});
}
const obs = new MutationObserver(() => {
const v = document.querySelector('video.html5-main-video');
if (v && !v.dataset.jzVol) { v.dataset.jzVol = '1'; apply(v); }
});
obs.observe(document.documentElement, { childList: true, subtree: true });
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.