Skip to content

Instantly share code, notes, and snippets.

@3ximus
Last active September 27, 2023 16:30
Show Gist options
  • Save 3ximus/159c2fc7dc20c871cac2806f1ec8e9e3 to your computer and use it in GitHub Desktop.
Save 3ximus/159c2fc7dc20c871cac2806f1ec8e9e3 to your computer and use it in GitHub Desktop.
Prevent Slack Croissantizer
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);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment