Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name HerosInfo
- // @namespace https://czogi.usermd.net/
- // @version 0.2
- // @description Info na webhook o herosach NI|SI
- // @author Czogi
- // @include /https:\/\/([^forum][^www][a-z]{4,15})\.margonem\.pl/
- // @noframes
- // @icon https://www.google.com/s2/favicons?domain=margonem.pl
- // @grant none
- // ==/UserScript==
- const whData = {
- url: "",
- content:
- "Heros **%npc.nick%(%npc.lvl%)** zrespił się na mapie **%map.name%** na kordach **%hero.x%.%hero.y%**",
- everyone: true
- };
- (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);
- };
- };
- await overwriteFunc(
- isSi ? ["parseInput"] : ["Engine", "communication", "parseJSON"],
- (data) => {
- if (!data.hasOwnProperty("npc")) {
- return;
- }
- for (const [id, npc] of Object.entries(data.npc)) {
- if (
- npc.hasOwnProperty("del") ||
- !npc.hasOwnProperty("wt") ||
- npc.wt > 99 ||
- npc.wt <= 79
- ) {
- continue;
- }
- 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 " : "") +
- setStringProperties(whData.content, {
- npc: npc,
- map: isSi ? window.map : window.Engine.map.d,
- hero: isSi ? window.hero : window.Engine.hero.d
- })
- })
- );
- }
- }
- );
- console.log(`[HerosInfo] Script Initiated.`);
- })(
- typeof unsafeWindow !== "undefined" ? unsafeWindow : window,
- /interface=si/.test(document.cookie),
- (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
- whData
- );
- /* parseInput({
- npc: {
- 99992: {
- nick: "Opętany paladyn",
- icon: "https://micc.garmory-cdn.cloud/obrazki/npc/woj/opetanypaladyn02.gif",
- qm: 0,
- x: hero.x - 1,
- y: hero.y - 1,
- lvl: 83,
- type: 3,
- wt: 80,
- grp: 0
- }
- }
- });
- */
- /*
- 0.1 - Publikacja.
- 0.2 - Poprawa wysyłania ikonki na si.
- */
Add Comment
Please, Sign In to add comment