Skip to content

Instantly share code, notes, and snippets.

@pl12133
Last active December 11, 2017 18:50
Show Gist options
  • Save pl12133/23433f30808e6428ca5f5587c3c9320a to your computer and use it in GitHub Desktop.
Save pl12133/23433f30808e6428ca5f5587c3c9320a to your computer and use it in GitHub Desktop.
Google Hangouts Volume Bar Bookmarklet
// This is mostly working but also useless, because the audio volume will periodically be reset during the discussion.
window.__hangoutsVolumeBookmarkletCleanup = (function createAudioModMenu(window, undefined) {
if (window.__hangoutsVolumeBookmarkletCleanup) {
window.__hangoutsVolumeBookmarkletCleanup();
}
var document = window.document;
var participants = Array.from(document.querySelector('[aria-label="Video call participants"]').childNodes).slice(0, -1);
var audios = Array.from(document.querySelectorAll('audio')).reverse();
var children = [];
for (var index = 0; index < audios.length; ++index) {
var audio = audios[index];
var participant = participants[index];
var bounds = participant.getBoundingClientRect();
var input = document.createElement('input');
input.setAttribute('type', 'range');
input.setAttribute('value', audio.volume * 100);
input.setAttribute('max', '100');
input.setAttribute('min', '0');
input.addEventListener('change', (e) => {
audio.volume = e.target.value / 100;
console.log(`${participant.innerText.trim()} volume set to ${e.target.value}`);
});
input.setAttribute('style', `position: fixed; top: ${bounds.top - 25}px; width: ${bounds.width}px; height: 15px; left: ${bounds.left}px;`);
children.push(input);
}
children.forEach((child) => document.body.appendChild(child));
return () => { children.forEach((child) => document.body.removeChild(child)); };
})(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment