Czogista

Customowe setUpy menogram 3.03

Jan 2nd, 2021
1,760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Autor: Czogi
  2. //Aby SetUpy zadziałały należy je umieścić za botem w tym samym userscriptcie co menogram.
  3. //Przykłady tworzenia nowych setupów znajdują się w linii ~240 i tam należy je dodawać w podanej kolejności exp,e2,other.
  4. //W przypadku napotkania błędu kontakt discord: Сzogi#8027(588099587605135377)
  5.  
  6. (async () => {
  7.   const sleep = async (time) => {
  8.     return await new Promise((resolve) => setTimeout(resolve, time));
  9.   };
  10.  
  11.   const randomValue = () => {
  12.     const length = ~~(Math.random() * (25 - 10) + 10);
  13.     var result = "";
  14.     var characters =
  15.       "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  16.     var charactersLength = characters.length;
  17.     for (var i = 0; i < length; i++) {
  18.       result += characters.charAt(Math.floor(Math.random() * charactersLength));
  19.     }
  20.     return result;
  21.   };
  22.  
  23.   unsafeWindow.expWindow;
  24.   unsafeWindow.setUpsSelectors;
  25.   const userID = getCookie("user_id");
  26.   const char = getCookie("mchar_id");
  27.   const isSi = getCookie("interface") === "si";
  28.   const world = /(?<=\/)(.*?)(?=\.)/g.exec(location.href)[0].slice(1);
  29.   const expSetUps = [],
  30.     e2SetUps = [],
  31.     otherSetUps = [];
  32.   var init = false;
  33.  
  34.   const setVisibility = (array, mode, spec = false) => {
  35.     const hLvl = isSi ? unsafeWindow.hero.lvl : unsafeWindow.Engine.hero.d.lvl;
  36.     for (const option of array) {
  37.       if (!spec) {
  38.         option.element.style.display = mode;
  39.       } else if (option.min + 17 <= hLvl || option.max - 17 >= hLvl) {
  40.         option.element.style.display = "none";
  41.       } else {
  42.         option.element.style.display = "unset";
  43.       }
  44.     }
  45.   };
  46.  
  47.   class Exp {
  48.     constructor(name, trav, min, max, exp) {
  49.       this.name = name;
  50.       this.trav = trav;
  51.       this.min = min;
  52.       this.max = max;
  53.       this.exp = exp;
  54.       if (!expSetUps.length) {
  55.         const separator = document.createElement("option");
  56.         separator.text = "Custom exp";
  57.         separator.disabled = true;
  58.         unsafeWindow.setUpsSelectors[0].appendChild(separator);
  59.       }
  60.       this.element = document.createElement("option");
  61.       this.element.text = name;
  62.       this.element.value = "e";
  63.       unsafeWindow.setUpsSelectors[0].appendChild(this.element);
  64.     }
  65.     applyChanges() {
  66.       if (!expWindow.children[0].children[1].children[1].children[0].checked) {
  67.         expWindow.children[0].children[1].children[1].children[0].click();
  68.       }
  69.       GM_setValue(`${userID}expMode${char}=${world}`, "on");
  70.       GM_setValue(`${userID}otherMap${char}=${world}`, this.exp);
  71.       GM_setValue(`${userID}mapsRet${char}=${world}`, this.trav);
  72.       GM_setValue(`${userID}myMax${char}=${world}`, this.max);
  73.       GM_setValue(`${userID}myMin${char}=${world}`, this.min);
  74.       expWindow.children[1].children[1].children[1].value = this.exp;
  75.       expWindow.children[2].children[1].children[1].value = this.trav;
  76.       expWindow.children[1].children[0].children[0].value = this.min;
  77.       expWindow.children[1].children[0].children[1].value = this.max;
  78.     }
  79.   }
  80.   class E2 {
  81.     constructor(name, trav, lvl, map, elite, cords = [0, 0]) {
  82.       this.name = name;
  83.       this.trav = trav;
  84.       this.lvl = lvl;
  85.       this.map = map;
  86.       this.elite = elite;
  87.       this.cords = cords;
  88.       if (!e2SetUps.length) {
  89.         const separator = document.createElement("option");
  90.         separator.text = "Custom e2";
  91.         separator.disabled = true;
  92.         unsafeWindow.setUpsSelectors[0].appendChild(separator);
  93.       }
  94.       this.element = document.createElement("option");
  95.       this.element.text = name;
  96.       this.element.value = "e2";
  97.       unsafeWindow.setUpsSelectors[0].appendChild(this.element);
  98.     }
  99.     applyChanges() {
  100.       if (expWindow.children[0].children[1].children[1].children[0].checked) {
  101.         expWindow.children[0].children[1].children[1].children[0].click();
  102.       }
  103.       GM_setValue(`${userID}expMode${char}=${world}`, "off");
  104.       GM_setValue(`${userID}mainMap${char}=${world}`, this.map);
  105.       GM_setValue(`${userID}mapsRet${char}=${world}`, this.trav);
  106.       GM_setValue(
  107.         `${userID}tytData${char}=${world}`,
  108.         GM_getValue(`${userID}tytData${char}=${world}`) + this.name
  109.       );
  110.       GM_setValue(
  111.         `myback${userID}${
  112.           isSi ? unsafeWindow.map.id : unsafeWindow.Engine.map.d.id
  113.         }=${world}`,
  114.         this.cords.join(",")
  115.       );
  116.       expWindow.children[1].children[0].children[1].value = this.elite;
  117.       expWindow.children[1].children[1].children[0].value = this.map;
  118.       expWindow.children[1].children[2].children[0].value = this.cords.join(
  119.         ","
  120.       );
  121.       expWindow.children[2].children[1].children[1].value = this.trav;
  122.     }
  123.   }
  124.   class Other {
  125.     constructor(name, trav, lvl = 0, map = 1, cords = [0, 0]) {
  126.       this.name = name;
  127.       this.trav = trav;
  128.       this.lvl = lvl;
  129.       this.map = map;
  130.       this.cords = cords;
  131.       if (!otherSetUps.length) {
  132.         const separator = document.createElement("option");
  133.         separator.text = "Custom inne";
  134.         separator.disabled = true;
  135.         unsafeWindow.setUpsSelectors[0].appendChild(separator);
  136.       }
  137.       this.element = document.createElement("option");
  138.       this.element.text = name;
  139.       this.element.value = "o";
  140.       unsafeWindow.setUpsSelectors[0].appendChild(this.element);
  141.     }
  142.     applyChanges() {
  143.       if (expWindow.children[0].children[1].children[1].children[0].checked) {
  144.         expWindow.children[0].children[1].children[1].children[0].click();
  145.       }
  146.       GM_setValue(`${userID}expMode${char}=${world}`, "off");
  147.       GM_setValue(`${userID}mainMap${char}=${world}`, this.map);
  148.       GM_setValue(`${userID}mapsRet${char}=${world}`, this.trav);
  149.       GM_setValue(
  150.         `${userID}tytData${char}=${world}`,
  151.         GM_getValue(`${userID}tytData${char}=${world}`) + this.name
  152.       );
  153.       GM_setValue(
  154.         `myback${userID}${
  155.           isSi ? unsafeWindow.map.id : unsafeWindow.Engine.map.d.id
  156.         }=${world}`,
  157.         this.cords.join(",")
  158.       );
  159.       expWindow.children[1].children[1].children[0].value = this.map;
  160.       expWindow.children[1].children[2].children[0].value = this.cords.join(
  161.         ","
  162.       );
  163.       expWindow.children[2].children[1].children[1].value = this.trav;
  164.     }
  165.   }
  166.   do {
  167.     if (GM_getValue("last_t") === "exp") {
  168.       try {
  169.         unsafeWindow.setUpsSelectors = Array.apply(
  170.           null,
  171.           Array.apply(null, document.querySelectorAll(".ui-draggable")).find(
  172.             (element) => {
  173.               return element.innerText?.includes("Main\nRelog");
  174.             }
  175.           ).children
  176.         ).find((element) => {
  177.           return element.innerText?.includes("Stan\n\nExp");
  178.         }).children[2].children[6].children[1].children;
  179.       } catch (error) {
  180.         console.error("Nie znaleziono okna bota, ponawianie.");
  181.       }
  182.     }
  183.     await sleep(1000);
  184.   } while (!unsafeWindow.setUpsSelectors);
  185.  
  186.   //To z lenistwa.
  187.   expWindow =
  188.     setUpsSelectors[0].parentElement.parentElement.parentElement.parentElement;
  189.  
  190.   const categoriesValues = [];
  191.   for (let i = 0; i < 5; i++) {
  192.     categoriesValues.push(randomValue());
  193.   }
  194.  
  195.   while (true) {
  196.     const val = GM_getValue("last_t");
  197.     if (val !== "exp") {
  198.       init = false;
  199.     }
  200.     if (
  201.       (!init && val === "exp") ||
  202.       document.querySelector(`.${setUpsSelectors[1].className}`)
  203.         .childElementCount === 5
  204.     ) {
  205.       try {
  206.         unsafeWindow.setUpsSelectors = Array.apply(
  207.           null,
  208.           Array.apply(null, document.querySelectorAll(".ui-draggable")).find(
  209.             (element) => {
  210.               return element.innerText?.includes("Main\nRelog");
  211.             }
  212.           ).children
  213.         ).find((element) => {
  214.           return element.innerText?.includes("Stan\n\nExp");
  215.         }).children[2].children[6].children[1].children;
  216.         const separator = document.createElement("option");
  217.         separator.text = "        ";
  218.         separator.disabled = true;
  219.         unsafeWindow.setUpsSelectors[1].appendChild(separator);
  220.         for (const [i, mode] of [
  221.           "Custom Wszystko",
  222.           "Custom Exp",
  223.           "Custom e2",
  224.           "Custom Inne",
  225.           "Custom Dedykowane"
  226.         ].entries()) {
  227.           const filterElem = document.createElement("option");
  228.           filterElem.text = mode;
  229.           filterElem.value = categoriesValues[i];
  230.           unsafeWindow.setUpsSelectors[1].appendChild(filterElem);
  231.         }
  232.         expSetUps.length = 0;
  233.         e2SetUps.length = 0;
  234.         otherSetUps.length = 0;
  235.         ////
  236.  
  237.         /*
  238.         #EXP    - Nazwa(String),  Dojście(String),  MinLvl(int),  MaxLvl(int),  Mapy(string)
  239.         #E2     - Nazwa(String),  Dojście(String),  LvlE2(int),  IDMapy(int),  NazwaE2(string), KordryPowrotu(array[2](int))
  240.         #OTHER  - Nazwa(String),  Dojście(String)
  241.         */
  242.  
  243.         ////
  244.         expSetUps.push(new Exp("123", "123", 1, 15, "123"));
  245.         expSetUps.push(new Exp("123", "123", 123, 123, "123"));
  246.         e2SetUps.push(new E2("123", "123", 123, 123, "123", [1, 2]));
  247.         e2SetUps.push(new E2("123", "123", 123, 123, "123", [1, 2]));
  248.         otherSetUps.push(new Other("123", "123,123"));
  249.         ////
  250.  
  251.         setUpsSelectors[0].onchange = () => {
  252.           const selectedOption =
  253.             setUpsSelectors[0].options[setUpsSelectors[0].selectedIndex];
  254.           switch (selectedOption.value) {
  255.             case "e":
  256.               expSetUps
  257.                 .find((element) => {
  258.                   return element.name === selectedOption.text;
  259.                 })
  260.                 .applyChanges();
  261.               break;
  262.             case "e2":
  263.               e2SetUps
  264.                 .find((element) => {
  265.                   return element.name === selectedOption.text;
  266.                 })
  267.                 .applyChanges();
  268.               break;
  269.             case "o":
  270.               otherSetUps
  271.                 .find((element) => {
  272.                   return element.name === selectedOption.text;
  273.                 })
  274.                 .applyChanges();
  275.               break;
  276.           }
  277.         };
  278.         setUpsSelectors[1].onchange = () => {
  279.           const selectedOption =
  280.             setUpsSelectors[1].options[setUpsSelectors[1].selectedIndex];
  281.           switch (selectedOption.value) {
  282.             case categoriesValues[0]:
  283.               setVisibility(e2SetUps, "unset");
  284.               setVisibility(otherSetUps, "unset");
  285.               setVisibility(expSetUps, "unset");
  286.               break;
  287.             case categoriesValues[1]:
  288.               setVisibility(e2SetUps, "none");
  289.               setVisibility(expSetUps, "unset");
  290.               setVisibility(otherSetUps, "none");
  291.               break;
  292.             case categoriesValues[2]:
  293.               setVisibility(expSetUps, "none");
  294.               setVisibility(e2SetUps, "unset");
  295.               setVisibility(otherSetUps, "none");
  296.               break;
  297.             case categoriesValues[3]:
  298.               setVisibility(expSetUps, "none");
  299.               setVisibility(e2SetUps, "none");
  300.               setVisibility(otherSetUps, "unset");
  301.               break;
  302.             case categoriesValues[4]:
  303.               setVisibility(expSetUps, "none", true);
  304.               setVisibility(e2SetUps, "none");
  305.               setVisibility(otherSetUps, "none");
  306.               break;
  307.           }
  308.         };
  309.         init = true;
  310.       } catch (error) {
  311.         console.error("Nie znaleziono okna bota, ponawianie.");
  312.       }
  313.     }
  314.     await sleep(600);
  315.   }
  316. })();
  317.  
Advertisement
Add Comment
Please, Sign In to add comment