Skip to content

Instantly share code, notes, and snippets.

@WiBla
Last active March 7, 2017 17:34
Show Gist options
  • Save WiBla/f0aa9ef4c8fdedc9d126550ef19873ea to your computer and use it in GitHub Desktop.
Save WiBla/f0aa9ef4c8fdedc9d126550ef19873ea to your computer and use it in GitHub Desktop.
Lower the volume from soundcloud's play on plug.dj.

Automaticly lower the volume from each soundclouds play on plug.dj.

##Install

Simply put this code in a new bookmark's url (name it how you want) :
It will even auto update !

javascript:(function(){$.getScript('https://rawgit.com/WiBla/f0aa9ef4c8fdedc9d126550ef19873ea/raw/magic.js');})();

Click the bookmark when browsing Plug.dj and voilà !
cough With my extension, you can load any script automaticly. Just saying.. cough

##Commands

  • /autovolume [off/X]

By doing /autovolume off you are turning the script off.
With /autovolume followed by a number (0-100), you change by how much the volume will increase/decrease.
Setting it to 0 will temporarily disable the script ;)

##Boring stuff

       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
               Version 2, December 2004

Copyright (C) 2004 Sam Hocevar [email protected]

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. You just DO WHAT THE FUCK YOU WANT TO.
(function(){
var lastMediaFormat = null;
var volStep = 10;
function autovolume(song) {
if (!song.dj || !song.media) return;
if (lastMediaFormat === null) {
lastMediaFormat = song.media.format;
} else if (lastMediaFormat !== song.media.format) {
var vol = API.getVolume();
vol += (song.media.format === 1 ? volStep : -volStep);
API.setVolume(vol);
lastMediaFormat = song.media.format;
}
}
function autovolumeCMD(cmd) {
if (cmd.toLowerCase().indexOf('autovolume') !== -1) {
cmd = cmd.split(' ').slice(1);
if (cmd.length === 0 || (cmd[0] !== "off" && isNaN(cmd[0]))) return API.chatLog('Use: /autovolume [off/X]');
else if (cmd[0] === "off") {
API.off(API.ADVANCE, autovolume);
API.off(API.CHAT_COMMAND, autovolumeCMD);
API.chatLog('Autovolume turned off !');
} else if (!isNaN(cmd[0])) {
var vol = parseInt(cmd[0]);
if (vol < 0 || vol > 100) {
API.chatLog('Number must be between 0 and 100.');
} else {
volStep = vol;
API.chatLog('Autovolume step set to '+volStep+'.');
}
}
}
}
API.on(API.CHAT_COMMAND, autovolumeCMD);
API.on(API.ADVANCE, autovolume);
API.chatLog('Autovolume started ! Try "/autovolume" for commands.');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment