()
| 26 | }; |
| 27 | |
| 28 | async function onDocumentEnd() { |
| 29 | const logs = document.body.innerText |
| 30 | .split("\n") |
| 31 | .filter((_) => _) |
| 32 | .map((_) => _.trim()); |
| 33 | |
| 34 | if (!logs.length) return; |
| 35 | |
| 36 | let hasLog = logs[0] != "Log not found" && logs[0] != "Waking up"; |
| 37 | |
| 38 | const allLogs = logs.map((log) => { |
| 39 | const data = { |
| 40 | log, |
| 41 | uid: extractUid(log), |
| 42 | time: new Date(extractTime(log)), |
| 43 | timeString: extractTime(log).replace(/\d+\/\d+\/\d+, /, ""), |
| 44 | eventName: extractEventName(log), |
| 45 | version: extractVersion(log), |
| 46 | totalCount: extractTotalCount(log), |
| 47 | isScript: isScript(log), |
| 48 | }; |
| 49 | const eventNameWithoutVersion = data.eventName |
| 50 | .replace("(" + data.version + ")", "") |
| 51 | .trim(); |
| 52 | const version = padStr(data.version, 4, " "); |
| 53 | if (version && eventNameWithoutVersion) |
| 54 | data.logPretty = `${data.timeString} | ${version} | ${eventNameWithoutVersion} <i class="show-on-hover">${data.totalCount} ${data.uid}</i>`; |
| 55 | else data.logPretty = data.log; |
| 56 | return data; |
| 57 | }); |
| 58 | |
| 59 | const container = document.createElement("div"); |
| 60 | |
| 61 | if (hasLog) { |
| 62 | UfsGlobal.Extension.getURL("/scripts/ufs_statistic.css").then( |
| 63 | UfsGlobal.DOM.injectCssFile |
| 64 | ); |
| 65 | |
| 66 | // #region re-make UI |
| 67 | document.body.innerText = ""; |
| 68 | |
| 69 | // #region create list |
| 70 | const ol = document.createElement("ol"); |
| 71 | ol.classList.add("log-list"); |
| 72 | ol.setAttribute("reversed", true); |
| 73 | document.body.appendChild(ol); |
| 74 | const all_li = allLogs.map((data) => { |
| 75 | let li = document.createElement("li"); |
| 76 | if (isFbUid(data?.uid)) { |
| 77 | li.innerHTML = |
| 78 | data.logPretty + |
| 79 | ` <a href="https://fb.com/${data.uid}" target="_blank"> |
| 80 | <span data-profile-name="${data.uid}">fb </span> |
| 81 | <img |
| 82 | data-profile-avatar="${data.uid}" |
| 83 | src="${getUserAvatarFromUid(data.uid)}" /> |
| 84 | </a>`; |
| 85 | } else { |
nothing calls this directly
no test coverage detected