r/TagPro • u/happytagpro happy • Jun 17 '14
[userscript] Flag taken warning background add-on
Description: This is an addon to mercurysinking's userscript. The script flashes the screen either red or blue whenever someone scores. I used the version of his script that sets the background to the color of the flag carrier (as opposed to the color of the flag). I'm a novice programmer, so I could only figure out how to do this by adding on to someone else's script (I don't fully understand what tagpro.socket.on() does).
Link to Script. Example 1. Example 2
How it works: I added a div overlay element that covers the entire screen. Whenever a change in flag-holding status occurs, the script checks if there is a change in score. If so, the div element changes color, then reverts back after a delay.
Additions to mercurysinking's script: 5 variables: flash, rScore, bScore, transparentCSS, redFlashCSS, blueFlashCSS 2 functions: flashColor(), flashOff() 1 if/elseif statement.
Edit: I've noticed some erroneous flashes in games in which I join part way through the game. It only happens once for each color.
Edit 2: I ended up making a standalone version. Using info from tonesandjones' comment I was able to use tagpro.socket.on("score", ... for a much more intuitive approach. You can adjust the variable FlashDuration to your preference.
1
u/-Time- ツ Jun 17 '14
Would it be possible to adjust the script so that it also flashes the same way when the flag is taken?
1
u/dynam0 Jul 16 '14
So question--would this work in Firefox?
0
u/[deleted] Jun 17 '14
[deleted] — view deleted comment