모든 XING 메시지 삭제

6038 단어 snippejavascriptxing
당신은 그것을 알고 있습니까?
XING 계정이 있고 오랫동안 방문하지 않았습니다.
이제 읽지 않은 메시지가 수백 개 있습니다!

삭제하고 싶지만 삭제를 두 번 확인해야 합니다 oO

여기 여러분 모두를 위해 브라우저 콘솔에서 실행할 수 있는 스니펫이 있습니다.
쿠키에 저장된 xing_csrf_token 토큰만 있으면 됩니다.



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: '[email protected]',
              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();




모든 메시지가 삭제되면 알림이 표시됩니다.

좋은 웹페이지 즐겨찾기