downloaderjavascript84
Canva Design & Slides Downloader
Ekstraktor & pengunduh slide Canva dari URL publik (view/edit/watch). Otomatis mengekstrak judul, metadata, serta link download AWS S3 resolusi tinggi untuk setiap slide tanpa perlu autentikasi.
Vamz Spectre21 Okt 2026212 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/canva-downloader" -o canva-downloader.js
# 2. Jalankan script
node canva-downloader.js
canva-downloader.js(212 lines)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/**
* Canva Design & Slides Downloader
* Author: Vamz Spectre (VamxAPI)
*
* Features:
* - Auto URL normalizer (handles /view, /edit, /watch, and query params)
* - Extracts design metadata (title, total pages, dimensions)
* - Reverse-engineers direct AWS S3 pre-signed slide image download URLs
* - Extracts full-resolution preview and thumbnail images for every page
*
* Usage:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/canva-downloader" -o canva-downloader.js
* node canva-downloader.js "https://www.canva.com/design/DAGwU2DtUxk/UDIxzR2nbX8gglGx1V5RgQ/view"
*/
const https = require('https');
const http = require('http');
const { URL } = require('url');
class CanvaDownloader {
constructor(options = {}) {
this.timeout = options.timeout || 15000;
this.userAgent = options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36';
}
/**
* Normalize any Canva design URL into a canonical /view endpoint
*/
normalizeUrl(rawUrl) {
if (!rawUrl || typeof rawUrl !== 'string') {
throw new Error('URL Canva tidak valid.');
}
let clean = rawUrl.trim();
const urlObj = new URL(clean);
// Replace edit or watch action with view
urlObj.pathname = urlObj.pathname.replace(/\/(edit|watch)(\/.*)?$/, '/view');
if (!urlObj.pathname.endsWith('/view')) {
urlObj.pathname = urlObj.pathname.replace(/\/+$/, '') + '/view';
}
// Keep clean pathname
urlObj.search = '';
urlObj.hash = '';
return urlObj.toString();
}
/**
* Perform HTTP GET request following redirects
*/
fetchHtml(targetUrl, maxRedirects = 5) {
return new Promise((resolve, reject) => {
if (maxRedirects <= 0) {
return reject(new Error('Terlalu banyak redirect.'));
}
const client = targetUrl.startsWith('https') ? https : http;
const req = client.get(targetUrl, {
timeout: this.timeout,
headers: {
'User-Agent': this.userAgent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.9,id;q=0.8',
'Sec-Ch-Ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"Windows"',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none'
}
}, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
const redirectUrl = new URL(res.headers.location, targetUrl).toString();
return resolve(this.fetchHtml(redirectUrl, maxRedirects - 1));
}
if (res.statusCode !== 200) {
return reject(new Error(`Gagal mengambil halaman Canva (HTTP ${res.statusCode})`));
}
let body = '';
res.on('data', (chunk) => body += chunk);
res.on('end', () => resolve(body));
});
req.on('error', reject);
req.on('timeout', () => {
req.destroy();
reject(new Error('Request timeout saat mengakses Canva.'));
});
});
}
/**
* Extract slides and media from Canva design page
*/
async download(url) {
const canonicalUrl = this.normalizeUrl(url);
const html = await this.fetchHtml(canonicalUrl);
// Extract Title
let title = 'Canva Design';
const ogTitle = html.match(/<meta\s+property=["\x27]og:title["\x27]\s+content=["\x27]([^"\x27]+)["\x27]/i);
const docTitle = html.match(/<title>([^<]+)<\/title>/i);
if (ogTitle && ogTitle[1]) {
title = ogTitle[1].trim();
} else if (docTitle && docTitle[1]) {
title = docTitle[1].replace(/\s*[–-]\s*Canva\s*$/i, '').trim();
}
// Extract og:image preview if present
let coverPreview = null;
const ogImage = html.match(/<meta\s+property=["\x27]og:image["\x27]\s+content=["\x27]([^"\x27]+)["\x27]/i);
if (ogImage && ogImage[1]) {
coverPreview = ogImage[1];
}
// Parse slide image arrays from JSON blocks
const imageBlockRegex = /"images":\s*(\[[^\]]+\])/g;
const pagesMap = new Map();
let match;
while ((match = imageBlockRegex.exec(html)) !== null) {
try {
const items = JSON.parse(match[1]);
if (!Array.isArray(items)) continue;
for (const item of items) {
if (!item || !item.url) continue;
const pageIndex = Number(item.page) || 1;
// Extract pre-signed AWS S3 URL from fallback parameter
let directDownloadUrl = null;
try {
const parsedUri = new URL(item.url);
directDownloadUrl = parsedUri.searchParams.get('fallback');
} catch (_) {
directDownloadUrl = item.url;
}
if (!directDownloadUrl) directDownloadUrl = item.url;
const existing = pagesMap.get(pageIndex);
const currentResolution = (item.width || 0) * (item.height || 0);
const existingResolution = existing ? (existing.width || 0) * (existing.height || 0) : 0;
// Save the highest resolution variant available
if (!existing || currentResolution > existingResolution) {
pagesMap.set(pageIndex, {
page: pageIndex,
width: item.width || null,
height: item.height || null,
key: item.key || null,
download_url: directDownloadUrl
});
}
}
} catch (_) {}
}
const pages = Array.from(pagesMap.values()).sort((a, b) => a.page - b.page);
if (pages.length === 0) {
throw new Error('Tidak ditemukan halaman/slide yang dapat diunduh dari link Canva ini. Pastikan link bersifat publik (View Link).');
}
return {
status: true,
creator: 'Vamz Spectre',
data: {
title,
url: canonicalUrl,
total_pages: pages.length,
cover: coverPreview,
pages
}
};
}
}
// CLI Runner
if (require.main === module) {
const inputUrl = process.argv[2];
if (!inputUrl) {
console.log(JSON.stringify({
status: false,
message: 'Parameter URL Canva wajib disertakan.',
usage: 'node canva-downloader.js "https://www.canva.com/design/DAGwU2DtUxk/UDIxzR2nbX8gglGx1V5RgQ/view"'
}, null, 2));
process.exit(1);
}
const downloader = new CanvaDownloader();
downloader.download(inputUrl)
.then((result) => {
console.log(JSON.stringify(result, null, 2));
})
.catch((err) => {
console.log(JSON.stringify({
status: false,
error: err.message
}, null, 2));
process.exit(1);
});
}
module.exports = CanvaDownloader;