Skip to content

Commit b4483af

Browse files
committed
Search any github user's repos with user:x
1 parent 41e07e3 commit b4483af

File tree

2 files changed

+217
-113
lines changed

2 files changed

+217
-113
lines changed

cheatsheet.html

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}catch(e){}
2424
})();
2525
</script>
26-
<link rel="stylesheet" href="/styles.css" />
26+
<link rel="stylesheet" href="//styles.css" />
2727

2828
</head>
2929
<body class="list">
@@ -67,9 +67,13 @@ <h3>Filters</h3>
6767
</div>
6868

6969
<div class="side-section">
70-
<h3>All tags you can browse</h3>
71-
<p class="hint">Collected from repository topics (languages excluded).</p>
72-
<ul id="all-tags" class="tag-list" style="max-height: unset;"></ul>
70+
<h3>Account switching</h3>
71+
<ul>
72+
<li><code>user:alice</code> — fetch repositories from another GitHub user.</li>
73+
<li><code>user:alice user:bob</code> — merge multiple users in one search.</li>
74+
<li>Omit <code>user:</code> to stick with the default (<code>ExperiencesXP</code>).</li>
75+
</ul>
76+
<p class="hint">These tokens can be combined with any other filters or sorting.</p>
7377
</div>
7478

7579
<p class="hint">Tip: Paste the whole query into the Tags box on Browse. Sorting is only via <code>sort:x</code>.</p>
@@ -79,40 +83,5 @@ <h3>All tags you can browse</h3>
7983
<div class="container"><p>Made by <a href="https://github.com/ExperiencesXP" target="_blank" rel="noopener noreferrer">@ExperiencesXP</a> - <a href="index.html">Home</a></p></div>
8084
</footer>
8185

82-
<script>
83-
(async function(){
84-
const user = 'ExperiencesXP';
85-
const token = (function(){ try { return localStorage.getItem('gitbooru.token') || ''; } catch { return ''; } })();
86-
const baseHeaders = { 'Accept': 'application/vnd.github+json' };
87-
if (token) baseHeaders['Authorization'] = `Bearer ${token}`;
88-
const results = [];
89-
for (let page=1; page<=3; page++) {
90-
const url = `https://api.github.com/users/${encodeURIComponent(user)}/repos?per_page=100&page=${page}&sort=updated`;
91-
const res = await fetch(url, { headers: baseHeaders });
92-
if (!res.ok) break;
93-
const data = await res.json();
94-
if (!Array.isArray(data) || !data.length) break;
95-
results.push(...data);
96-
if (data.length < 100) break;
97-
}
98-
// fetch topics and aggregate (60 points of API unauthenticated request an hour, therefore we try to limit the amount used.)
99-
const map = new Map();
100-
const toProcess = results.slice(0, 40);
101-
for (const r of toProcess) {
102-
try {
103-
const res = await fetch(`https://api.github.com/repos/${r.full_name}/topics`, { headers: { ...baseHeaders, 'Accept': 'application/vnd.github+json, application/vnd.github.mercy-preview+json' } });
104-
if (!res.ok) continue;
105-
const x = await res.json();
106-
(x.names||[]).forEach(t => {
107-
const k = String(t).toLowerCase();
108-
map.set(k, (map.get(k) || 0) + 1);
109-
});
110-
} catch {}
111-
}
112-
const items = [...map.entries()].sort((a,b)=> b[1]-a[1] || a[0].localeCompare(b[0]));
113-
const ul = document.getElementById('all-tags');
114-
ul.innerHTML = items.map(([tag,count]) => `<li><a href="list.html?tags=${encodeURIComponent(tag)}"><span>#${tag}</span><span class=\"count\">${count}</span></a></li>`).join('');
115-
})();
116-
</script>
11786
</body>
11887
</html>

0 commit comments

Comments
 (0)