Created
September 12, 2017 03:18
-
-
Save Dartv/4659cd1de0144b30995ab61678ce9adf to your computer and use it in GitHub Desktop.
Itunes userscript to lower volume
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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