-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFont Downloader - Run this in DevTools Console.js
More file actions
39 lines (32 loc) · 1.53 KB
/
Font Downloader - Run this in DevTools Console.js
File metadata and controls
39 lines (32 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Font Downloader - Run this in DevTools Console
(async function downloadFonts() {
// Get the Google Fonts CSS URL from the page
const fontCssUrl = 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap';
console.log('📥 Fetching Google Fonts CSS...');
const response = await fetch(fontCssUrl);
const css = await response.text();
// Extract all font URLs
const fontUrls = [...css.matchAll(/url\((https:\/\/fonts\.gstatic\.com[^)]+)\)/g)]
.map(m => m[1]);
console.log(`Found ${fontUrls.length} font files`);
// Filter to just latin (most sites only need these)
// Comment out these lines if you need all character sets
const latinFonts = fontUrls.filter(url =>
css.split(url)[0].split('@font-face').pop().includes('latin') &&
!css.split(url)[0].split('@font-face').pop().includes('latin-ext')
);
console.log(`\n🔤 Font URLs to download (${fontUrls.length} total, showing all):\n`);
fontUrls.forEach((url, i) => console.log(`${i + 1}. ${url}`));
console.log('\n\n📋 WGET COMMANDS (copy and run in terminal):\n');
console.log('mkdir -p fonts && cd fonts');
fontUrls.forEach(url => {
const filename = url.split('/').pop();
console.log(`wget "${url}" -O "${filename}"`);
});
console.log('\n\n📋 OR USE CURL:\n');
console.log('mkdir -p fonts && cd fonts');
fontUrls.forEach(url => {
const filename = url.split('/').pop();
console.log(`curl -o "${filename}" "${url}"`);
});
})();