Skip to content

Instantly share code, notes, and snippets.

@Dartv
Created September 12, 2017 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dartv/4659cd1de0144b30995ab61678ce9adf to your computer and use it in GitHub Desktop.
Save Dartv/4659cd1de0144b30995ab61678ce9adf to your computer and use it in GitHub Desktop.
Itunes userscript to lower volume
// ==UserScript==
// @name Itunes lower volume
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://itunes.apple.com/*/album/*/*$
// @grant none
// ==/UserScript==
(function() {
'use strict';
var audioObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes) {
mutation.addedNodes.forEach(function(node) {
if (node.tagName === 'AUDIO') {
audioObserver.disconnect();
var target = document.getElementsByTagName('audio')[0];
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === 'src') {
target.volume = 0.2;
}
});
});
observer.observe(target, { attributes: true });
}
});
}
});
});
audioObserver.observe(document.body, { childList: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment