MCPcopy
hub / github.com/xcanwin/KeepChatGPT / updateEverChangingFromCurrentPage

Function updateEverChangingFromCurrentPage

KeepChatGPT.user.js:2077–2103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2075 };
2076
2077 const updateEverChangingFromCurrentPage = async function () {
2078 const conversationId = extractConversationIdFromPageUrl();
2079 const assistantMessages = $$(`main [data-message-author-role="assistant"]`);
2080 const lastAssistantMessage = assistantMessages[assistantMessages.length - 1];
2081 const last = `${lastAssistantMessage?.innerText || ""}`
2082 .replace(/[\r\n]+/g, " ")
2083 .replace(/\s+/g, " ")
2084 .trim()
2085 .slice(0, 100);
2086 if (!conversationId || !last || !global.st_ec) return;
2087
2088 const oldRecord = (await global.st_ec.get(conversationId)) || {};
2089 const record = {
2090 id: conversationId,
2091 title:
2092 document.title && document.title !== "ChatGPT"
2093 ? document.title
2094 : oldRecord.title || "",
2095 update_time: new Date(),
2096 last: last,
2097 model: oldRecord.model || "",
2098 };
2099 await global.st_ec.put(record);
2100 const kec_object = {};
2101 kec_object[record.id] = record;
2102 scheduleEverChangingAttach(kec_object, 120);
2103 };
2104
2105 const scheduleCurrentConversationRecordUpdate = function (delay = 1200) {
2106 if (global.currentConversationRecordTimer) {

Calls 5

$$Function · 0.85
getMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected