Advertisement
Trambambaj

Przelączanie flot guzikami

Feb 14th, 2021 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       przełączanie aktywnej floty w przód lub tył
  3. // @version    2.0
  4. // @include    *hegira.com.pl/*
  5. // @copyright  free
  6. // ==/UserScript==
  7. "use strict";
  8. const listaFlot = document.getElementsByName("change_flagship");
  9. const ile = listaFlot.length;
  10. const listaId = [];
  11. for (let i = 0; i < ile; i++) {
  12.   listaId.push(listaFlot[i].value);
  13. }
  14. const html = "[style*='text-shadow: 1px 1px 6px #13AFC8;background:#728992;']"
  15. const aktywId = $(
  16.   `${html}`
  17. )[0].attributes[0].ownerElement.childNodes[0].firstChild[0].value;
  18. const nrAkt = listaId.indexOf(aktywId);
  19. const pUpId = nrAkt === 0 ? false : listaId[nrAkt - 1];
  20. const pDownId = nrAkt === ile - 1 ? false : listaId[nrAkt + 1];
  21. if (pUpId) {
  22.   $('h3:contains("Flota:")').append(
  23.     '<button type= "button" title = "Przełącz aktywną flotę w górę" id = "gora"><--</button>'
  24.   );
  25. }
  26. if (pDownId) {
  27.   $('h3:contains("Flota:")').append(
  28.     '<button type= "button" title = "Przełącz aktywną flotę w dół" id = "dol">--></button>'
  29.   );
  30. }
  31. $("button#gora").click(function () {
  32.   $(`${html}`)
  33.     .prev()
  34.     .children("td")
  35.     .children("form")[0]
  36.     .submit();
  37. });
  38. $("button#dol").click(function () {
  39.   $(`${html}`)
  40.     .next()
  41.     .children("td")
  42.     .children("form")[0]
  43.     .submit();
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement