SHARE
TWEET

Untitled

a guest Jun 24th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Engine {
  2.  
  3.     overlay_inv = null;
  4.     overlay_eq = null;
  5.     mutation_inveq = null;
  6.  
  7.     constructor() {
  8.         this._prepare_css();
  9.         this._add_overlay();
  10.         $("tg-right-sidebar").css("zoom", "0.7");
  11.  
  12.         MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  13.  
  14.         const mutation_inveq_temp = new MutationObserver(function (mutations, observer) {
  15.  
  16.             let overlay_equip_container = $(".cdk-overlay-container");
  17.  
  18.             if (!overlay_equip_container.length)
  19.                 return;
  20.  
  21.             console.log("trovato eqinv...");
  22.  
  23.             this.disconnect();
  24.  
  25.  
  26.             $global_handler.mutation_inveq = new MutationObserver($global_handler.update_eqine);
  27.  
  28.             console.log("attaching observer");
  29.  
  30.             overlay_equip_container.each(function () {
  31.  
  32.                 $global_handler.mutation_inveq.observe(this, {
  33.                     subtree: true,
  34.                     childList: true
  35.                 });
  36.             });
  37.  
  38.             //overlay_equip_container.css("z-index", "0");
  39.  
  40.         });
  41.  
  42.         $("body").each(function () {
  43.             mutation_inveq_temp.observe(this, {
  44.                 subtree: true,
  45.                 childList: true
  46.             });
  47.         });
  48.  
  49.     }
  50.  
  51.     detach_engine() {
  52.         this.mutation_inveq.disconnect();
  53.     }
  54.  
  55.     update_eqine(mutations, observer) {
  56.         console.log("try update_eginv");
  57.  
  58.         var cont = $(".eqinv-container:last");
  59.  
  60.         if (!cont.length)
  61.             return;
  62.  
  63.         var newcont = cont.clone();
  64.  
  65.         $(newcont).find(".eqinv-switch-action").remove();
  66.  
  67.         var htm = newcont.html();
  68.  
  69.         if (htm.indexOf("Inventario") !== -1) {
  70.             console.log("update inventory");
  71.             $global_handler.overlay_inv.html(newcont.html());
  72.         } else if(htm.indexOf("Equipaggiamento")){
  73.             console.log("update equip");
  74.             $global_handler.overlay_eq.html(newcont.html());
  75.         }
  76.  
  77.     }
  78.  
  79.     _prepare_css() {
  80.         $("<style type='text/css'> .overlay_custom{position:fixed;top:0;left:0;width:380px;height:350px;background-color:#000;z-index:10000} </style>").appendTo("head");
  81.     }
  82.  
  83.     _add_overlay() {
  84.  
  85.         var overlay = jQuery('<div id="overlay_custom_content_inv_drag" class="b-ironlight-mini tg-box overlay_custom">' +
  86.             ' <div id="overlay_custom_content_inv" class="tg-dialog-content-nopadding tg-shadow-inset"> </div><div class="tg-border-box"><div class="tg-border tg-border-top"></div><div class="tg-border tg-border-left"></div><div class="tg-border tg-border-right"></div><div class="tg-border tg-border-bottom"></div></div>' +
  87.             '</div>' +
  88.             '<div id="overlay_custom_content_eq_drag" class="b-ironlight-mini tg-box overlay_custom">' +
  89.             ' <div id="overlay_custom_content_eq" class="tg-dialog-content-nopadding tg-shadow-inset"> </div><div class="tg-border-box"><div class="tg-border tg-border-top"></div><div class="tg-border tg-border-left"></div><div class="tg-border tg-border-right"></div><div class="tg-border tg-border-bottom"></div></div>' +
  90.             '</div>');
  91.         overlay.appendTo(document.body);
  92.  
  93.         this.overlay_inv = $("#overlay_custom_content_inv");
  94.         this.overlay_eq = $("#overlay_custom_content_eq");
  95.  
  96.  
  97.         // Make the DIV element draggable:
  98.         //
  99.         dragElement(document.getElementById("overlay_custom_content_inv_drag"));
  100.         dragElement(document.getElementById("overlay_custom_content_eq_drag"));
  101.  
  102.         function dragElement(elmnt) {
  103.             var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  104.             if (document.getElementById(elmnt.id + "header")) {
  105.                 // if present, the header is where you move the DIV from:
  106.                 document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  107.             } else {
  108.                 // otherwise, move the DIV from anywhere inside the DIV:
  109.                 elmnt.onmousedown = dragMouseDown;
  110.             }
  111.  
  112.             function dragMouseDown(e) {
  113.                 e = e || window.event;
  114.                 e.preventDefault();
  115.                 // get the mouse cursor position at startup:
  116.                 pos3 = e.clientX;
  117.                 pos4 = e.clientY;
  118.                 document.onmouseup = closeDragElement;
  119.                 // call a function whenever the cursor moves:
  120.                 document.onmousemove = elementDrag;
  121.             }
  122.  
  123.             function elementDrag(e) {
  124.                 e = e || window.event;
  125.                 e.preventDefault();
  126.                 // calculate the new cursor position:
  127.                 pos1 = pos3 - e.clientX;
  128.                 pos2 = pos4 - e.clientY;
  129.                 pos3 = e.clientX;
  130.                 pos4 = e.clientY;
  131.                 // set the element's new position:
  132.                 elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  133.                 elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  134.             }
  135.  
  136.             function closeDragElement() {
  137.                 // stop moving when mouse button is released:
  138.                 document.onmouseup = null;
  139.                 document.onmousemove = null;
  140.             }
  141.         }
  142.  
  143.     };
  144. }
  145.  
  146.  
  147. if (window.script === undefined) {
  148.  
  149.  
  150.     if (window.main_function === undefined) {
  151.         $main_function = function () {
  152.             $(document).ready(function () {
  153.                 console.log("creo engine");
  154.                 $global_handler = new Engine();
  155.  
  156.  
  157.                 // define what element should be observed by the observer
  158.                 // and what types of mutations trigger the callback
  159.  
  160.             });
  161.         };
  162.     }
  163.     console.log("carico jquery");
  164.     $script = document.createElement("SCRIPT");
  165.     $script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js';
  166.     $script.type = 'text/javascript';
  167.     $script.onload = function () {
  168.         var $ = window.jQuery;
  169.         // Use $ here...
  170.         $main_function();
  171.     };
  172.     document.getElementsByTagName("head")[0].appendChild($script);
  173. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top