Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name TagPro Game Notification
- // @version 0.1
- // @description Show a notification when a game started, and when the tab is not active.
- // @author Comakip
- // @include http://*.koalabeast.com:8*
- // @include http://*.jukejuice.com:8*
- // @include http://*.newcompte.fr:8*
- // @grant GM_notification
- // ==/UserScript==
- var timeNotifyBeforeGame = 5; //change this to the amount of time (in seconds) you want a notification before the game starts.
- tagpro.ready(function(){
- setTimeout(function(){
- start();
- },1000);
- });
- function start(){
- if(tagpro.spectator === false && document.hidden === true){ //when we're not spectating, and tab isn't acive; continue
- if (tagpro.state == 2){ //game ended (don't know if this would ever happen but whatever)
- return;
- }
- else if (tagpro.state == 1){ //game started
- notify("Game started!");
- }
- else if (tagpro.state == 3){ //waiting for game to start
- var timeTillStart = tagpro.gameEndsAt - new Date().getTime();
- if (timeTillStart < timeNotifyBeforeGame * 1000){
- notify("Game starts very soon!");
- }
- else {
- var notifyTime = timeTillStart - timeNotifyBeforeGame * 1000;
- setTimeout(function(){
- notify("Game starts in " + timeNotifyBeforeGame + " seconds.");
- }, notifyTime);
- }
- }
- }
- }
- function notify(message){
- GM_notification(message, "TagPro", "https://pbs.twimg.com/profile_images/734800641072234496/aJpDBeF6_400x400.jpg" , function() { window.focus(); this.cancel(); });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement