Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Heroes And E2 On Discord
- // @version 21.37
- // @description Info na discord o e2, herosach NI|SI
- // @author Czogi ale Libit przerobil, dzieki Pecio za e2 <3
- // @updateURL https://pastebin.com/raw/MiFiPuuP
- // @downloadURL https://pastebin.com/raw/MiFiPuuP
- // @include /https:\/\/([^forum][^www][a-z]{4,15})\.margonem\.pl/
- // @noframes
- // @icon https://cdn.discordapp.com/avatars/419459580335095808/4496293fabe5d96c831678894f2ebe0e.webp?size=80
- // ==/UserScript==
- const whData = {
- url: "https://discord.com/api/webhooks/932624930523197510/H0--fuvOR1nmXttTt_r_GpIymgHxxpjYWV5CNoBpEw9V-1k1-DdWIMcZAEUGxN1C3mcf",
- content: "**%npc.nick%(%npc.lvl%)** stoi na mapie **%map.name%**",
- everyone: false
- };
- const e2Data = {
- 18614: {
- nick: 'Berserker Amuno',
- icon: 'hum/amuno.gif',
- id: '18614',
- roleId: 'jdjawjda'
- },
- 231573: {
- nick: 'Mistrz Worundriel',
- icon: 'hum/worundriel02.gif',
- id: '231573',
- roleId: 'jdjawjda'
- }
- };
- (async (window, isSi, sleep, whData) => {
- "use strict";
- const setStringProperties = (string, objects) => {
- let slicesString = string.split("%");
- for (let i = 0; i < slicesString.length; i++) {
- const currString = slicesString[i];
- if (currString === "." || !currString.includes(".")) {
- continue;
- }
- const path = currString.split(".");
- const obj = objects[path[0]];
- const data = obj[path[1]];
- slicesString[i] = data ? data : "";
- }
- return slicesString.join("");
- };
- const overwriteFunc = async (path, newFunc) => {
- let currPath = window,
- prevPath = window;
- for (const key of path) {
- while (!currPath.hasOwnProperty(key)) {
- await sleep(100);
- }
- prevPath = currPath;
- currPath = currPath[key];
- }
- const old = currPath;
- prevPath[path.slice(-1).pop()] = function () {
- newFunc.apply(prevPath, arguments);
- old.apply(prevPath, arguments);
- };
- };
- const whichE2 = (idNpc) => {
- for (const [id, npc] of Object.entries(e2Data)) {
- if (id == idNpc) {
- return npc.roleId;
- }
- }
- return;
- }
- await overwriteFunc(
- isSi ? ["parseInput"] : ["Engine", "communication", "parseJSON"],
- (data) => {
- if (!data.hasOwnProperty("npc")) {
- return;
- }
- for (const [idNpc, npc] of Object.entries(data.npc)) {
- if (
- npc.hasOwnProperty("del") ||
- !npc.hasOwnProperty("wt") ||
- npc.hasOwnProperty("walkover")
- ) {
- if (e2Data[idNpc] !== undefined && idNpc == e2Data[idNpc].id && !npc.hasOwnProperty("walkover")) {
- const request = new XMLHttpRequest();
- request.open("POST", whData.url);
- request.setRequestHeader("Content-type", "application/json");
- request.send(
- JSON.stringify({
- username: e2Data[idNpc].nick,
- avatar_url: `https://micc.garmory-cdn.cloud/obrazki/npc/${e2Data[idNpc].icon}`,
- content: `**${e2Data[idNpc].nick}** - zbito`
- })
- );
- }
- continue;
- } else if (
- npc.wt > 99 ||
- npc.wt <= 79
- ) {
- if (whichE2(idNpc) === undefined) {
- continue;
- }
- } else {
- whData.everyone = true;
- }
- if (isSi) {
- if (hero.clan) {
- setTimeout(async () => {
- _g('chat', {
- c: `/k ${npc.nick}!`
- })
- }, 1000)
- } else {
- console.log(`Znaleziono npc: ${npc.nick}`)
- }
- } else {
- if (Engine.hero.d.clan) {
- setTimeout(async () => {
- Engine.chat.sendMessage(`/k ${npc.nick}!`)
- }, 1000)
- } else {
- console.log(`Znaleziono npc: ${npc.nick}`)
- }
- }
- const request = new XMLHttpRequest();
- request.open("POST", whData.url);
- request.setRequestHeader("Content-type", "application/json");
- request.send(
- JSON.stringify({
- username: npc.nick,
- avatar_url: `https://micc.garmory-cdn.cloud/obrazki/npc/${npc.icon}`,
- content: (whData.everyone ? "@everyone " : "<@&" + whichE2(idNpc) + "> ") +
- setStringProperties(whData.content, {
- npc: npc,
- map: isSi ? window.map : window.Engine.map.d,
- hero: isSi ? window.hero : window.Engine.hero.d
- })
- })
- );
- whData.everyone = false;
- }
- }
- );
- console.log(`[Heroes And E2 On Discord] Script Initiated.`);
- })(
- typeof unsafeWindow !== "undefined" ? unsafeWindow : window,
- /interface=si/.test(document.cookie),
- (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
- whData
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement