<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dawosch</title>
    <description>The latest articles on DEV Community by Dawosch (@dawosch).</description>
    <link>https://dev.to/dawosch</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F894485%2Fa460d9eb-b827-4272-8fe1-755c953488eb.png</url>
      <title>DEV Community: Dawosch</title>
      <link>https://dev.to/dawosch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dawosch"/>
    <language>en</language>
    <item>
      <title>Delete all XING Messages</title>
      <dc:creator>Dawosch</dc:creator>
      <pubDate>Mon, 29 Aug 2022 08:31:00 +0000</pubDate>
      <link>https://dev.to/dawosch/delete-all-xing-messages-30jc</link>
      <guid>https://dev.to/dawosch/delete-all-xing-messages-30jc</guid>
      <description>&lt;p&gt;Do you know it?&lt;br&gt;
You have a XING account and didn't visited it for a longer time.&lt;br&gt;
And now you have hundrets of unread messages!&lt;/p&gt;

&lt;p&gt;You want to delete them but you need to confirm each deleteation twice oO&lt;/p&gt;

&lt;p&gt;For all of you here is a snippet which you can run in the browser console.&lt;br&gt;
The only thing you need is the &lt;code&gt;xing_csrf_token&lt;/code&gt; token which is stored in the cookies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S7isbLcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vih4u7cn0goi15i9gk8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S7isbLcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vih4u7cn0goi15i9gk8.png" alt="Xing Cookie" width="582" height="318"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;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) =&amp;gt; {
    res.json().then((data) =&amp;gt; {
      var chats = data.data.viewer.chats.edges;

      if (chats.length === 0) {
        alert('All messages deleted');
        return;
      }

      var promises = chats.map((chat) =&amp;gt; {
        return new Promise((resolve) =&amp;gt; {
          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) =&amp;gt; {
              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) =&amp;gt; {
                console.log(res.status);

                resolve();
              });
            }
          );
        });
      });

      Promise.all(promises).then(() =&amp;gt; {
        clearAllMessages();
      });
    });
  });
}

clearAllMessages();


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When all messages are deleted, you got an alert.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>snippe</category>
      <category>xing</category>
    </item>
  </channel>
</rss>
