diff --git a/src/libpoketube/init/pages-api.js b/src/libpoketube/init/pages-api.js
index 629fe337..8cdb8730 100644
--- a/src/libpoketube/init/pages-api.js
+++ b/src/libpoketube/init/pages-api.js
@@ -100,9 +100,159 @@ if (!data.users) data.users = {}
fs.writeFileSync(statsFile, JSON.stringify(data, null, 2))
res.json({ ok: true })
})
-app.get("/api/stats", (req, res) => {
- if (!telemetryConfig.telemetry)
+
+ app.get("/api/stats", (req, res) => {
+ if (!telemetryConfig.telemetry) {
+ const view = (req.query.view || "").toString()
+ if (!view) {
+ return res.send(`
+
+
+
+ Poke – Stats
+
+
+
+
+
+ Poke stats
+ How Poke improves itself while keeping your browsing private.
+
+
+
+ This page shows information about Poke’s anonymous, local-only usage statistics feature
+ (/api/stats).
+
+
+ For full details on what is collected (and what is not), see the privacy policy section:
+ /policies/privacy#stats.
+
+
+
+
+
Developers:
+
+ • To get the aggregated stats as JSON, call:
+ GET /api/stats?view=json
+ • The response includes:
+ videos (top 10 most-watched), browsers, os, and totalUsers.
+
+
+
+
+`)
+ }
+
return res.json({ videos: {}, browsers: {}, os: {}, totalUsers: 0 })
+ }
+
+ const view = (req.query.view || "").toString()
+
+ // if no ?view= param, show info page instead of raw JSON
+ if (!view) {
+ return res.send(`
+
+
+
+ Poke – Stats
+
+
+
+
+
+ Poke stats
+ How Poke improves itself while keeping your browsing private.
+
+
+
+ This page shows information about Poke’s anonymous, local-only usage statistics feature
+ (/api/stats).
+
+
+ For full details on what is collected (and what is not), see the privacy policy section:
+ /policies/privacy#stats.
+
+
+
+
+
Developers:
+
+ • To get the aggregated stats as JSON, call:
+ GET /api/stats?view=json
+ • The response includes:
+ videos (top 10 most-watched), browsers, os, and totalUsers.
+
+
+
+
+`)
+ }
const raw = fs.readFileSync(statsFile, "utf8")
const data = JSON.parse(raw)
@@ -128,6 +278,7 @@ app.get("/api/stats", (req, res) => {
})
+
app.get("/avatars/:v", async function (req, res) {
var url = `https://yt3.ggpht.com/${req.params.v}`;