Trambambaj

Dzielniki Autoupdate

Feb 12th, 2022 (edited)
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Dzielniki
  3. // @version     2.1
  4. // @include     *hegira.com.pl/*
  5. // @author      Thing
  6. // @updateURL   https://pastebin.com/raw/fpPaaiW9
  7. // @downloadURL https://pastebin.com/raw/fpPaaiW9
  8. // @copyright   free
  9. // ==/UserScript==
  10. "use strict";
  11. const dzielnikiKotwica = function (formName) {
  12.     const form =
  13.       formName === "move_station"
  14.         ? $('input[name="station_move_to_ob"]').parent()
  15.         : $(`form[name=${formName}]`);
  16.     form.before(
  17.       '<p>Rozdzielanie współrzędnych</p><input type="text" value size="12" /><button type="button" class="dzielnik" title="Rozdziel współrzędne." >RW</button>'
  18.     );
  19.   };
  20.   const formList = [
  21.     "odpal_sonde",
  22.     "kurs_floty",
  23.     "organizer_add",
  24.     "move_station",
  25.   ];
  26.  
  27. $("button.dzielnik").click(function () {
  28.   const kordy = $(this)
  29.     .prev()
  30.     .val()
  31.     .replace(/-\d\D|.*w1|w[23]|speed.*|[^-\d]/g, ",")
  32.     .replace(/^[,]*/g, "")
  33.     .replace(/,+/g, "w")
  34.     .split("w");
  35.   const output = $(this).next().find('input[type="text"]');
  36.   for (let i = 0; i < 3; i++) {
  37.     output[i].value = kordy[i];
  38.   }
  39. });
  40.  
Add Comment
Please, Sign In to add comment