Created
June 13, 2023 14:02
-
-
Save sanderfoobar/1133afc9f07c9dc46fa60876b6af7093 to your computer and use it in GitHub Desktop.
discord chat to python server CTF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Discord Greasemonkey XHR to server | |
// @version 1 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// @grant GM_xmlhttpRequest | |
// @grant GM_log | |
// @match https://discord.com/* | |
// ==/UserScript== | |
(function () { | |
setTimeout(() => { | |
unsafeWindow.console.clear (); | |
unsafeWindow.console.log("lets go hax"); | |
var container = $('ol[data-list-id=chat-messages]'); | |
var msgs = container.find('li'); | |
var msg_history = []; | |
$(document).on('DOMNodeInserted', 'ol[data-list-id=chat-messages]', function (e) { | |
let msg = e.target.textContent; | |
if(msg !== "") { | |
unsafeWindow.console.log("ADDED"); | |
if(msg_history[msg_history.length -1] !== msg) { | |
msg_history.push(msg); | |
send(msg); | |
} | |
} | |
}); | |
function send(q){ | |
unsafeWindow.console.log ("SENDING", q); | |
fetch('http://127.0.0.1:3000/', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json, text/plain, */*', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({q: q}) | |
}).then(res => { | |
unsafeWindow.console.log ("ANSWER!", q); | |
res.json(); | |
}) | |
.then(res => { | |
console.log(res); | |
}); | |
} | |
}, 4000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment