Skip to content

Instantly share code, notes, and snippets.

@psychfan5
Created July 26, 2014 22:38
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 psychfan5/ff8fc4c6ba89fb4f26aa to your computer and use it in GitHub Desktop.
Save psychfan5/ff8fc4c6ba89fb4f26aa to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name TagPro more music
// @namespace http://www.reddit.com/user/Watball
// @description Plays a random track instead of the same ones all the time
// @include http://tagpro-*.koalabeast.com*
// @license WTFPL
// @author Watball pls
// @version 1.1
// ==/UserScript==
// Add more URLs here. Make sure your browser can play the format.
MUSIC = [
"http://k003.kiwi6.com/hotlink/3tvb4191hf/drukqs1.mp3",
"http://k003.kiwi6.com/hotlink/ovpf4os05b/drukqs3.mp3"
];
// If you want to hear the default tune, leave this to 1.
// If you don't, set it to 0.
DEFAULT_TUNE = 1;
if (document.getElementById('music')) {
var musicth = document.getElementById('music');
var rand = Math.floor(Math.random() * (MUSIC.length + DEFAULT_TUNE));
if (rand < MUSIC.length) {
musicth.innerHTML = '<source src="' + MUSIC[rand] + '" type="audio/' + MUSIC[rand].split('.').pop() + '">';
// We can't check for tagpro.music without fucking around with scope and sandbox and bleh, so this'll have to do
if (document.getElementById('soundMusic').getAttribute('class') !== 'off') {
musicth.pause();
musicth.load();
musicth.play();
}
else {
musicth.load();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment