Last active
May 20, 2019 03:41
-
-
Save bash-tp/9ed6262dc313a245f1cad44443199fbe to your computer and use it in GitHub Desktop.
TagPro Overtime Enhancer
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 Overtime Enhancer | |
// @namespace http://www.reddit.com/user/bash_tp/ | |
// @description Add visual cues to overtime | |
// @include *://*.koalabeast.com* | |
// @include *://*.jukejuice.com* | |
// @include *://*.newcompte.fr* | |
// @author bash# | |
// @version 1.2 | |
// @updateURL https://gist.github.com/bash-tp/9ed6262dc313a245f1cad44443199fbe/raw/tagpro_overtime_enhancer.user.js | |
// @downloadURL https://gist.github.com/bash-tp/9ed6262dc313a245f1cad44443199fbe/raw/tagpro_overtime_enhancer.user.js | |
// ==/UserScript== | |
tagpro.ready(function() { | |
if (tagpro.renderer === undefined) { | |
return; | |
} | |
// 1. Flash a countdown when overtime is approaching | |
var vp = $("#viewport"); | |
var mask = $("<div>"); | |
var resize_mask = function() { | |
mask.hide (); | |
mask.height (vp.height()); | |
mask.width (vp.width()); | |
mask.css ({ | |
position: "absolute", | |
top: vp.offset().top, | |
left: vp.offset().left, | |
"background-color": "yellow", | |
opacity: 0, | |
}); | |
} | |
vp.parent().append(mask); | |
tagpro.socket.on("id", resize_mask); | |
$(window).resize(resize_mask); | |
var timer = tagpro.ui.timer; | |
var prev = ""; | |
tagpro.ui.timer = function() { | |
timer.apply(this, arguments); | |
var remain = arguments[arguments.length-1]; | |
if (remain != prev) { | |
if ((tagpro.state == 1) && (tagpro.score.b == tagpro.score.r) && (remain.match(/^00:0[3210]$/))) { | |
mask.fadeTo(200, 0.25).fadeTo(1, 0, function() { mask.hide(); }); | |
} | |
prev = remain; | |
} | |
}; | |
// 2. Outline the viewport when overtime starts | |
tagpro.socket.on("time", function(e) { | |
if (e.state == 5) { | |
vp.css({"outline": "20px ridge #f4b942"}) | |
} | |
}); | |
// 3. Show a countdown to long spawns | |
var spawnStyle = new PIXI.TextStyle({ | |
fontSize: "48pt", | |
fontWeight: "bold", | |
fill: "#ffffff", | |
stroke: "#000000", | |
strokeThickness: 2, | |
}); | |
var spawn = new PIXI.Text("", spawnStyle); | |
var resize_spawn = function() { | |
spawn.anchor.x = 0.5; | |
spawn.anchor.y = 0.5; | |
spawn.x = vp.width() / 2; | |
spawn.y = 75; | |
} | |
tagpro.socket.on("id", resize_spawn); | |
$(window).resize(resize_spawn); | |
var interval = null; | |
var clear_spawn = function() { | |
if (interval) { | |
tagpro.renderer.layers.ui.removeChild(spawn); | |
clearInterval(interval); | |
interval = null; | |
} | |
}; | |
tagpro.socket.on("chat", function(e) { | |
var match = e.message.match(/Currently: ([0-9]+)$/); | |
if ((e.from === null) && match) { | |
var count = match[1]; | |
spawn.text = "Spawning in " + count; | |
tagpro.renderer.layers.ui.addChild(spawn); | |
interval = setInterval(function() { | |
count--; | |
if (count == 0) { | |
clear_spawn(); | |
} else { | |
spawn.text = "Spawning in " + count; | |
} | |
}, 1000); | |
} | |
}); | |
tagpro.socket.on("end", clear_spawn); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment