| 455 | } |
| 456 | |
| 457 | async function getTodayTimer() { |
| 458 | let host = |
| 459 | location.hostname || |
| 460 | location.pathname?.split("/")?.at(-1) || |
| 461 | location.href; |
| 462 | let today = getToday(); |
| 463 | let web_timer = (await chrome.storage.local.get(["web_timer"]))?.web_timer; |
| 464 | if (typeof web_timer !== "object") web_timer = {}; |
| 465 | if (typeof web_timer[today] !== "object") web_timer[today] = {}; |
| 466 | if (!web_timer[today][host]) web_timer[today][host] = 0; |
| 467 | let value = Math.floor(web_timer[today][host]); |
| 468 | |
| 469 | return { web_timer, host, today, value }; |
| 470 | } |
| 471 | |
| 472 | function getToday() { |
| 473 | return formatDate(new Date()); |