Created
July 26, 2014 22:38
-
-
Save psychfan5/ff8fc4c6ba89fb4f26aa to your computer and use it in GitHub Desktop.
This file contains 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 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