Ansolley

Plugin - Advanced Player Links

May 10th, 2019
1,722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 7.52 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. */
  8.  
  9. // initialize your plugin
  10. BBLog.handle("add.plugin", {
  11.  
  12.     /**
  13.     * The unique, lowercase id of my plugin
  14.     * Allowed chars: 0-9, a-z, -
  15.     */
  16.     id : "mrfixit-bf4-advanced-player-links",
  17.  
  18.     /**
  19.     * The name of my plugin, used to show config values in bblog options
  20.     * Could also be translated with the translation key "plugin.name" (optional)
  21.     *
  22.     * @type String
  23.     */
  24.     name : "BF4 Advanced Player Links",
  25.  
  26.     /**
  27.     * Some translations for this plugins
  28.     * For every config flag must exist a corresponding EN translation
  29.     *   otherwise the plugin will no be loaded
  30.     *
  31.     * @type Object
  32.     */
  33.     translations : {
  34.         "en" : {
  35.             "use.player-links" : "Use Advanced Player Links",
  36.             "use.ACI" : "Show ACI",
  37.             "use.247FairPlay" : "Show 247FairPlay",
  38.             "use.BF4DB" : "Show BF4DB",
  39.             "use.PBScreens" : "Show PBScreens",
  40.             "use.Metabans" : "Show Metabans",
  41.             "use.i-Stats" : "Show i-Stats",
  42.             "use.BF4stats" : "Show BF4stats",
  43.             "use.Google" : "Show Google"
  44.         },
  45.         "de" : {
  46.             "use.player-links" : "Advanced Player Links verwenden",
  47.             "use.ACI" : "ACI anzeigen",
  48.             "use.247FairPlay" : "247FairPlay anzeigen",
  49.             "use.BF4DB" : "BF4DB anzeigen",
  50.             "use.PBScreens" : "PBScreens anzeigen",
  51.             "use.Metabans" : "Metabans anzeigen",
  52.             "use.i-Stats" : "i-Stats anzeigen",
  53.             "use.BF4stats" : "BF4stats anzeigen",
  54.             "use.Google" : "Google anzeigen"
  55.         }
  56.     },
  57.  
  58.     /**
  59.     * Configuration Options that appears in the BBLog Menu
  60.     * Every option must be an object with properties as shown bellow
  61.     * Properties available:
  62.     *   key : The name for your config flag - The user can toggle this option
  63.     *         and you can retreive the users choice with instance instance.storage(YOUR_KEY_NAME) (0 or 1 will be returned)
  64.     *   init : Can be 0 or 1 - Represent the initial status of the option when the user load the plugin for the first time
  65.     *          If you want that this option is enabled on first load (opt-out) than set it to 1, otherwise to 0 (opt-in)
  66.     *   handler(optional): When set as a function this config entry turns into a button (like the plugins button you see in the bblog menu)
  67.     *                       The function well be executed when the user clicks the button
  68.     */
  69.     configFlags : [
  70.         {"key" : "use.player-links", "init" : 1},
  71.         {"key" : "use.ACI", "init" : 1},
  72.         {"key" : "use.247FairPlay", "init" : 1},
  73.         {"key" : "use.BF4DB", "init" : 1},
  74.         {"key" : "use.PBScreens", "init" : 1},
  75.         {"key" : "use.Metabans", "init" : 1},
  76.         {"key" : "use.i-Stats", "init" : 1},
  77.         {"key" : "use.BF4stats", "init" : 1},
  78.         {"key" : "use.Google", "init" : 1}
  79.     ],
  80.  
  81.     /**
  82.     * 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
  83.     * 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
  84.     * This make sure that all actions in battlelog been finished before this function been called
  85.     * This is how BBLog track Battlelog for any change, like url, content or anything
  86.     *
  87.     * @param object instance The instance of your plugin which is the whole plugin object
  88.     *    Always use "instance" to access any plugin related function, not use "this" because it's not working properly
  89.     *    For example: If you add a new function to your addon, always pass the "instance" object
  90.     */
  91.     domchange : function(instance){
  92.         if (instance.storage("use.player-links"))
  93.         {
  94.             if(BBLog.cache("mode") == "bf4")
  95.             {
  96.                 if (!$( "#advanced-player-links" ).length) {
  97.                     var urlParts = window.location.pathname.replace(/\/+$/, "").split('/');
  98.                     var personaId = urlParts[urlParts.length - 2];
  99.                    
  100.                     var soldierName = $("#game-stats-head .soldier-info-name span").last().text();
  101.                     var html = "<div id='advanced-player-links' class='box-content no-padding leaderboard-highlight'>";
  102.    
  103.                     html += "<div class='description'>•</div>";
  104.    
  105.                     if (instance.storage("use.ACI")) html += "<div class='description'><a href='//history.anticheatinc.com/bf4/index.php?searchvalue=" + soldierName + "' target='_blank'>ACI</a></div>"
  106.                                                                 + "<div class='description'>•</div>";
  107.    
  108.                     if (instance.storage("use.247FairPlay")) html += "<div class='description'><a href='https://www.247fairplay.com/CheatDetector/" + soldierName + "' target='_blank'>247FairPlay</a></div>"
  109.                                                                     + "<div class='description'>•</div>";
  110.                                                                    
  111.                     if (instance.storage("use.BF4DB")) html += "<div class='description'><a href='https://bf4db.com/player/" + personaId + "' target='_blank'>BF4DB</a></div>"
  112.                                                                     + "<div class='description'>•</div>";
  113.                                                                    
  114.                     if (instance.storage("use.PBScreens")) html += "<div class='description'><a href='https://pbscreens.com/?search&input=" + soldierName + "' target='_blank'>PBScreens</a></div>"
  115.                                                                     + "<div class='description'>•</div>";
  116.                            
  117.                     if (instance.storage("use.Metabans")) html += "<div class='description'><a href='http://metabans.com/search/?phrase=" + soldierName + "' target='_blank'>Metabans</a></div>"
  118.                                                                     + "<div class='description'>•</div>";
  119.                    
  120.                     if (instance.storage("use.i-Stats")) html += "<div class='description'><a href='http://i-stats.net/index.php?action=pcheck&player=" + soldierName + "&game=BF4' target='_blank'>i-Stats</a></div>"
  121.                                                                     + "<div class='description'>•</div>";
  122.                    
  123.                     if (instance.storage("use.BF4stats")) html += "<div class='description'><a href='http://bf4stats.com/search?q=" + soldierName + "' target='_blank'>BF4stats</a></div>"
  124.                                                                     + "<div class='description'>•</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'>•</div>";
  128.    
  129.                     html += "<div class='clear'></div></div>";
  130.                    
  131.                     $("#overview-info div[class=box]").append(html);
  132.                 }
  133.             }
  134.         }
  135.         else
  136.         {
  137.             $( "#advanced-player-links" ).remove();
  138.         }
  139.     }
  140. });
Add Comment
Please, Sign In to add comment