安裝與設定方式
- 先在 Mac 上安裝並開啟 Glanceway,再使用上方的安裝連結。
- 點選「安裝到 Glanceway」。若瀏覽器無法開啟應用程式,下載 .gwsrc 檔案並在資訊源管理中匯入。
- 填寫以下必填欄位並儲存,設定更新間隔,等待首次成功取得內容。
目前版本沒有必填設定欄位,安裝後等待首次取得內容即可。
沒有顯示內容時如何排查
- 對照目前版本設定表檢查欄位、清單項目與憑證。下方範例不包含可用的真實憑證。
- 檢查網路及上游服務狀態。認證失敗或速率限制可能使更新失敗,請依上游限制調整間隔。
- 空清單也可能代表沒有符合條件的條目。內容與更新時間取決於資料提供方及資訊源實作。
原始碼
id: codytseng/xkcd
version: 1.0.0
name: xkcd Comics
description: Latest comics from xkcd
author: codytseng
author_url: https://github.com/codytseng
category: Entertainment
tags:
- comics
- humor
- science id: codytseng/xkcd
version: 1.0.0
name: xkcd Comics
description: Latest comics from xkcd
author: codytseng
author_url: https://github.com/codytseng
category: Entertainment
tags:
- comics
- humor
- science module.exports = async (api) => {
async function fetchData() {
const latestRes = await api.fetch(
"https://xkcd.com/info.0.json",
);
if (!latestRes.ok || !latestRes.json) {
throw new Error(`Failed to fetch latest xkcd comic (HTTP ${latestRes.status})`);
}
const latest = latestRes.json;
const count = 50;
const comics = [latest];
await Promise.allSettled(
Array.from({ length: count - 1 }, (_, i) => latest.num - i - 1)
.filter((num) => num > 0 && num !== 404)
.map(async (num) => {
const res = await api.fetch(
`https://xkcd.com/${num}/info.0.json`,
);
if (res.ok && res.json) {
comics.push(res.json);
api.emit(
comics.map((c) => ({
id: c.num.toString(),
title: `#${c.num}: ${c.title}`,
subtitle: c.alt,
url: `https://xkcd.com/${c.num}/`,
timestamp: `${c.year}-${c.month.padStart(2, "0")}-${c.day.padStart(2, "0")}`,
})),
);
}
}),
);
}
await fetchData();
return {
refresh: fetchData,
};
}; module.exports = async (api) => {
async function fetchData() {
const latestRes = await api.fetch(
"https://xkcd.com/info.0.json",
);
if (!latestRes.ok || !latestRes.json) {
throw new Error(`Failed to fetch latest xkcd comic (HTTP ${latestRes.status})`);
}
const latest = latestRes.json;
const count = 50;
const comics = [latest];
await Promise.allSettled(
Array.from({ length: count - 1 }, (_, i) => latest.num - i - 1)
.filter((num) => num > 0 && num !== 404)
.map(async (num) => {
const res = await api.fetch(
`https://xkcd.com/${num}/info.0.json`,
);
if (res.ok && res.json) {
comics.push(res.json);
api.emit(
comics.map((c) => ({
id: c.num.toString(),
title: `#${c.num}: ${c.title}`,
subtitle: c.alt,
url: `https://xkcd.com/${c.num}/`,
timestamp: `${c.year}-${c.month.padStart(2, "0")}-${c.day.padStart(2, "0")}`,
})),
);
}
}),
);
}
await fetchData();
return {
refresh: fetchData,
};
};