Do you know it?
You have a XING account and didn't visited it for a longer time.
And now you have hundrets of unread messages!
You want to delete them but you need to confirm each deleteation twice oO
For all of you here is a snippet which you can run in the browser console.
The only thing you need is the xing_csrf_token
token which is stored in the cookies.
function clearAllMessages() {
var csrf = 'ENTER YOUR TOKEN HERE';
var body = {
operationName: 'GetMessengerChats',
variables: { first: 20, filter: 'ALL' },
query:
'query GetMessengerChats($first: Int, $after: String, $filter: MessengerChatsFilterTypes) {\n viewer {\n id\n chats(first: $first, after: $after, filter: $filter) {\n edges {\n ...MessengerChatEdge\n __typename\n }\n pageInfo {\n ...MessengerChatsPageInfo\n __typename\n }\n __typename\n }\n __typename\n }\n}\n\nfragment MessengerChatEdge on MessengerChatEdge {\n cursor\n node {\n ...MessengerChatsChat\n __typename\n }\n __typename\n}\n\nfragment MessengerChatsChat on MessengerChat {\n id\n topic\n type\n listedAt\n deleted\n messengerParticipants {\n participant {\n ...MessengerChatsChatParticipant\n __typename\n }\n __typename\n }\n unreadMessagesCount\n lastMessage {\n ...MessengerChatsChatLastMessage\n __typename\n }\n __typename\n}\n\nfragment MessengerChatsChatParticipant on MessengerParticipant {\n ... on XingId {\n pageName\n id\n displayName\n ...MessengerXingIdProfileImages\n __typename\n }\n ... on MessengerUser {\n id\n displayName\n ...MessengerMessengerUserProfileImages\n __typename\n }\n __typename\n}\n\nfragment MessengerXingIdProfileImages on XingId {\n profileImage32: profileImage(size: SQUARE_32) {\n url\n __typename\n }\n profileImage64: profileImage(size: SQUARE_64) {\n url\n __typename\n }\n profileImage128: profileImage(size: SQUARE_128) {\n url\n __typename\n }\n profileImage256: profileImage(size: SQUARE_256) {\n url\n __typename\n }\n __typename\n}\n\nfragment MessengerMessengerUserProfileImages on MessengerUser {\n profileImage32: profileImage(size: SQUARE_32) {\n url\n __typename\n }\n profileImage64: profileImage(size: SQUARE_64) {\n url\n __typename\n }\n profileImage128: profileImage(size: SQUARE_128) {\n url\n __typename\n }\n profileImage256: profileImage(size: SQUARE_256) {\n url\n __typename\n }\n __typename\n}\n\nfragment MessengerChatsChatLastMessage on MessengerMessage {\n author {\n participant {\n ... on XingId {\n id\n displayName\n __typename\n }\n ... on MessengerUser {\n id\n displayName\n __typename\n }\n __typename\n }\n __typename\n }\n preview {\n sender\n text\n __typename\n }\n read\n createdAt\n __typename\n}\n\nfragment MessengerChatsPageInfo on PageInfo {\n hasNextPage\n endCursor\n __typename\n}\n',
};
fetch('https://www.xing.com/xing-one/api', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }).then((res) => {
res.json().then((data) => {
var chats = data.data.viewer.chats.edges;
if (chats.length === 0) {
alert('All messages deleted');
return;
}
var promises = chats.map((chat) => {
return new Promise((resolve) => {
var chatId = chat.node.id;
var body = {
clientTimestamp: Date.now(),
pageName: 'wbm/Messenger/chat',
location: `https://www.xing.com/chats/${chatId}?sc_o=messenger_chat_entry_filtered_messages_all`,
referrer: 'https://www.xing.com/chats',
properties: {
brazeUserId: '24770582',
PropExperiment: 'ABACUS-157|A|A,ABACUS-129|A|0,ABACUS-135|B|B,ABACUS-142|B|B,ABACUS-175|A|0,ABACUS-138|B|B',
PropExperimentInfo: 'ABACUS-157|200|U,ABACUS-129|404|U,ABACUS-135|200|U,ABACUS-142|200|U,ABACUS-175|404|U,ABACUS-138|200|U',
PropChannel: 'wbm/Messenger',
PropAppId: 'ttt@1.7.2',
PropTrackAction: 'messenger_chat_deletion_confirmation_layer_open',
PropActionOrigin: 'messenger_chat_one_on_one_chat',
PropAbacusTriggered: 1,
},
browserWidth: 1331,
browserHeight: 947,
resolution: '1920x1080',
type: 'web',
eventName: 'PropTrackAction',
};
fetch('https://www.xing.com/api/upgraded-umbrella/r', { method: 'POST', headers: { 'Content-Type': 'text/plain;charset=UTF-8' }, body: JSON.stringify(body) }).then(
(res) => {
console.log(res.status);
var body = {
operationName: 'DeleteChat',
variables: { id: chatId },
query: 'mutation DeleteChat($id: ID!) {\n deleteMessengerChat(input: {id: $id}) {\n error {\n message\n __typename\n }\n __typename\n }\n}\n',
};
fetch('https://www.xing.com/xing-one/api', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf },
body: JSON.stringify(body),
}).then((res) => {
console.log(res.status);
resolve();
});
}
);
});
});
Promise.all(promises).then(() => {
clearAllMessages();
});
});
});
}
clearAllMessages();
When all messages are deleted, you got an alert.
Top comments (1)
Hey, just wanted to thank you personally.
I just searched for exactly that functionality. And your code did all the heavy lifting.
Thanks a lot π