Skip to content

Instantly share code, notes, and snippets.

@3ximus
Last active September 27, 2023 16:30
Show Gist options
  • Select an option

  • Save 3ximus/159c2fc7dc20c871cac2806f1ec8e9e3 to your computer and use it in GitHub Desktop.

Select an option

Save 3ximus/159c2fc7dc20c871cac2806f1ec8e9e3 to your computer and use it in GitHub Desktop.

Revisions

  1. 3ximus renamed this gist Sep 27, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. 3ximus created this gist Sep 27, 2023.
    38 changes: 38 additions & 0 deletions patch.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    var originalOpen = originalOpen ? originalOpen : XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function (method, url) {
    this._url = url;
    return originalOpen.apply(this, arguments);
    };

    const MESSAGE = [
    {
    type: "rich_text",
    elements: [
    {
    type: "rich_text_section",
    elements: [
    { type: "text", text: "@Croissantizer", style: { strike: true } },
    { type: "text", text: " DENIED!! Better luck next time !!" },
    ],
    },
    ],
    },
    ];

    var originalSend = originalSend ? originalSend : XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.send = function (data) {
    try {
    if (this._url.includes("api/chat.postMessage")) {
    blocks = JSON.parse(arguments[0].get("blocks"));
    if (
    blocks[0].elements[0].elements[0].type === "user" &&
    blocks[0].elements[0].elements[0].user_id === "U03EB0G8UM8"
    ) {
    arguments[0].set("blocks", JSON.stringify(MESSAGE));
    }
    }
    } catch (e) {
    console.log("FAIL");
    }
    originalSend.apply(this, arguments);
    };