MCPcopy
hub / github.com/Bistutu/FluentRead / procDockerhub

Function procDockerhub

userscripts.js:2022–2059  ·  view source on GitHub ↗
(node, respMap)

Source from the content-addressed store, hash-verified

2020}
2021
2022function procDockerhub(node, respMap) {
2023 let text = format(node.textContent);
2024 if (text && withoutChinese(text)) {
2025 // 处理更新时间的翻译
2026 let timeMatch = text.match(regex.timeRegex);
2027 if (timeMatch) {
2028 let [_, quantity, unit, isPlural] = timeMatch;
2029 quantity = (quantity === 'a' || quantity === 'an') ? ' 1' : ` ${quantity}`; // 将 'a' 或 'an' 转换为 '1'
2030 const unitMap = {'minute': '分钟', 'hour': '小时', 'day': '天', 'month': '月',}; // 单位转换
2031 unit = unitMap[unit] || unit;
2032 node.textContent = `${quantity} ${unit}之前`;
2033 return;
2034 }
2035 // 处理分页信息的翻译
2036 let paginationMatch = text.match(regex.paginationRegex);
2037 if (paginationMatch) {
2038 let [_, start, end, total] = paginationMatch;
2039 total = total.replace(/,/g, ''); // 去除数字中的逗号
2040 node.textContent = `当前第 ${start} - ${end} 项,共 ${total} `;
2041 return;
2042 }
2043 // 处理 "Joined March 27, 2022"
2044 let joinedMatch = text.match(regex.joinedRegex);
2045 if (joinedMatch) {
2046 const date = new Date(joinedMatch[1]);
2047 node.textContent = `加入时间:${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
2048 return;
2049 }
2050 // 处理 "+5 more..."
2051 let moreMatch = text.match(regex.moreRegex);
2052 if (moreMatch) {
2053 node.textContent = `还有${parseInt(moreMatch[1], 10)}个更多...`;
2054 return;
2055 }
2056
2057 processNode(node, textType.textContent, respMap);
2058 }
2059}
2060
2061// endregion

Callers

nothing calls this directly

Calls 3

formatFunction · 0.85
withoutChineseFunction · 0.85
processNodeFunction · 0.85

Tested by

no test coverage detected