From 123524c629419d8a984e1f96639e8fd090345584 Mon Sep 17 00:00:00 2001 From: qcrao Date: Thu, 25 Jul 2024 15:33:23 +0800 Subject: [PATCH] move sendEventAsync define to util.js --- bulkDeleteConversations.js | 33 --------------------------------- utils.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/bulkDeleteConversations.js b/bulkDeleteConversations.js index 68ff420..c2bc5a4 100644 --- a/bulkDeleteConversations.js +++ b/bulkDeleteConversations.js @@ -130,37 +130,4 @@ async function waitForElementToDisappear(selector, timeout = 2000) { throw new Error(`Element ${selector} did not disappear within ${timeout}ms`); } -async function sendEventAsync(count) { - try { - const userInfo = await getUserInfo(); - const timestamp = new Date().toISOString().replace("T", " ").substr(0, 19); - - const data = { - user_id: userInfo.id || "unknown", - timestamp: timestamp, - action: "delete", - count: count, - }; - - const response = await fetch( - "https://bulk-delete-chatgpt-worker.qcrao.com/send-event", - { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - } - ); - - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - - console.log("Event sent successfully"); - } catch (error) { - console.error("Error sending event:", error); - } -} - bulkDeleteConversations(); diff --git a/utils.js b/utils.js index dfd3174..88131e1 100644 --- a/utils.js +++ b/utils.js @@ -12,3 +12,36 @@ function getUserInfo() { }); }); } + +async function sendEventAsync(count) { + try { + const userInfo = await getUserInfo(); + const timestamp = new Date().toISOString().replace("T", " ").substr(0, 19); + + const data = { + user_id: userInfo.id || "unknown", + timestamp: timestamp, + action: "delete", + count: count, + }; + + const response = await fetch( + "https://bulk-delete-chatgpt-worker.qcrao.com/send-event", + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + } + ); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + console.log("Event sent successfully"); + } catch (error) { + console.error("Error sending event:", error); + } +}