Advertisement
Ansolley

BF4 Advanced Player Links-

Feb 4th, 2020
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 10.82 KB | None | 0 0
  1. /**
  2. * BF4 Advanced Player Links - Add some advanced player links (Anti-Cheat) to the profile.
  3. *
  4. * @author I-MrFixIt-I + Elementofprgress (ACI)
  5. * @version 1.1.1
  6. * @url https://getbblog.com/de/board/topic/145489/1/BF4-Advanced-player-links
  7. * original: https://bf4cheatreport.com/froadvancedplayerlinks.js
  8. * Edited by Russao
  9. */
  10.  
  11. // initialize your plugin
  12. BBLog.handle("add.plugin", {
  13.  
  14.     /**
  15.     * The unique, lowercase id of my plugin
  16.     * Allowed chars: 0-9, a-z, -
  17.     */
  18.     id : "mrfixit-bf4-advanced-player-links",
  19.  
  20.     /**
  21.     * The name of my plugin, used to show config values in bblog options
  22.     * Could also be translated with the translation key "plugin.name" (optional)
  23.     *
  24.     * @type String
  25.     */
  26.     name : "BF4 Advanced Player Stats",
  27.  
  28.     /**
  29.     * Some translations for this plugins
  30.     * For every config flag must exist a corresponding EN translation
  31.     *   otherwise the plugin will no be loaded
  32.     *
  33.     * @type Object
  34.     */
  35.     translations : {
  36.         "en" : {
  37.             "use.player-stats" : "Use Advanced Player Stats",
  38.             "use.player-links" : "Use Advanced Player Links",
  39.             "use.ACI" : "Show ACI",
  40.             "use.247FairPlay" : "Show 247FairPlay",
  41.             "use.BF4DB" : "Show BF4DB",
  42.             "use.BF4CR" : "Show BF4CR",
  43.             "use.Google" : "Show Google"
  44.         },
  45.         "de" : {
  46.             "use.player-stats" : "Use Advanced Player Stats",
  47.             "use.player-links" : "Use Advanced Player Links",
  48.             "use.ACI" : "ACI anzeigen",
  49.             "use.247FairPlay" : "247FairPlay anzeigen",
  50.             "use.BF4DB" : "BF4DB anzeigen",
  51.             "use.BF4CR" : "BF4CR anzeigen",
  52.             "use.Google" : "Google anzeigen"
  53.         }
  54.     },
  55.  
  56.     /**
  57.     * Configuration Options that appears in the BBLog Menu
  58.     * Every option must be an object with properties as shown bellow
  59.     * Properties available:
  60.     *   key : The name for your config flag - The user can toggle this option
  61.     *         and you can retreive the users choice with instance instance.storage(YOUR_KEY_NAME) (0 or 1 will be returned)
  62.     *   init : Can be 0 or 1 - Represent the initial status of the option when the user load the plugin for the first time
  63.     *          If you want that this option is enabled on first load (opt-out) than set it to 1, otherwise to 0 (opt-in)
  64.     *   handler(optional): When set as a function this config entry turns into a button (like the plugins button you see in the bblog menu)
  65.     *                       The function well be executed when the user clicks the button
  66.     */
  67.     configFlags : [
  68.         {"key" : "use.player-stats", "init" : 1},
  69.         {"key" : "use.player-links", "init" : 1},
  70.         {"key" : "use.ACI", "init" : 1},
  71.         {"key" : "use.247FairPlay", "init" : 1},
  72.         {"key" : "use.BF4DB", "init" : 1}, 
  73.         {"key" : "use.BF4CR", "init" : 1},
  74.         {"key" : "use.Google", "init" : 1}
  75.     ],
  76.  
  77.     /**
  78.     * A trigger that fires everytime when the dom is changing but at max only once each 200ms (5x per second) to prevent too much calls in a short time
  79.     * Example Case: If 10 DOM changes happen in a period of 100ms than this function will only been called 200ms after the last of this 10 DOM changes
  80.     * This make sure that all actions in battlelog been finished before this function been called
  81.     * This is how BBLog track Battlelog for any change, like url, content or anything
  82.     *
  83.     * @param object instance The instance of your plugin which is the whole plugin object
  84.     *    Always use "instance" to access any plugin related function, not use "this" because it's not working properly
  85.     *    For example: If you add a new function to your addon, always pass the "instance" object
  86.     */
  87.     loadonce: 0,
  88.    
  89.     waitforit: 0,
  90.    
  91.     domchange : function(instance){
  92.     if (window.location.href.match(/\/soldier\//i) && window.location.href.match(/\/pc\//i) && window.location.href.match(/\/stats\//i)){
  93.         var urlParts = window.location.pathname.replace(/\/+$/, "").split('/');
  94.         var personaId = urlParts[urlParts.length - 2];
  95.         var ftimeCache = new Date().getTime();
  96.         var inwait = instance.waitforit;
  97.         if (inwait == 0) {
  98.             instance.waitforit = ftimeCache;
  99.             instance.loadonce = 1;
  100.         }
  101.         var resultdiff = ftimeCache - instance.waitforit;
  102.         if (resultdiff > 250) { // 300
  103.             instance.waitforit = 0;
  104.             instance.loadonce = 0;
  105.         }  
  106.         var soldierName = $("#game-stats-head .soldier-info-name span").last().text();      
  107.        
  108.             if(BBLog.cache("mode") == "bf4")
  109.             {  
  110.             if (instance.storage("use.player-links")) {
  111.                 if (!$( "#advanced-player-links" ).length) {                  
  112.                     var bfdbhtml = "";
  113.                     var bfdbhtmld = "";
  114.                     var html = "<div id='advanced-player-links' class='box-content no-padding leaderboard-highlight'>";
  115.                     html += "<div class='description'>&#9760;</div>";
  116.    
  117.                     if (instance.storage("use.ACI")) html += "<div class='description'><a href='//history.anticheatinc.com/bf4/index.php?searchvalue=" + soldierName + "' target='_blank'>ACI</a></div>"
  118.                                                                 + "<div class='description'>&#9760;</div>";
  119.    
  120.                     if (instance.storage("use.247FairPlay")) html += "<div class='description'><a href='https://www.247fairplay.com/CheatDetector/" + soldierName + "' target='_blank'>247FairPlay</a></div>"
  121.                                                                     + "<div class='description'>&#9760;</div>";                                                                
  122.                                                                    
  123.                     if (instance.storage("use.BF4CR")) html += "<div class='description'><a href='https://bf4cheatreport.com?bblog=1&cnt=100&uid=" + soldierName + "' target='_blank'>BF4CR</a></div>"
  124.                                                                     + "<div class='description'>&#9760;</div>";
  125.                    
  126.                     if (instance.storage("use.Google")) html += "<div class='description'><a href='https://www.google.com/#q=%22" + soldierName + "%22' target='_blank'>Google</a></div>"
  127.                                                                     + "<div class='description'>&#9760;</div>";                                                                                        
  128.                    
  129.                     if (instance.storage("use.BF4DB")) html += "<div class='description'><a href='https://bf4db.com/player/" + personaId + "' target='_blank'>BF4DB</a>"+bfdbhtmld+" </div>" + bfdbhtml;
  130.                    
  131.                     html += "<div class='description'>&#9760;</div><div class='clear'></div></div>";
  132.  
  133.                     $("#overview-info div[class=box]").first().append(html);                   
  134.                     $('.leaderboard-highlight').css("height", "45px");
  135.                     $('.description').css("font-size", "16px");                
  136.                 }              
  137.             }
  138.             else {
  139.                 $( "#advanced-player-links" ).remove();
  140.             }  
  141. if (instance.storage("use.player-stats")) {
  142. if (!$( "#advanced-player-stats" ).length) {    
  143. if (instance.loadonce == 0) {
  144. instance.loadonce = 1;
  145. instance.waitforit = 0;
  146. $.getJSON( "https://battlelog.battlefield.com/bf4/warsawWeaponsPopulateStats/"+personaId+"/1/stats/", function( data ) {
  147. var peristhere = $("#bfdb_"+soldierName);
  148. var sname = $("#bfdb_"+soldierName).attr('name');
  149. var setheight = $("#overview-skill");
  150. if (!peristhere.length) {
  151. if (soldierName != sname){
  152. setheight.find(".box-content").css("height", "60px"); // 64px
  153. setheight.find("#overview-skill-value").css("font-size", "24px"); // 28px
  154. setheightb = $("#overview-info-list");
  155. setheightb.find("li").css("height", "56px"); // 94px
  156.   var items = [];
  157.   var totwpkills = 0;
  158.   var hswpkills = 0;
  159.   var totacc = 0;
  160.   var tothit = 0;
  161.   var totfired = 0;
  162.   var vtca = 0;
  163.   var vtcb = 0;
  164.   var disphs = 0;
  165.   var isnip = 0;
  166.   $.each( data.data.mainWeaponStats, function( key, val ) {
  167.    var catitems = ["wA", "wL", "wC", "wX", "waPDW", "wH", "wSR", "waS", "wD"];  
  168.    var catnonhs = ["c4-explosive", "m18-claymore", "m32-mgl", "m15-at-mine", "m2-slam", "ucav", "xm25-smoke", "m224-mortar", "m18-smoke", "m320-fb", "m26-frag", "m26-mass", "aa-mine"];
  169.    if (catitems.indexOf(val.code) > -1) {      
  170.        if (catnonhs.indexOf(val.slug) == -1){
  171.             totwpkills = totwpkills + val.kills;
  172.             hswpkills = hswpkills + val.headshots;
  173.             tothit = tothit + val.shotsHit;
  174.             totfired = totfired + val.shotsFired;
  175.             if (vtca == 0) {
  176.                 vtca = val.kills;
  177.                 disphs = val.headshots;
  178.                 if (val.code == "wSR") { isnip = 20;}
  179.             }
  180.        } else {
  181.         if (vtcb == 0) { vtcb = val.kills; }  
  182.        }
  183.    } else {
  184.         if (vtcb == 0) { vtcb = val.kills; }
  185.    }
  186.   });
  187.  
  188. var acct = 0;  
  189. var hsRate = 0;
  190. if (hswpkills > 0) { hsRate = ((100 / totwpkills) * hswpkills).toFixed(2); }
  191. var hscolor = "#ffffff";
  192. if (hsRate < 25) hscolor = "#ffffff";
  193. if (hsRate > 24) hscolor = "#38a220";
  194. if (hsRate > 34) hscolor = "#ef9e2b";
  195. if (hsRate > 49) hscolor = "#e2361f";
  196. if (totfired > 0) { acct = 100*(tothit/totfired); }
  197. acct = acct.toFixed(2);
  198. var acccolor = "#ffffff";
  199. if (acct < 20) acccolor = "#ffffff";
  200. if (acct > 19) acccolor = "#38a220";
  201. if (acct > 29) acccolor = "#ef9e2b";
  202. if (acct > 39) acccolor = "#e2361f";
  203.  
  204. $("#overview-info div[class=box]").first().append("<div id='bfdb_"+soldierName+"' name='"+soldierName+"'></div>");
  205. instance.loadonce = 1;
  206. instance.waitforit = 0;
  207. var myhtml = '<div id="advanced-player-stats"><li data-tooltip="Total Weapons kills, NO NADES" style="height:56px;"><span style="font-size: 12px;">Weapon Kills</span><strong id="stat-test1">'+totwpkills+'</strong></li><li style="height:56px;" data-tooltip="Headshots - Weapons only"><span style="font-size: 12px;">Headshots</span><strong id="stat-test2" style="color:'+hscolor+'">'+hswpkills+'('+hsRate+'%) </strong></li><li class="last" style="height:56px;" data-tooltip="Accuracy - Weapons only, NO NADES"><span style="font-size: 12px;">Accuracy</span> <strong id="stat-test3" style="color:'+acccolor+'">'+acct+'%</strong> </li></div>';
  208. $("#overview-info-list").first().prepend(myhtml);
  209.  
  210.  if (vtca > vtcb && disphs > 0) {
  211.     var tophsRate = ((100 / vtca) * disphs).toFixed(2);
  212.     var favwp = $("div[class=item-highlighted]").first();
  213.     hscolor = "#ffffff";
  214.     if (tophsRate < (25+isnip)) hscolor = "#ffffff";
  215.     if (tophsRate > (24+isnip)) hscolor = "#38a220";
  216.     if (tophsRate > (34+isnip)) hscolor = "#ef9e2b";
  217.     if (tophsRate > (49+isnip)) hscolor = "#e2361f";
  218.     $favwphtml = '<span class="title">Headshots:</span> <span class="title" style="color:'+hscolor+';">'+disphs+'('+tophsRate+'%)</span>';
  219.     favwp.find("div[class=info]").append($favwphtml);
  220.  }
  221.  var changeli = $("#overview-info-list").first().find("li");
  222.  changeli.find("span").eq(6).text("TOTAL KILLS");
  223.  
  224. }
  225. }
  226.  
  227. });
  228. instance.loadonce = 1;
  229. instance.waitforit = 0;
  230.         }
  231.         }
  232. }
  233.     }
  234. if (inwait == 0) {
  235.     instance.loadonce = 1; // testando
  236. }
  237.     } else {
  238.          instance.loadonce = 0;
  239.          instance.waitforit = 0;
  240.     }
  241.     }
  242. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement