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

Function attachDate

KeepChatGPT.user.js:2483–2588  ·  view source on GitHub ↗
(kec_object)

Source from the content-addressed store, hash-verified

2481 };
2482
2483 const attachDate = function (kec_object) {
2484 $$(`${symbol1_selector} a[href*='/c/']`).forEach(async (el) => {
2485 let a_id;
2486 const a_id_m = el.href.match(
2487 "/(([^/]{4,}?){4}-[^/]{4,}?)(\\?|$)(\\?|$)",
2488 );
2489 if (a_id_m) {
2490 a_id = a_id_m[1];
2491 } else {
2492 return;
2493 }
2494 let kec_obj_el;
2495 if (kec_object) {
2496 kec_obj_el = kec_object[a_id];
2497 } else {
2498 if (global.st_ec) {
2499 kec_obj_el = await global.st_ec.get(a_id);
2500 } else {
2501 kec_obj_el = {};
2502 }
2503 }
2504 const title = (kec_obj_el && kec_obj_el.title) || "";
2505 const update_time = (kec_obj_el && kec_obj_el.update_time) || "";
2506 const last = (kec_obj_el && kec_obj_el.last) || "";
2507 const model = (kec_obj_el && kec_obj_el.model) || "";
2508 const previewText = last || model || "";
2509
2510 if (!title || !update_time) return;
2511 if (!previewText) {
2512 $("[data-kcg-everchanging='true']", el)?.remove();
2513 $$("[data-kcg-original-hidden='true']", el).forEach((node) => {
2514 node.style.display = "";
2515 node.removeAttribute("data-kcg-original-hidden");
2516 });
2517 return;
2518 }
2519 if (
2520 !$(".navtitle", el) ||
2521 !$(".navdate", el) ||
2522 (previewText && !$(".navlast", el))
2523 ) {
2524 const cdiv_old =
2525 $(`.flex.min-w-0.grow.items-center`, el) ||
2526 el.firstElementChild;
2527 if (cdiv_old) {
2528 cdiv_old.style.display = "none";
2529 cdiv_old.setAttribute("data-kcg-original-hidden", "true");
2530 }
2531 const cdiv_new = document.createElement("div");
2532 cdiv_new.className = `flex-1 text-ellipsis overflow-hidden break-all relative`;
2533 cdiv_new.setAttribute("data-kcg-everchanging", "true");
2534 cdiv_new.innerHTML = `
2535<div style="max-height: unset; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: absolute; color: #000000; font-weight: bold;" class="navtitle">
2536 ${htmlEncode(title)}
2537</div>
2538<div style="right: 0; position: absolute; color: gray; font-size: 0.71rem;" class="navdate">
2539 ${formatDate2(update_time)}
2540</div>

Callers 1

Calls 6

$$Function · 0.85
$Function · 0.85
htmlEncodeFunction · 0.85
formatDate2Function · 0.85
getMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected