Created
August 23, 2024 08:59
-
-
Save Accudio/bc5eece6352770fa91e0503621f17e85 to your computer and use it in GitHub Desktop.
Cheating at mojiparty.io
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 New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-08-22 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.mojiparty.io/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=mojiparty.io | |
// @grant none | |
// ==/UserScript== | |
let emojiSets | |
let textField | |
let button | |
window.guess = () => { | |
textField = textField || document.querySelector('[data-testid="chat-message-input"]') | |
button = button || document.querySelector('[data-testid="chat-send-button"]') | |
const outputContainer = document.querySelector('.sc-bWOGAC.OkkiF .sc-hBxehG.gOmloc') | |
const emojis = [...outputContainer.querySelectorAll('img')].map(el => el.getAttribute('alt')).join('') | |
const currentSet = emojiSets.find(set => { | |
return set.emojiSet === emojis | |
}) | |
console.log(currentSet.answer) | |
textField.value = currentSet.answer | |
} | |
window.init = () => { | |
const container = document.querySelector('#root > *') | |
container.style.transform = 'none' | |
document.querySelector('[data-testid="pass-emojiset-button"]')?.remove() | |
document.querySelector('.sc-kImNAt.Vulyj .sc-hOzowv.iZVgqn')?.remove() | |
const buttonWrap = document.querySelector('.sc-kImNAt.Vulyj') | |
if (!buttonWrap) return | |
const button = document.createElement('button') | |
button.innerText = '⚡Cheat' | |
button.className = 'sc-kDvujY BMHwH' | |
button.style.marginRight = '0.5rem' | |
button.type = 'button' | |
button.addEventListener('click', () => window.guess()) | |
buttonWrap.prepend(button) | |
} | |
try { | |
const parser = await import("https://esm.sh/[email protected]"); | |
const decoder = new parser.Decoder() | |
decoder.on('decoded', (decodedPacket) => { | |
const eventType = decodedPacket.data[0] | |
if (eventType !== 'room-update' || !decodedPacket.data[1].game) return | |
console.log('game', decodedPacket.data[1]) | |
emojiSets = [ | |
decodedPacket.data[1].game.currentEmojiSet, | |
...decodedPacket.data[1].game.emojiSets | |
] | |
}) | |
// create XMLHttpRequest proxy object | |
const oldXMLHttpRequest = window.XMLHttpRequest; | |
// define constructor for my proxy object | |
window.XMLHttpRequest = function() { | |
var actual = new oldXMLHttpRequest(); | |
var self = this; | |
this.onreadystatechange = null; | |
// this is the actual handler on the real XMLHttpRequest object | |
actual.onreadystatechange = function() { | |
if (this.readyState == 4) { | |
for (const packet of actual.responseText.split('')) { | |
decoder.add(packet) | |
} | |
self.responseText = actual.responseText; | |
} | |
if (self.onreadystatechange) { | |
return self.onreadystatechange(); | |
} | |
}; | |
["status", "statusText", "responseType", "response", | |
"readyState", "responseXML", "upload"].forEach(function(item) { | |
Object.defineProperty(self, item, { | |
get: function() {return actual[item];} | |
}); | |
}); | |
["ontimeout, timeout", "withCredentials", "onload", "onerror", "onprogress"].forEach(function(item) { | |
Object.defineProperty(self, item, { | |
get: function() {return actual[item];}, | |
set: function(val) {actual[item] = val;} | |
}); | |
}); | |
["addEventListener", "send", "open", "abort", "getAllResponseHeaders", | |
"getResponseHeader", "overrideMimeType", "setRequestHeader"].forEach(function(item) { | |
Object.defineProperty(self, item, { | |
value: function() {return actual[item].apply(actual, arguments);} | |
}); | |
}); | |
} | |
} catch(e) { let error = e } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment