Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SERVERS PAGE //
- /*
- This script will allow you to see actual number of players
- on a BF4 server.
- Just click on a server in the list and the actual player
- number will appear on the right in the server info.
- Only tested in Chrome - Feel free to improve it if you like.
- https://i.imgur.com/YBpeX3r.png
- */
- if(/battlelog\.battlefield\.com\/bf4\/servers/g.test(document.URL)){
- var beef4CheckServers = setInterval(function(){
- if($('.servers-list tr').length > 0){
- clearInterval(beef4CheckServers);
- $('.servers-list tr').click(function(){
- beef4GetActualPlayerCount($(this).attr('data-guid'));
- });
- }
- },500);
- function beef4GetActualPlayerCount(guid){
- $.ajax({
- url: 'https://keeper.battlelog.com/snapshot/' + guid,
- type: 'get',
- dataType: 'json',
- success: function(data){
- var beef4Teams = data.snapshot.teamInfo;
- var beef4PlayerCount = 0;
- for(i=0; i<Object.keys(beef4Teams).length; i++){
- if(Object.keys(beef4Teams[i].players).length > 0){
- beef4PlayerCount += Object.keys(beef4Teams[i].players).length;
- }
- }
- var beef4IsServerBrowserShowReady = setInterval(function(){
- if($('#serverbrowser-show .holder p').text()){
- clearInterval(beef4IsServerBrowserShowReady);
- var beef4PlusText = $('#serverbrowser-show .holder p').text();
- $('#serverbrowser-show .holder p').after("<p style='background:red; font-size: 18px; padding: 0 5px;'>" + beef4PlayerCount.toString() + "</p>");
- }
- },500);
- },
- complete: function(data){ },
- error: function(xhr,err){
- log("*****ERROR*****");
- log("readyState: "+xhr.readyState);
- log("status: "+xhr.status);
- log("responseText: "+xhr.responseText);
- log("err: "+err);
- log("*****ERROR*****");
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment