Advertisement
Trambambaj

panel flot beta dla 5.0

Apr 4th, 2022 (edited)
1,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @author       Thing
  3. // @name         Panel Flot dla beta 5.x
  4. // @version      1.27
  5. // @match        *hegira.com.pl/*
  6. // @match        *hegira.eu/*
  7. // @updateURL    https://pastebin.com/raw/XXNwXk3f
  8. // @downloadURL  https://pastebin.com/raw/XXNwXk3f
  9. // @copyright    free
  10. // @noframes
  11. // ==/UserScript==
  12. "use strict";
  13. let ppdr;
  14. if (!window.location.href.includes("4.0")) {
  15.   $("head").append(
  16.     "<style>.panelFSkr{padding:5px;text-align:center;}.loader{border:16px solid #f3f3f3;border-radius: 50%;border-top: 16px solid #3498db;width: 100px;height: 100px;-webkit-animation: spin 2s linear infinite; /* Safari */ animation: spin 2s linear infinite;}/* Safari */@-webkit-keyframes spin {  0% { -webkit-transform: rotate(0deg); }  100% { -webkit-transform: rotate(360deg); }}@keyframes spin {  0% { transform: rotate(0deg); }  100% { transform: rotate(360deg); }}</style>"
  17.   );
  18.   //ustawianie panelu
  19.   const pozycjaPanelu =
  20.     (document.cookie
  21.       .split("; ")
  22.       .filter((x) => x.includes("panelFloty"))
  23.       .map(function (x) {
  24.         const temp = x.includes("panelFlotyy=")
  25.           ? `left:${x.replace("panelFlotyy=", "")};`
  26.           : `top:${x.replace("panelFlotyx=", "")};`;
  27.         return temp;
  28.       })
  29.       .join(" ") || "left:1535px; top:45px;") + "z-index:1;";
  30.   //dodawacz panelu i iframe'ow
  31.   const dodawacz = function () {
  32.     $("#pudlo").append(
  33.       `<div id="panelFloty" class="dragme" style="${pozycjaPanelu}">` +
  34.         `<div class="div_efekt" style="border: 4px ridge #016161;border-radius: 25px 25px 40px 25px; width:400px;">` +
  35.         `<iframe name='invisiblev2' id='invisiblev2' style='display:none;'></iframe>` +
  36.         `<div style="padding:5px;"id="wypel">` +
  37.         `<center><div class="loader"></div></center` +
  38.         `</div></div>` +
  39.         `<iframe id="kombo" name="kombo" src="engine.php?menu=port_fleet" style="display:none;";></iframe>` +
  40.         `</div>`
  41.     );
  42.   };
  43.   function buttonChanger() {
  44.     //kolko czytywania
  45.     if ($("div.loader").length === 0)
  46.       $("div#wypel").append(`<center><div class="loader"></div></center>`);
  47.     document.getElementById("invisiblev2").onload = function () {
  48.       $("#kombo")[0].src = "engine.php?menu=port_fleet";
  49.       document.getElementById("kombo").onload = function () {
  50.         ppdr = $($("#kombo")[0].contentDocument).find("#srodeksyswSzeroki")[0]
  51.           .outerHTML;
  52.         const temp = $($("#kombo")[0].contentDocument);
  53.         //pierwszy if sprawdza czy strona iframe'a zaladowala sie poprawnie
  54.         if ($(temp).find("#pudlo").length > 0) {
  55.           wypelniacz(temp);
  56.           const divIdAr = ["#pole_komunikatu", "#zasobysysw > ul", "#mapa"];
  57.           if (
  58.             window.location.href.includes(
  59.               "hegira.com.pl/engine.php?menu=port_fleet"
  60.             )
  61.           ) {
  62.             // location.reload();
  63.             // return;
  64.             $("#srodeksyswSzeroki")[0].outerHTML = ppdr;
  65.           }
  66.           const divUpdater = function (divId) {
  67.             $(divId)[0].innerHTML = $(temp).find(divId)[0].innerHTML;
  68.           };
  69.           divIdAr.forEach(divUpdater);
  70.         } else {
  71.           alert("Wystąpił nieoczekiwany błąd");
  72.           location.reload();
  73.         }
  74.       };
  75.     };
  76.   }
  77.   //podmienia targety dla formow przy klikaniu guzikow
  78.   const stopPrzekierowaniu = function () {
  79.     $("div.wypel")
  80.       .find("form")
  81.       .not('[name="obejrzyj_sonde"]')
  82.       .each(function () {
  83.         $((this.target = "invisiblev2"));
  84.       });
  85.     $("div.wypel")
  86.       .find("button")
  87.       .click(function () {
  88.         if ($(this)[0].classList[0] == "dzielnik") {
  89.           const kordy = $(this)
  90.             .prev()
  91.             .val()
  92.             .replace(/-\d\D|.*w1|w[23]|speed.*|[^-\d]/g, ",")
  93.             .replace(/^[,]*/g, "")
  94.             .replace(/,+/g, "w")
  95.             .split("w");
  96.           const output = $(this).next().find('input[type="text"]');
  97.           for (let i = 0; i < 3; i++) {
  98.             output[i].value = kordy[i];
  99.           }
  100.         } else if (
  101.           this.innerHTML == "D" ||
  102.           this.innerHTML == " Podgląd z sondy"
  103.         ) {
  104.         } else {
  105.           buttonChanger();
  106.         }
  107.       });
  108.     //guziki nie button
  109.     $("div.wypel").find('input[type="submit"]').click(buttonChanger);
  110.     $("div.wypel").find('input[value="Submit"]').click(buttonChanger);
  111.   };
  112.   //tworzy zawartosc panelu
  113.   function wypelniacz(r) {
  114.     const fdr = function (co, resp = r) {
  115.       return $(resp).find(co)[0];
  116.     };
  117.     const dzielnikStr =
  118.       '<p>Rozdzielanie współrzędnych</p><input type="text" value size="12" /><button type="button" class="dzielnik" title="Rozdziel współrzędne." >RW</button>';
  119.  
  120.     let nFloty;
  121.     let listaFlot;
  122.     let pozycja;
  123.     let rozkazy;
  124.     let sterowanie;
  125.     let celowanie;
  126.     let techniczne;
  127.     let ladownia;
  128.     let walka;
  129.     const zestaw = [];
  130.     let wyp;
  131.     let obecnaZakl =
  132.       Number(localStorage.obecnaZakl) || (localStorage.obecnaZakl = 1);
  133.  
  134.     listaFlot = fdr(".okienko_floty_9");
  135.     let aktFl;
  136.     //zapamietuje akt flote
  137.     const aktualizator = function () {
  138.       $(fdr(".okienko_floty_9"))
  139.         .find("tr")
  140.         .each(function () {
  141.           if (
  142.             this.style.cssText ===
  143.             "text-shadow: rgb(19, 175, 200) 1px 1px 6px; background: rgb(114, 137, 146);"
  144.           )
  145.             aktFl = this;
  146.         });
  147.     };
  148.     aktualizator();
  149.     let prevFl = $(aktFl).prev().find("button.guzik_wybor_floty").parent()[0];
  150.     prevFl && (prevFl.target = "invisiblev2");
  151.     let nextFl = $(aktFl).next().find("button.guzik_wybor_floty").parent()[0];
  152.     nextFl && (nextFl.target = "invisiblev2");
  153.     //usuwa div z flotami by zapobiec dupkiowaniu
  154.     $("#dFlot").remove();
  155.     //dolacza divy z formami do body dla gozikow do zmiany flot, bo bez tego te guziki nie istnieja w dokumencie zatem nie moga dzialac
  156.     $(document.body).append(
  157.       `<div id="dFlot" style="display:none;"><div id="prevFlFrm">${prevFl?.outerHTML}</div><div id="nextFlFrm">${nextFl?.outerHTML}</div></div>`
  158.     );
  159.     listaFlot = $(listaFlot).find("ul");
  160.     listaFlot.style = "";
  161.     listaFlot = listaFlot[1];
  162.     listaFlot.style = "";
  163.     listaFlot = listaFlot.outerHTML;
  164.     zestaw.push(listaFlot);
  165.     pozycja = fdr(".okienko_floty_6").innerHTML;
  166.     rozkazy = fdr(".okienko_w_stoczni");
  167.     nFloty = $(rozkazy).find("h3")[0].innerHTML;
  168.     $(rozkazy).find("h2").remove();
  169.     $(rozkazy).find("h3").remove();
  170.     $(rozkazy).find(".okienko_floty_9")[0].remove();
  171.     $(rozkazy).find("div")[0].style = "";
  172.     rozkazy = rozkazy.innerHTML + pozycja;
  173.     zestaw.push(rozkazy);
  174.     sterowanie = fdr(".okienko_floty_1");
  175.     $(sterowanie).find('form[name="kurs_floty"]').before(dzielnikStr);
  176.     sterowanie = sterowanie.innerHTML;
  177.     zestaw.push(sterowanie);
  178.     celowanie = fdr(".okienko_floty_3");
  179.     $(celowanie).find('input[name="max_targets_id"]').siblings("p").remove();
  180.     celowanie = celowanie.innerHTML;
  181.     zestaw.push(celowanie);
  182.     techniczne = fdr(".okienko_floty_4");
  183.     $(techniczne).find('form[name="odpal_sonde"]').before(dzielnikStr);
  184.     techniczne = techniczne.innerHTML;
  185.     zestaw.push(techniczne);
  186.     ladownia =
  187.       $(fdr("p:contains(Zawarto)")).parent()[0]?.outerHTML ||
  188.       "<h3>Ładownie floty są puste.</h3";
  189.     zestaw.push(ladownia);
  190.     walka = fdr("#porownanie_flotw");
  191.     if (walka) {
  192.       walka = `${$(walka).find('form[name="kupmiasto3"]')[0]?.outerHTML}
  193.       ${$(walka).find('table[class="fleets"]')[0]?.outerHTML}
  194.       ${$(walka).find('table[class="fleets"]')[1]?.outerHTML}`;
  195.     } else walka = "<h3>Nie prowadzisz obecnie bitwy</h3>";
  196.     zestaw.push(walka);
  197.     wyp =
  198.       `<div style="text-align: center; padding-bottom:20px;">` +
  199.       `<center><p style="font-size: 125%; margin-bottom: 10px;">${
  200.         prevFl ? '<button type="button" class="zmFl" value="1"><</button>' : ""
  201.       } Aktywna ${nFloty} ${
  202.         nextFl ? '<button type="button" class="zmFl" value="2">></button>' : ""
  203.       }</p></center>` +
  204.       `<button type="button" class="panelFSkr"  value="2">Rozkazy</button>` +
  205.       `<button type="button" class="panelFSkr"  value="1">Lista Flot</button>` +
  206.       `<button type="button" class="panelFSkr"  value="3">Sterowanie</button>` +
  207.       `<button type="button" class="panelFSkr"  value="4">Celowanie</button>` +
  208.       `<button type="button" class="panelFSkr"  value="5">Techniczne</button>` +
  209.       `<button type="button" class="panelFSkr"  value="6">Ładownia</button>` +
  210.       `<button type="button" class="panelFSkr"  value="7">Walka</button>` +
  211.       `</div>` +
  212.       `<center><div class="wypel" style ="max-height:500px;overflow-y:auto;">${
  213.         zestaw[obecnaZakl - 1]
  214.       }</div></center>`;
  215.     $("div#wypel")[0].innerHTML = wyp;
  216.     $("button.zmFl").click(function () {
  217.       if (this.value == 1) {
  218.         $("#prevFlFrm").children().submit();
  219.         aktualizator();
  220.         buttonChanger();
  221.       } else if (this.value == 2) {
  222.         $("#nextFlFrm").children().submit();
  223.         aktualizator();
  224.         buttonChanger();
  225.       }
  226.     });
  227.     $("button.panelFSkr").click(function () {
  228.       localStorage.obecnaZakl = this.value;
  229.       $("div.wypel")[0].innerHTML = zestaw[Number(this.value) - 1];
  230.       if (localStorage.obecnaZakl == 7) {
  231.         $("div.wypel")[0].style.overflowX = "scroll";
  232.       } else $("div.wypel")[0].style.overflowX = "auto";
  233.       stopPrzekierowaniu();
  234.     });
  235.     stopPrzekierowaniu();
  236.     fetch(window.location.href);
  237.   }
  238.   dodawacz();
  239.   document.getElementById("kombo").onload = function () {
  240.     wypelniacz($("#kombo")[0].contentDocument);
  241.   };
  242. }
  243.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement