Advertisement
Guest User

FW

a guest
Feb 27th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Opponent Info
  3. // @namespace    FW
  4. // @version      0.1
  5. // @description  Opponent info
  6. // @author       Yuri
  7. // @match        http://fantasy-world.pl/game
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13. setInterval(function(){
  14.  
  15.     var format = (num, decimals) => num.toLocaleString('en-US', {
  16.         minimumFractionDigits: 1,
  17.         maximumFractionDigits: 2,
  18.     });
  19.     // ile ma życia
  20.     if($(".object-health-now").length !== 0) {
  21.         let obj = {};
  22.         obj['hp_max'] = 32;
  23.         obj['hp'] = format(parseFloat($(".object-health-now").css('width')));
  24.         obj['hp_percent'] = format(obj['hp'] / obj['hp_max'] * 100);
  25.  
  26.         obj['info'] = $(".object-health-now").parent().attr('data-tip');
  27.  
  28.         obj['name'] = obj['info'].split('<br>')[0];
  29.         obj['level'] = obj['info'].split('<small>').pop().split('</small>')[0];
  30.  
  31.  
  32.         if($('#opponent_div').length == 0) {
  33.          let opponent_div = document.createElement("div");
  34.          opponent_div.id = 'opponent_div';
  35.  
  36.          document.body.appendChild(opponent_div);
  37.         } else
  38.             $('#opponent_div').css('display', 'block');
  39.         $('#opponent_div').css({
  40.             "background": "url(https://zapodaj.net/images/3910f787131c7.png)",
  41.             "height": "94px",
  42.             "width": "257px",
  43.             "position": "absolute",
  44.             "left": "20px",
  45.             "top": "50px",
  46.             "z-index": 9999,
  47.             "color": "#eee",
  48.             "box-sizing": "border-box",
  49.             "line-height": "15px",
  50.             "font-size": "12px"
  51.         });
  52.  
  53.         let e = '<div class="opponent-health" style="width: 174px; background-size: '+(174/100)*obj.hp_percent+'px 15px;height:15px;text-align:center;background-repeat:no-repeat;background-image:url(\'http://fantasy-world.pl/templates/client/default/images/others/health_points.png\'); position:absolute;top:23px;left:43px;">'+obj.hp_percent+'%</div>';
  54.         let f = '<div class="opponent-health" style="width: 174px; height:15px;text-align:center;position:absolute;top:47px;left:43px;">'+obj.info.split('<br>').join(' ').split('Poziom:').join('lvl.')+'</div>';
  55.  
  56.  
  57.         $("#opponent_div").html(e + f);
  58.     }else {
  59.         if($('#opponent_div').length !== 0) {
  60.             $('#opponent_div').css('display', 'none');
  61.         }
  62.     }
  63. },500);
  64.  
  65. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement