Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name score and grab flashing
- // @namespace http://www.reddit.com/user/happytagpro/
- // @include http://tagpro-*.koalabeast.com:*
- // @include http://tangent.jukejuice.com:*
- // @include http://maptest.newcompte.fr:*
- // @author happy
- // @version o.2
- // ==/UserScript==
- var FlashDuration = 200;
- // set up CSS for blue red and transparent overlays
- var transparentOverlay = {
- height:"100%",
- width:"100%",
- position:"fixed",
- left:0,
- top:0,
- background:"rgba(0,0,0,0)"
- }
- var blueOverlay = {
- height:"100%",
- width:"100%",
- position:"fixed",
- left:0,
- top:0,
- background:"rgba(0,0,200,0.5)"
- }
- var redOverlay = {
- height:"100%",
- width:"100%",
- position:"fixed",
- left:0,
- top:0,
- background:"rgba(200,0,0,0.5)"
- }
- // add div overlay element to webpage
- var overlay = '<div class="overlay"></div>'
- $('body').find('#sound').after(overlay);
- //when a sound is played, a message is sent as the arguement of function(message)
- tagpro.socket.on("sound", function(message) {
- //I couldnt figure out how to set these variables AFTER the page is fully loaded. they kept on being set to null when placed earlier.
- teamColor = tagpro.players[tagpro.playerId].team == 1 ? 'r' : 'b';
- opponentColor = teamColor == 'r' ? 'b' : 'r';
- // list of sound names:
- //burst, alert, cheering, drop, sigh, powerup, pop, click, explosion, countdown, friendlydrop, friendlyalert, alertlong (not currently used), go, degreeup, teleport
- //the screen will flash a certian color, depending on what sound is played.
- sound = message.s
- if (sound == "cheering" | sound == "friendlyalert") {
- flashColor(teamColor)
- } else if (sound == "sigh" | sound == "alert") {
- flashColor(opponentColor)
- }
- });
- // change overlay to either blue or red depending on who scored, then revert overlay to transparent
- function flashColor(c) {
- css = c == 'r' ? redOverlay : blueOverlay;
- $('.overlay').css(css)
- setTimeout(function(){$('.overlay').css(transparentOverlay)}, FlashDuration);
- }
Add Comment
Please, Sign In to add comment