Created
May 18, 2017 03:19
-
-
Save stevenklar/ac0411863afbd32d805601ab3991d1c4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ESL Admin Helper | |
| // @namespace https://play.eslgaming.com/rainbowsix/europe-pc/ | |
| // @version 0.17 | |
| // @description ESL Rainbow Six Siege Admin Helper | |
| // @author Deadshot | |
| // @updateURL https://gist.githubusercontent.com/stevenklar/4a22dbb739dbe17b7c9159f833d566cf/raw | |
| // @downloadURL https://gist.githubusercontent.com/stevenklar/4a22dbb739dbe17b7c9159f833d566cf/raw | |
| // @require https://greasyfork.org/scripts/622-super-gm-setvalue-and-gm-getvalue-js/code/Super_GM_setValue_and_GM_getValuejs.js?version=1786 | |
| // @match https://play.eslgaming.com/* | |
| // @grant GM_notification | |
| // @grant window.focus | |
| // @grant GM_SuperValue | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // @copyright Steven "Deadshot" Klar | |
| // ==/UserScript== | |
| /* | |
| +++ Featues +++ | |
| - Show ticket counter with and without admin assignment | |
| - Notification when there are tickets without admin assignment | |
| - Configure features | |
| - Change NavNode | |
| - Admin Match Link in protest | |
| - Easy "Go back to Match"-link in Admin Match page | |
| - Add generic protest link to admin menu in Matches | |
| - Admin quick list in support tickets for easy move | |
| - Fast forward to oldest unassigned ticket | |
| - Show Match chatlog/logfile in Match instead of page reload | |
| - Quick Protest timer, never forget a cup protest again | |
| */ | |
| class App { | |
| static init() { | |
| setTimeout(function() { | |
| Menu.init(); | |
| }, 1000); | |
| if (URL.isProtest()) { | |
| Protest.addAdminMatchLink(); | |
| Protest.addSentences(); | |
| setInterval(function() { | |
| $.get('', function(data) { | |
| var ticketTable = $(data).find('.esl-content > div > table').eq(1); | |
| $('.esl-content > div > table').eq(1).html(ticketTable.html()); | |
| }); | |
| }, 30000); | |
| /* | |
| var quickTimers = GM_getValue('protestQuickTimers'); | |
| if (quickTimers === undefined) { | |
| quickTimers = []; | |
| } | |
| console.log(quickTimers); | |
| quickTimers.push({ | |
| }); | |
| quickTimers = []; | |
| GM_setValue('protestQuickTimers', quickTimers); | |
| */ | |
| } | |
| if (URL.isSupport()) { | |
| Support.addAdminQuickList(); | |
| Protest.addSentences(); | |
| // prototype for auto monthly finals | |
| var league = $('form[name=parentForm] td').filter(function() { | |
| return $(this).text() === 'League'; | |
| }).next().text(); | |
| // is about monthly finals? | |
| if (league.indexOf('Monthly Finals') !== -1) { | |
| var platform = ''; | |
| // is ps4 | |
| if (league.indexOf('PS4') !== -1) { | |
| platform = 'ps4'; | |
| } | |
| // is one | |
| if (league.indexOf('One') !== -1) { | |
| platform = 'one'; | |
| } | |
| // is one | |
| if (league.indexOf('PC') !== -1) { | |
| platform = 'pc'; | |
| } | |
| if (platform !== '') { | |
| var player = $('td:contains(Anfragesteller)').next().find('a'); | |
| if (player.length > 1) { | |
| var go4team = player.eq(1).text(); | |
| var go4teamLink = player.eq(1).attr('href'); | |
| var month = ("0" + (new Date().getMonth())).slice(-2); | |
| var year = new Date().getUTCFullYear(); | |
| $.get('https://toolbox.tet.io/go4/go4r6_'+platform+'_eu/'+year+'-'+month+'/', function(data) { | |
| var template = 'Team: <a href="'+go4teamLink+'">'+go4team+'</a><br />' + | |
| 'Ticket: <a href="'+ location.href +'">Ticket</a><br />' + | |
| 'Participation: Yes'; | |
| $('textarea[name=body]').after('<div>'+template+'</div>'); | |
| var ranking = $(data).find('td:contains('+go4team+')').prev().prev().text(); | |
| $('textarea[name=body]').parent().parent().parent().parent().parent().before('<a href="https://play.eslgaming.com/rainbowsix/forum/3326/35581/">Forum-Link</a> - Ranking: ' + ranking); | |
| }); | |
| } else { | |
| console.log('Cant find team name'); | |
| } | |
| } else { | |
| console.log('Platform for Go4 Monthly finals not found'); | |
| } | |
| } | |
| } | |
| if (URL.isAdminTickets() || GM_getValue("refreshCounterGlobal") === true) { | |
| setTimeout(function() { | |
| Menu.showTicketCounter(); | |
| setInterval(Menu.showTicketCounter, 30000); | |
| }, 1000); | |
| } | |
| if (URL.isAdminMatch()) { | |
| AdminMatch.addMatchLink(); | |
| AdminMatch.addProtestLink(); | |
| // begin helper | |
| // remove MiniHelper Buttons | |
| $('.esl-content .btn').remove(); | |
| function addActionButton(action, name, callback) { | |
| $('.esl-content .TitleM').after('<a class="btn btn-primary action__'+ action +'" href="#checked">'+ name +'</a>'); | |
| $('.action__' + action).on('click', callback); | |
| }; | |
| var contestant1 = $('select[name=defaultwin] option').eq(1); | |
| var contestant2 = $('select[name=defaultwin] option').eq(2); | |
| function giveDefaultWin(contestant) { | |
| $('select[name=active]').val('yes'); | |
| $('select[name=status]').val('closed'); | |
| $('select[name=calculate]').val('yes'); | |
| $('.esl-content input[type=checkbox][name!=featured]').attr('checked', true); | |
| $('select[name=defaultwin]').val(contestant); | |
| $('option:contains(No Exception)').parent().val($('option:contains(No Exception)').val()) | |
| if (contestant == 1) { | |
| $('td:contains(round1team1)').next().find('input').eq(1).val(1); | |
| $('td:contains(round1team2)').next().find('input').eq(1).val(0); | |
| } else { | |
| $('td:contains(round1team1)').next().find('input').eq(1).val(0); | |
| $('td:contains(round1team2)').next().find('input').eq(1).val(1); | |
| } | |
| } | |
| addActionButton('default-win-2', 'Default Win ' + contestant2.text(), function() { | |
| giveDefaultWin(2); | |
| }); | |
| addActionButton('default-win-1', 'Default Win ' + contestant1.text(), function() { | |
| giveDefaultWin(1); | |
| }); | |
| addActionButton('delete-match', 'Delete', function() { | |
| $('select[name=active]').val('no'); | |
| $('select[name=status]').val('exception'); | |
| $('select[name=calculate]').val('no'); | |
| $('select[name=defaultwin]').val('none'); | |
| $('.esl-content input[type=checkbox][name!=featured]').attr('checked', true); | |
| $('option:contains(No Exception)').parent().val($('option:contains(No Exception)').next().val()) | |
| }); | |
| addActionButton('check-match', 'Check', function() { | |
| $('.esl-content input[type=checkbox][name!=featured]').attr('checked', true); | |
| $('select[name=active]').val('yes'); | |
| $('select[name=status]').val('closed'); | |
| $('select[name=calculate]').val('yes'); | |
| $('select[name=defaultwin]').val('none'); | |
| $('option:contains(No Exception)').parent().val($('option:contains(No Exception)').val()) | |
| }); | |
| } | |
| if (URL.isMatch()) { | |
| Match.addProtestLink(); | |
| Match.addLinkPreview('Chatlog'); | |
| Match.addLinkPreview('Logfile'); | |
| } | |
| if (URL.isBracket()) { | |
| var rounds = []; | |
| var leagueId = $('league-interaction').attr('league_id'); | |
| $.get('https://play.eslgaming.com/api/leagues/'+leagueId+'/results', function(data) { | |
| $.each(data, function(k, v) { | |
| var round = v.round; | |
| var begin = v.beginAt; | |
| rounds[round] = begin; | |
| }); | |
| $('div.round').each(function(k, v) { | |
| var dueColor = 'black'; | |
| var tempBegin = rounds[$(v).attr('number') - 1]; | |
| var tempDate = new Date(tempBegin).toLocaleString(); | |
| var timeDiff = ((((tempBegin) - (new Date().getTime()))/1000)/60/60); | |
| //console.log(timeDiff); | |
| if (timeDiff < -1.25) dueColor = 'red'; | |
| $(v).prepend('<span style="color: '+dueColor+'">'+tempDate+'</span>'); | |
| }); | |
| }); | |
| } | |
| } | |
| } | |
| class AdminMatch { | |
| static addMatchLink() { | |
| var link = window.location.href.replace('admin_match', 'match'); | |
| var editMatch = $("div.esl-content div:contains(Edit Match)"); | |
| var oldText = editMatch.text().trim(); | |
| editMatch.html('<a href="'+link+'">'+oldText+'</a>'); | |
| } | |
| static addProtestLink() { | |
| var matchId = $('input[name=id][type=hidden]').val(); | |
| var protestLink = location.href.substr(0, location.href.indexOf('admin_match')) + 'match/protest/' + matchId + '/'; | |
| $("div.esl-content div:contains(Edit Match)").append(' - <a href="'+ protestLink +'">Protest</a>'); | |
| } | |
| } | |
| class Match { | |
| static addProtestLink() { | |
| var protestLink = location.href.substr(0, location.href.indexOf('match')) + 'match/protest/' + matchId + '/'; | |
| $('div.esl-content span.arrowlink:contains(Admin Match)').append('<span class="arrowlink"><a href="'+ protestLink +'" target="_parent">Protest</a></span>'); | |
| } | |
| static addLinkPreview(name) { | |
| $('a:contains('+name+')').on('click', function() { | |
| $('#preview').remove(); | |
| $.get($('a:contains('+name+')').attr('href'), function(response) { | |
| var content = '<table>' + $(response).find('.esl-content > table').html() + '</table>'; | |
| $('a:contains('+name+')').parent().parent().append('<div id="preview">'+content+'</div>'); | |
| }); | |
| return false; | |
| }); | |
| } | |
| } | |
| class Menu { | |
| static init() { | |
| // build menu | |
| var navnodeSwitch = | |
| '<table style="width: 100%;">' + | |
| Helper.makeSwitch('Realtime Ticket updates', 'refreshCounter') + | |
| Helper.makeSwitch('Unassigned Tickets Notification', 'notification') + | |
| Helper.makeSwitch('Ticket counter on all pages', 'refreshCounterGlobal') + | |
| Helper.makeText('Navnode', 'helperNavnode') + | |
| Helper.makeText('Ignore Squads', 'squadsIgnore') + | |
| '</table>'; | |
| $('body').append('<div id="dialog" style="display: hidden;" title="Settings">'+navnodeSwitch+'</div>'); | |
| $('#userbar_connection_status_text').on('click', function() { | |
| if ($('#dialog').dialog('isOpen') === true) { | |
| $('#dialog').dialog('close'); | |
| } else { | |
| $('#dialog').dialog({ | |
| modal: true, | |
| minWidth: 700, | |
| resizable: false, | |
| buttons: { | |
| Ok: function() { | |
| $(this).dialog('close'); | |
| } | |
| } | |
| }); | |
| } | |
| }); | |
| // listener | |
| Helper.addSwitch( | |
| 'refreshCounter', | |
| '.userbar_jslink_refreshCounter', | |
| function() { | |
| if (URL.isAdminTickets()) { | |
| Menu.showTicketCounter(); | |
| } | |
| }, | |
| function() { | |
| $('.userbar_caption:contains(Admin)').animate({ | |
| color: '#FFFFFF', | |
| }); | |
| $('.userbar_caption:contains(Admin)').text('Admin'); | |
| } | |
| ); | |
| Helper.addSwitch( | |
| 'refreshCounterGlobal', | |
| '.userbar_jslink_refreshCounterGlobal', | |
| function() { | |
| Menu.showTicketCounter(); | |
| }, | |
| function() { | |
| if (!URL.isAdminTickets()) { | |
| $('.userbar_caption:contains(Admin)').animate({ | |
| color: '#FFFFFF', | |
| }); | |
| $('.userbar_caption:contains(Admin)').text('Admin'); | |
| } | |
| } | |
| ); | |
| Helper.addSwitch( | |
| 'notification', | |
| '.userbar_jslink_notification', | |
| function(){}, function(){} | |
| ); | |
| Helper.addInputListener('helperNavnode'); | |
| Helper.addInputListener('squadsIgnore'); | |
| Menu.addNavnodeSwitch(); | |
| // add dependencies | |
| $('head').append('<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">'); | |
| $('head').append('<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />'); | |
| $('head').append('<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>'); | |
| $('head').append('<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/v1.6.0/dist/clipboard.min.js"></script>'); | |
| // quick ticket assigner :) | |
| Menu.addUserbarLink('fastForward', 'forward', AdminTickets.fastForward); | |
| Menu.addUserbarLink('leagueInfos', 'info', Helper.getTodaysCups); | |
| setTimeout(function() { | |
| if (URL.isSupport()) { | |
| // quick search for selects | |
| $('select[name=country_squad]').select2(); | |
| $('select[name=squad]').select2(); | |
| } | |
| }, 1000); | |
| } | |
| static addNavnodeSwitch() { | |
| $('.userbar_caption:contains(Admin)').parent().on('click', function() { | |
| var helperNavnode = GM_getValue('helperNavnode'); | |
| if (helperNavnode === undefined || helperNavnode === '') { | |
| helperNavnode = '/rainbowsix/europe-pc/'; | |
| GM_setValue('helperNavnode', helperNavnode); | |
| } | |
| var MYURL=helperNavnode; | |
| var nodesToReplace=['support', 'admin_tickets', 'protest', 'player', 'team', 'admin_fakematches', 'admin_application']; | |
| var path=window.location.pathname; | |
| for (var i in nodesToReplace){ | |
| var regex=new RegExp("(.*)" + nodesToReplace[i]); | |
| var matches; | |
| if (matches=path.match(regex)){ | |
| if (matches[1]==MYURL){continue;} | |
| if (window.location.href.match(/esl.eu/)){path="/play" + path;} | |
| path=path.replace(matches[1], MYURL); | |
| window.location.pathname=path; | |
| } | |
| } | |
| }); | |
| } | |
| static showTicketCounter() { | |
| if (GM_getValue('refreshCounter') === false) { | |
| return; | |
| } | |
| AdminTickets.getTickets(function(data) { | |
| // do not cound specific squads | |
| var notTheseSquads = AdminTickets.getIgnoredSquads(); | |
| var openTickets = $(data).find('table').eq(1).find('tr td:nth-child(3) a.TextS' + notTheseSquads); | |
| var assignedTickets = $(data).find('table').eq(1).find('tr td:nth-child(3) a.TextSP' + notTheseSquads); | |
| var openTicketsCount = openTickets.length; | |
| var assignedTicketsCount = assignedTickets.length; | |
| if (openTicketsCount > 0 && GM_getValue('notification') !== false) { | |
| openTickets.each(function(k, v) { | |
| var ticket = openTickets.eq(k); | |
| var ticketHref = ticket.attr('href'); | |
| GM_notification({ | |
| text: ticket.text(), | |
| title: 'New Ticket', | |
| timeout: 3000, | |
| onclick: function() { window.location = 'https://play.eslgaming.com' + ticketHref; }, | |
| }); | |
| }); | |
| } | |
| if (openTicketsCount > 0) { | |
| $('.userbar_caption:contains(Admin)').animate({ | |
| color: '#FF0000', | |
| }); | |
| } else { | |
| $('.userbar_caption:contains(Admin)').animate({ | |
| color: '#00FF00', | |
| }); | |
| } | |
| // refresh counter | |
| var adminCountText = '('+ openTicketsCount +'/'+ assignedTicketsCount +')'; | |
| $('.userbar_caption:contains(Admin)').text('Admin ' + adminCountText); | |
| // refresh admin page live | |
| var ticketTable = $(data).find('.esl-content > table'); | |
| $('.esl-content > table').html(ticketTable.html()); | |
| // refresh title for better overview | |
| $('title').html(adminCountText); | |
| }); | |
| } | |
| static addUserbarLink(name, icon, callback) { | |
| var actionId = 'action__' + name; | |
| var link = '<a class="fa fa-'+icon+'" style="padding-top: 4px;font-size: 20px;"></a>'; | |
| var userbar = '<div id="'+actionId+'" class="userbar_item">'; | |
| userbar += link | |
| userbar += '</div>'; | |
| $('.userbar.chatbar').append(userbar); | |
| $('#' + actionId).on('click', callback); | |
| } | |
| } | |
| class URL { | |
| static isAdminTickets() { | |
| return window.location.href.indexOf("/admin_tickets/") > -1; | |
| } | |
| static isAdminMatch() { | |
| return window.location.href.indexOf("/admin_match/") > -1; | |
| } | |
| static isMatch() { | |
| return window.location.href.indexOf("/match/") > -1; | |
| } | |
| static isBracket() { | |
| return (window.location.href.indexOf("/rankings/") > -1 && $(".league--header .description").text().indexOf("Cup") > -1); | |
| } | |
| static isLeagueResults() { | |
| return (window.location.href.indexOf("/results/") > -1 && $(".league--header .description").text().indexOf("League") > -1); | |
| } | |
| static isProtest() { | |
| return window.location.href.indexOf("/protest/") > -1; | |
| } | |
| static isSupport() { | |
| return window.location.href.indexOf("/support/") > -1; | |
| } | |
| } | |
| class Support { | |
| static addAdminQuickList() { | |
| // build list | |
| var help = $('tr td a:contains(Help)'); | |
| var options = '<option value="">-</option>'; | |
| var adminSquad = $('input[name=adminsquad]').val(); | |
| help.parent().html('<select id="adminList">'+ options +'</select>'); | |
| $.getJSON("https://spreadsheets.google.com/feeds/list/1ySB3NhUelKmwIIGxzQEcwcjVgeDoeXOpWt7P7Ki5H6Y/opznj7h/public/values?alt=json", function(data) { | |
| $.each(data.feed.entry, function(key, value) { | |
| $('#adminList') | |
| .append('<option value="'+ value.gsx$id.$t +':'+adminSquad+'">'+ value.gsx$name.$t +' ('+ value.gsx$position.$t +')</option>'); | |
| }); | |
| }); | |
| // event listener | |
| $('#adminList').on('change', function(element) { | |
| $('input[name=directtoadmin]').val($(element.currentTarget).val()); | |
| }); | |
| } | |
| } | |
| class Protest { | |
| static addAdminMatchLink() { | |
| var match = $('td:contains(Match):not(.WindowHeader)').eq(0).next(); | |
| var link = match.find('a').attr('href'); | |
| match.append(' | <a href="'+ link.replace('match', 'admin_match') +'">Admin Match</a>'); | |
| } | |
| static addSentences() { | |
| // check if we are in support/protest ticket | |
| if ($('select.defaultAnswerTexts[data-language=en]').length === 0) { | |
| return; | |
| } | |
| // read pretext | |
| var originalText = $('textarea[name=body]').val(); | |
| var salutationRegex = '((Hello .+,)(\nhello .+)?)'; | |
| var endwordRegex = '(Best regards,\n.+)'; | |
| var defaultOptions = $('select.defaultAnswerTexts[data-language=en]').find('option').filter(function() { | |
| return $(this).data("id") < 100; | |
| }); | |
| $('select.defaultAnswerTexts[data-language=en]').html(''); | |
| $('select.defaultAnswerTexts[data-language=en]').append('<optgroup label="Default" id="defaultGroup"></optgroup>'); | |
| $('#defaultGroup').append(defaultOptions); | |
| $('select.defaultAnswerTexts[data-language=en]').prepend('<optgroup id="customGroup" label="Custom"></optgroup>'); | |
| $.getJSON("http://spreadsheets.google.com/feeds/list/1ySB3NhUelKmwIIGxzQEcwcjVgeDoeXOpWt7P7Ki5H6Y/od6/public/values?alt=json", function(data) { | |
| $.each(data.feed.entry, function(key, value) { | |
| $('select.defaultAnswerTexts[data-language=en]').find('optgroup#customGroup') | |
| .append($("<option></option>") | |
| .data('id', value.gsx$id.$t) | |
| .data('text', originalText.replace('\n\n\n', '\n\n'+ value.gsx$text.$t +'\n')) | |
| .text(value.gsx$label.$t)); | |
| }); | |
| $('select.defaultAnswerTexts[data-language=en]').val('Blank address'); | |
| }); | |
| } | |
| } | |
| class Helper { | |
| static addSwitch(name, className, callbackOn, callbackOff) { | |
| $(className).on('click', function() { | |
| if (GM_getValue(name) === true) { | |
| GM_setValue(name, false); | |
| $(className).text('OFF'); | |
| $(className).addClass('btn-danger'); | |
| $(className).removeClass('btn-success'); | |
| callbackOff(); | |
| return; | |
| } | |
| if (GM_getValue(name) === false) { | |
| GM_setValue(name, true); | |
| $(className).text('ON'); | |
| $(className).addClass('btn-success'); | |
| $(className).removeClass('btn-danger'); | |
| callbackOn(); | |
| return; | |
| } | |
| return GM_setValue(name, false); | |
| }); | |
| } | |
| static addInputListener(name) { | |
| $('#' + name).on('keyup', function(e) { | |
| GM_setValue(name, $(e.target).val()); | |
| }); | |
| } | |
| static makeSwitch(name, switchName) { | |
| return '<tr><td>'+ name +'</td><td>'+ Helper.getSwitch(switchName) +'</td></tr>'; | |
| } | |
| static makeText(name, textName) { | |
| return '<tr><td>'+ name +'</td><td>'+ Helper.getText(textName) +'</td></tr>'; | |
| } | |
| static getText(name) { | |
| var value = GM_getValue(name); | |
| if (value === undefined) { | |
| value = ''; | |
| GM_setValue(name, value); | |
| } | |
| return '<input type="text" id="'+name+'" value="'+value+'" />'; | |
| } | |
| static getSwitch(name) { | |
| var status, btnClass; | |
| var value = GM_getValue(name); | |
| if (value === true) { | |
| status = 'ON'; | |
| btnClass = 'btn-success'; | |
| } else { | |
| status = 'OFF'; | |
| btnClass = 'btn-danger'; | |
| } | |
| return '<a class="btn btn-xsmall '+btnClass+' userbar_jslink_'+name+'">'+status+'</a>'; | |
| } | |
| static getTodaysCups() { | |
| var cups = []; | |
| var date = new Date(); | |
| var data = { | |
| path: '/play/rainbowsix/europe-pc/', | |
| states: 'inProgress,upcoming', | |
| skill_levels: 'open,major', | |
| types: 'cup,swiss', | |
| 'limit.total': 20, | |
| }; | |
| $('.l-region.l-region--header').html(''); | |
| function fetchLeague(path) { | |
| data.path = path; | |
| $.get('https://play.eslgaming.com/api/leagues', data, function(data) { | |
| $.each(data, function(key, value) { | |
| if (value.timeline.inProgress.begin.indexOf(date.toISOString().substr(0, 10)) != -1) { | |
| $('.l-region.l-region--header').append('<a style="font-size:10px;" href="'+ value.uri +'/rankings/">' + value.name.full + '</a><br />'); | |
| } | |
| }); | |
| }); | |
| } | |
| fetchLeague('/play/rainbowsix/europe-pc/'); | |
| fetchLeague('/play/rainbowsix/europe-one/'); | |
| fetchLeague('/play/rainbowsix/europe-ps4/'); | |
| } | |
| } | |
| class XMPP { | |
| static connect() { | |
| teXmppConnectionControl.setStatus('available', true); | |
| teXmppConnectionControl.connect(); | |
| } | |
| static disconnect() { | |
| teXmppConnectionControl.disconnect(true); | |
| } | |
| static toggleGhost() { | |
| XMPP.ghostHandler('toggle'); | |
| } | |
| // Common Cookie Toggle Handler | |
| static cookieToggleHandler( option, cookie, enableText, disableText, target, enableValue ) | |
| { | |
| var enabled = jQuery.cookie( cookie ); | |
| if( option == 'toggle' ) | |
| { | |
| if( enabled ) | |
| { | |
| enabled = null; | |
| } | |
| else | |
| { | |
| enabled = enableValue; | |
| } | |
| jQuery.cookie( cookie, enabled, {expires: 365, path: '/'} ); | |
| } | |
| var text = enableText; | |
| if( enabled ) | |
| { | |
| text = disableText; | |
| } | |
| jQuery( '#' + target ).html( text ); | |
| if( option == 'toggle' ) | |
| { | |
| teUserbarManager.refresh(); | |
| } | |
| } | |
| // Ghost Cookie | |
| static ghostHandler( option ) { | |
| XMPP.cookieToggleHandler( option, 'ghost', 'Enable Ghost', 'Disable Ghost', 'ghostHandler', ghostKey ); | |
| } | |
| // 404 Cookie | |
| static fnfHandler( option ) { | |
| XMPP.cookieToggleHandler( option, 'no404', 'Enable 404', 'Disable 404', 'fnfHandler', 1 ); | |
| } | |
| // Debug Cookie | |
| static debugHandler( option ) { | |
| //jQuery.cookie( 'debug_version', 'old' ); | |
| XMPP.cookieToggleHandler( option, 'show_debug_code', 'Show Debug', 'Hide Debug', 'debugHandler', 'true' ); | |
| } | |
| // Profile Cookie | |
| static profileHandler( option ) { | |
| XMPP.cookieToggleHandler( option, 'profile', 'Enable Profiling', 'Disable Profiling', 'profileHandler', 'true' ); | |
| } | |
| } | |
| class AdminTickets { | |
| static getTickets(callback) { | |
| $.get('https://play.eslgaming.com/admin_tickets/', callback); | |
| } | |
| static getIgnoredSquads() { | |
| var squadsIgnore = GM_getValue('squadsIgnore'); | |
| var notTheseSquads = ''; | |
| $.each(squadsIgnore.split(','), function(key, value) { | |
| notTheseSquads += ':not([href$="squad='+value+'"])'; | |
| }); | |
| return notTheseSquads; | |
| } | |
| static fastForward() { | |
| AdminTickets.getTickets(function(data) { | |
| var notTheseSquads = AdminTickets.getIgnoredSquads(); | |
| var openTickets = $(data).find('table').eq(1).find('tr td:nth-child(3) a.TextS' + notTheseSquads); | |
| if (openTickets.length > 0) { | |
| window.location = 'https://play.eslgaming.com' + openTickets.first().attr('href'); | |
| } else { | |
| alert('No open ticket found.'); | |
| } | |
| }); | |
| } | |
| } | |
| (function() { | |
| 'use strict'; | |
| App.init(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment