Advertisement
Litib

Heroes And E2 On Discord Fistachy

Jan 20th, 2022 (edited)
1,790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Heroes And E2 On Discord
  3. // @version      21.37
  4. // @description  Info na discord o e2, herosach NI|SI
  5. // @author       Czogi ale Libit przerobil, dzieki Pecio za e2 <3
  6. // @updateURL    https://pastebin.com/raw/MiFiPuuP
  7. // @downloadURL  https://pastebin.com/raw/MiFiPuuP
  8. // @include      /https:\/\/([^forum][^www][a-z]{4,15})\.margonem\.pl/
  9. // @noframes
  10. // @icon         https://cdn.discordapp.com/avatars/419459580335095808/4496293fabe5d96c831678894f2ebe0e.webp?size=80
  11. // ==/UserScript==
  12. const whData = {
  13.     url: "https://discord.com/api/webhooks/932624930523197510/H0--fuvOR1nmXttTt_r_GpIymgHxxpjYWV5CNoBpEw9V-1k1-DdWIMcZAEUGxN1C3mcf",
  14.     content: "**%npc.nick%(%npc.lvl%)** stoi na mapie **%map.name%**",
  15.     everyone: false
  16. };
  17. const e2Data = {
  18.     18614: {
  19.         nick: 'Berserker Amuno',
  20.         icon: 'hum/amuno.gif',
  21.         id: '18614',
  22.         roleId: 'jdjawjda'
  23.     },
  24.     231573: {
  25.         nick: 'Mistrz Worundriel',
  26.         icon: 'hum/worundriel02.gif',
  27.         id: '231573',
  28.         roleId: 'jdjawjda'
  29.     }
  30.  
  31. };
  32. (async (window, isSi, sleep, whData) => {
  33.     "use strict";
  34.     const setStringProperties = (string, objects) => {
  35.         let slicesString = string.split("%");
  36.         for (let i = 0; i < slicesString.length; i++) {
  37.             const currString = slicesString[i];
  38.             if (currString === "." || !currString.includes(".")) {
  39.                 continue;
  40.             }
  41.             const path = currString.split(".");
  42.             const obj = objects[path[0]];
  43.             const data = obj[path[1]];
  44.             slicesString[i] = data ? data : "";
  45.         }
  46.         return slicesString.join("");
  47.     };
  48.     const overwriteFunc = async (path, newFunc) => {
  49.         let currPath = window,
  50.             prevPath = window;
  51.         for (const key of path) {
  52.             while (!currPath.hasOwnProperty(key)) {
  53.                 await sleep(100);
  54.             }
  55.             prevPath = currPath;
  56.             currPath = currPath[key];
  57.         }
  58.         const old = currPath;
  59.         prevPath[path.slice(-1).pop()] = function () {
  60.             newFunc.apply(prevPath, arguments);
  61.             old.apply(prevPath, arguments);
  62.         };
  63.     };
  64.     const whichE2 = (idNpc) => {
  65.         for (const [id, npc] of Object.entries(e2Data)) {
  66.             if (id == idNpc) {
  67.  
  68.                 return npc.roleId;
  69.             }
  70.         }
  71.         return;
  72.     }
  73.     await overwriteFunc(
  74.         isSi ? ["parseInput"] : ["Engine", "communication", "parseJSON"],
  75.         (data) => {
  76.             if (!data.hasOwnProperty("npc")) {
  77.                 return;
  78.             }
  79.             for (const [idNpc, npc] of Object.entries(data.npc)) {
  80.                 if (
  81.                     npc.hasOwnProperty("del") ||
  82.                     !npc.hasOwnProperty("wt") ||
  83.                     npc.hasOwnProperty("walkover")
  84.                 ) {
  85.                     if (e2Data[idNpc] !== undefined && idNpc == e2Data[idNpc].id && !npc.hasOwnProperty("walkover")) {
  86.                         const request = new XMLHttpRequest();
  87.                         request.open("POST", whData.url);
  88.                         request.setRequestHeader("Content-type", "application/json");
  89.                         request.send(
  90.                             JSON.stringify({
  91.                                 username: e2Data[idNpc].nick,
  92.                                 avatar_url: `https://micc.garmory-cdn.cloud/obrazki/npc/${e2Data[idNpc].icon}`,
  93.                                 content: `**${e2Data[idNpc].nick}** - zbito`
  94.                             })
  95.                         );
  96.                     }
  97.                     continue;
  98.                 } else if (
  99.                     npc.wt > 99 ||
  100.                     npc.wt <= 79
  101.                 ) {
  102.                     if (whichE2(idNpc) === undefined) {
  103.                         continue;
  104.                     }
  105.                 } else {
  106.                     whData.everyone = true;
  107.                 }
  108.                 if (isSi) {
  109.                     if (hero.clan) {
  110.                         setTimeout(async () => {
  111.                             _g('chat', {
  112.                                 c: `/k ${npc.nick}!`
  113.                             })
  114.                         }, 1000)
  115.  
  116.                     } else {
  117.                         console.log(`Znaleziono npc: ${npc.nick}`)
  118.                     }
  119.                 } else {
  120.                     if (Engine.hero.d.clan) {
  121.                         setTimeout(async () => {
  122.                             Engine.chat.sendMessage(`/k ${npc.nick}!`)
  123.                         }, 1000)
  124.  
  125.                     } else {
  126.                         console.log(`Znaleziono npc: ${npc.nick}`)
  127.                     }
  128.  
  129.                 }
  130.                 const request = new XMLHttpRequest();
  131.                 request.open("POST", whData.url);
  132.                 request.setRequestHeader("Content-type", "application/json");
  133.                 request.send(
  134.                     JSON.stringify({
  135.                         username: npc.nick,
  136.                         avatar_url: `https://micc.garmory-cdn.cloud/obrazki/npc/${npc.icon}`,
  137.                         content: (whData.everyone ? "@everyone " : "<@&" + whichE2(idNpc) + "> ") +
  138.                             setStringProperties(whData.content, {
  139.                                 npc: npc,
  140.                                 map: isSi ? window.map : window.Engine.map.d,
  141.                                 hero: isSi ? window.hero : window.Engine.hero.d
  142.                             })
  143.                     })
  144.                 );
  145.                 whData.everyone = false;
  146.             }
  147.         }
  148.     );
  149.     console.log(`[Heroes And E2 On Discord] Script Initiated.`);
  150. })(
  151.     typeof unsafeWindow !== "undefined" ? unsafeWindow : window,
  152.     /interface=si/.test(document.cookie),
  153.     (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
  154.     whData
  155. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement