IMVU-Desktop-Message-Tracker

Toolyx
by Toolyx · 2 posts
1 year ago in Javascript
Posted 1 year ago · Author
Code
// Initialize variables
let lastMessage = "";
let timeout = null;
let scriptEnabled = true;

// Create button element
const toggleScriptBtn = document.createElement("button");
toggleScriptBtn.innerHTML = "Run Script";
toggleScriptBtn.style.position = "absolute";
toggleScriptBtn.style.top = "0";
toggleScriptBtn.style.left = "0";
toggleScriptBtn.style.zIndex = "9999";



// Add click event listener to button
toggleScriptBtn.addEventListener("click", () => {
    scriptEnabled = !scriptEnabled;
    if (scriptEnabled) {
        toggleScriptBtn.innerHTML = "Disable Script";
    } else {
        toggleScriptBtn.innerHTML = "Enable Script";
    }
});

// Append button to body
document.body.appendChild(toggleScriptBtn);

if (scriptEnabled) {
    async function sendToWebhook(data) {
        // Replace this with your Discord webhook URL
        const webhookURL = "YOUR WEBHOOK URL!";
        // Send message to webhook
        const response = await fetch(webhookURL, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify(data),
        });

        if (!response.ok) {
            throw new Error(`Failed to send data to webhook: ${response.status}`);
        }
    }
    function listen(fn) {
        fn = fn || console.log;
        let property = Object.getOwnPropertyDescriptor(MessageEvent.prototype, "data");
        const data = property.get;
        function lookAtMessage() {
            let socket = this.currentTarget instanceof WebSocket;
            if (!socket) {
                return data.call(this);
            }
            let msg = data.call(this);
            Object.defineProperty(this, "data", { value: msg });
            fn({ data: msg, socket: this.currentTarget, event: this });
            return msg;
        }
        property.get = lookAtMessage;
        Object.defineProperty(MessageEvent.prototype, "data", property);
    }
    // Listen for websocket messages
    listen(({ data }) => {
        if (scriptEnabled) {
            // Parse data
            const parse = JSON.parse(data);
            if (parse.record === "msg_g2c_send_message") {
                // Base 64 decode the msg
                let message = JSON.parse(atob(parse.message));
                if (!message.message) {
                    return;
                }
                // Check if message is different from last message
                if (lastMessage !== message.message) {
                    if (timeout) {
                        clearTimeout(timeout);
                    }
                    // check if message should be filtered (You can add the other ones in here!)
                    if (message.message.startsWith("*use") || message.message.startsWith("*imvu:isPureUser") || message.message.startsWith("*putOnOutfit") || message.message.startsWith("*msg")) {
                        return;
                    }
                    lastMessage = message.message;
                    timeout = setTimeout(() => {
                        sendToWebhook({
                            content: message.message,
                            username: message.userId,
                            avatar_url: `https://www.imvu.com/catalog/web_mugshot.php?user=${message.userId}`,
                        });
                    }, 1000);
                }
            }
        }
    });
}


(This code is meant to run in the web-page-console)






I created this script as a part of my experimentation with IMVU Desktop. Despite having some positive results, it is not yet fully optimized! I'm not a big js guy and you will find lots of bugs. Additionally, I have spent significant time and effort in the development and redesign of my GhostVu project, and I am excited to announce that a new version of the web-application, with a wide range of new features, will be released soon. :)
Posted 1 year ago
Thank you ill be checking your posts :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts