[JS snippet] Subscriber compare

pepsicolaa
by pepsicolaa · 10 posts
3 years ago in Javascript
Posted 3 years ago · Author
Hello

As i mentionned somewhere else, i made a script that can be used to compare the subscribers of two accounts, you simply copy/paste the code snippet in your browser console while being and on an imvu domain ( imvu classic website or imvu next is fine ) and it's going to retrieve both account subscribers, compare them and outputs the ones in common in the console. you also need to be logged in to imvu in your browser for it to work

simply replace the const name1 and name2 values by the wanted avatar names or customer id before clicking enter in your console

EG:
const name1 = 'someUser';
const name2 = 'someUser2';

Code
const name1 = 'First Avatar name or customer id here';
const name2 = 'Second Avatar name or customer id here';

const getCid = (name) => {
    return fetch(`https://api.imvu.com/user?username=${name}`, { "credentials": "include" })
        .then(response => response.json())
        .then(data => {
            return Object.entries(data.denormalized)[0][1].data.legacy_cid
        });
}

const getRequest = async(url) => {
    let data = await (await (fetch(url)
        .then(res => {
            return res.json()
        })
        .catch(err => {
            console.log('Error: ', err)
        })
    ))
    return data
}

const getNames = (json) => {
    keys = Object.keys(json.denormalized);
    const followersName = [];
    keys.map(x => {
        if (json.denormalized[x].data.avatar_name) {
            followersName.push(json.denormalized[x].data.avatar_name);
        }
    });
    return followersName;
}

const getNamesInCommon = (array1, array2) => {
    return array1.filter(value => array2.includes(value))
}

const contactapi = async(cid1, cid2) => {
    json1 = await getRequest(`https://api.imvu.com/profile/profile-user-${cid1}/subscribers?limit=50000`);
    json2 = await getRequest(`https://api.imvu.com/profile/profile-user-${cid2}/subscribers?limit=50000`);
    return [json1, json2];
};

const handleSubmit = async(cid1,cid2) => {
    const t = await contactapi(cid1,cid2);
    names1 = getNames(t[0]);
    names2 = getNames(t[1]);
    const common = getNamesInCommon(names1, names2);
    console.log('name in common:', common);
}

(async() => {
    let cid1 = name1;
    let cid2 = name2;
    if (isNaN(cid1)) {
        cid1 = await getCid(cid1);
    }
    if (isNaN(cid2)) {
        cid2 = await getCid(cid2);
    }

    await handleSubmit(cid1,cid2);
})();


If you have any questions, feel free to ask
Enjoy !
Last edited by pepsicolaa on Fri Jul 09, 2021 7:49 am, edited 2 times in total.
Posted 3 years ago
That's pretty dope, makes it easy. Great work man. Though the green matrix font abit hard to read, anyway we can make it more reader friendly?
Posted 3 years ago
Nice job pepsicolaa. Look forward to trying it out.
Posted 3 years ago · Author
@DataMine


Not for this one, i already made complete apps to stalk, using react + node+mongodb but explaining to people how to use docker and how to set everything up is really painful
Posted 3 years ago
@pepsicolaa


True...Docker is a pain in the ass on Windows. Even I couldn't figure it out. However for this you'd just need a simple html page with some input fields and basic javascript to parse the response and render it.
Posted 3 years ago · Author
problem is with imvu CORS, at first it was a greasemonkey script adding 2 inputs to an imvu error page, idk what would have been better, it looks shitty tho, and the output is still in browser console, but i guess i can easily add the namelist to an empty div or something
Posted 3 years ago
@pepsicolaa


Any idea where you would append the empty div to?

I did something similar, where I appended the controls for a bot to the top of IMVU's webpages. It worked pretty well. Getting people to correctly install and use greasemonkey though was a pain.
Posted 3 years ago · Author
@Don Von Alpha Dom


Here is an example of what i did

Code
const createInput = () => {
  const x = document.createElement("input");
   x.setAttribute("type", "text");
   return x;
}

const createLabel = (text) => {
  const x = document.createElement("label");
   x.innerHTML = text
   return x;
}

const createButton = () => {
  const x = document.createElement('button');
  x.setAttribute('type', 'button');
  x.innerText = 'Stalk';
  return x
}

const createDiv = () => {
    const x = document.createElement('div');
  return x;
}

const div = createDiv();

const elements = [createLabel('search'),createInput(),createLabel('userName'),createInput(), createLabel('occupancy'), createInput(), createButton(), createLabel()];
const search=elements[1];
const username= elements[3];
const occupancy = elements[5];
const submit = elements[6];
const counter = elements[7];

elements.map(x => {
div.append(x);
});
document.body.append(div);


Storing them in an array is kinda useless, don't know what i did it but it was months ago, and i placed this above the userscript, and it appends the inputs under the html error message
// @match *://client-dynamic.imvu.com/api/

you could do the same by using doing something like
Code
// With the functions above
const dataDiv = createDiv();

// Your process fetching the data, storing it in yourData
dataDiv.innerHTML= yourData.toString();

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