scraperjavascript10122
Code-V Web2APK Android Compiler
Scraper & API wrapper untuk meng-compile website menjadi file APK Android via Code-V compiler engine (sdkforge). Mendukung polling build status real-time.
Vamz Spectre6 Okt 2026152 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/codev-web2apk-compiler" -o codev-web2apk-compiler.js
# 2. Jalankan script
node codev-web2apk-compiler.js
Dependencies npm yang Dibutuhkan:
npm install Node 18+ (Native fetch)Panduan Penggunaan:
Jalankan dengan Node.js (v18+). Tidak membutuhkan dependensi eksternal tambahan karena menggunakan native fetch.
codev-web2apk-compiler.js(152 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
/**
* Code-V Web2APK Compiler Scraper
* Author: Vamz Spectre (VamxAPI)
*
* Target: https://code-v-compiler-sr.vercel.app
* Backend: Internal Next.js Vercel API (/api/build, /api/build/:id, /cdn/:file)
* Engine: sdkforge WebView APK Packager
*/
const BASE_URL = 'https://code-v-compiler-sr.vercel.app';
/**
* Request compile Web to APK
* @param {Object} config
* @param {string} config.url - URL website target (e.g. 'https://vamxapi.my.id')
* @param {string} [config.appName='MyWebApp'] - Nama aplikasi Android
* @param {string} [config.packageName='com.mywebapp.app'] - Package ID Android
* @param {string} [config.versionName='1.0.0'] - Version display
* @param {number} [config.versionCode=1] - Version code int
* @param {Object} [config.options] - Opsi kustomisasi tambahan
* @param {Function} [onProgress] - Callback progress listener (status, percent)
* @returns {Promise<Object>} Result data build info & download url
*/
async function buildWeb2Apk(config, onProgress = null) {
if (!config?.url) {
throw new Error('Parameter config.url wajib diisi!');
}
const payload = {
url: config.url,
appName: config.appName || 'MyWebApp',
packageName: config.packageName || 'com.mywebapp.app',
versionName: config.versionName || '1.0.0',
versionCode: Number(config.versionCode) || 1,
options: {
splash: config.options?.splash ?? true,
splashType: config.options?.splashType || 'default',
splashText: config.options?.splashText || config.appName || 'Loading...',
splashBg: config.options?.splashBg || '#0B0D10',
splashFg: config.options?.splashFg || '#3B82F6',
splashMs: Number(config.options?.splashMs) || 2000,
orientation: config.options?.orientation || 'auto',
js: config.options?.js ?? true,
zoom: config.options?.zoom ?? false,
permissions: Array.isArray(config.options?.permissions)
? config.options.permissions
: ['INTERNET', 'WAKE_LOCK']
}
};
// 1. Submit Build Request
const createRes = await fetch(`${BASE_URL}/api/build`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
},
body: JSON.stringify(payload)
});
if (!createRes.ok) {
const errText = await createRes.text();
throw new Error(`Gagal mengirim build request: ${createRes.status} ${errText}`);
}
const createData = await createRes.json();
const buildId = createData.build_id;
if (!buildId) {
throw new Error(`Respon server tidak memiliki build_id: ${JSON.stringify(createData)}`);
}
if (onProgress) onProgress({ status: 'queued', progress: 0, buildId });
// 2. Poll Build Status
const maxAttempts = 60; // Max ~120 detik
let attempt = 0;
while (attempt < maxAttempts) {
await new Promise(r => setTimeout(r, 2000));
attempt++;
const pollRes = await fetch(`${BASE_URL}/api/build/${buildId}`, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
}
});
if (!pollRes.ok) continue;
const pollData = await pollRes.json();
const status = pollData.status;
const progress = pollData.progress || 0;
if (onProgress) {
onProgress({ status, progress, log: pollData.log || [] });
}
if (status === 'ready' || status === 'completed') {
const downloadPath = pollData.download_url || `/cdn/${buildId}.apk`;
const downloadUrl = downloadPath.startsWith('http')
? downloadPath
: `${BASE_URL}${downloadPath}`;
return {
status: true,
buildId,
appName: payload.appName,
packageName: payload.packageName,
targetUrl: payload.url,
fileSize: pollData.file_size || null,
downloadUrl,
raw: pollData
};
}
if (status === 'failed' || status === 'error') {
throw new Error(`Build gagal: ${pollData.error || 'Unknown error'}`);
}
}
throw new Error('Build timeout: Proses compile memakan waktu lebih dari 2 menit.');
}
if (typeof module !== "undefined" && module.exports) {
module.exports = {
buildWeb2Apk,
BASE_URL
};
}
// Contoh eksekusi langsung jika dijalankan via node:
if (require.main === module) {
(async () => {
try {
console.log('š Memulai Web2APK Compile...');
const result = await buildWeb2Apk(
{
url: 'https://vamxapi.my.id',
appName: 'Vamx Demo',
packageName: 'com.vamx.demo'
},
(p) => console.log(`ā³ [${p.status}] Progress: ${p.progress || 0}%`)
);
console.log('\nā
Build Sukses!');
console.log(JSON.stringify(result, null, 2));
} catch (err) {
console.error('\nā Terjadi error:', err.message);
}
})();
}