LOADING
/**
Dimohon Untuk tidak menghapus/mengganti credit
*/
const axios = require("axios");
const BASE_URL = "https://genmyart.com";
const AJAX_URL = `${BASE_URL}/wp-admin/admin-ajax.php`;
const STYLES = ["photorealistic", "digital-art", "impressionist", "anime", "fantasy", "sci-fi", "vintage", "watercolor", "ghibli", "cyberpunk", "surrealist", "minimalist", "baroque"];
const RESOLUTIONS = ["512x512", "768x768", "1024x1024", "1280x720", "1920x1080", "2560x1440", "3840x2160"];
const ASPECT_RATIOS = ["square", "portrait", "landscape"];
async function getNonce() {
const res = await axios.get(BASE_URL, {
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
}
});
const match = res.data.match(/_ajax_nonce:\s*'([a-f0-9]+)'/);
if (!match) throw new Error("Nonce tidak ditemukan, struktur halaman mungkin berubah");
return match[1];
}
async function generateImage({ prompt, style = "photorealistic", resolution = "1024x1024", aspectRatio = "square", numImages = 1 }) {
if (!prompt || !prompt.trim()) throw new Error("Prompt tidak boleh kosong");
if (!STYLES.includes(style)) throw new Error(`Style tidak valid. Pilihan: ${STYLES.join(", ")}`);
if (!RESOLUTIONS.includes(resolution)) throw new Error(`Resolution tidak valid. Pilihan: ${RESOLUTIONS.join(", ")}`);
if (!ASPECT_RATIOS.includes(aspectRatio)) throw new Error(`Aspect ratio tidak valid. Pilihan: ${ASPECT_RATIOS.join(", ")}`);
if (numImages < 1 || numImages > 6) throw new Error("Jumlah gambar harus antara 1-6");
const nonce = await getNonce();
const params = new URLSearchParams();
params.append("action", "generate_ai_image");
params.append("ai_prompt", prompt);
params.append("ai_style", style);
params.append("ai_resolution", resolution);
params.append("ai_aspect_ratio", aspectRatio);
params.append("ai_num_images", String(numImages));
params.append("_ajax_nonce", nonce);
const res = await axios.post(AJAX_URL, params.toString(), {
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Accept": "*/*",
"X-Requested-With": "XMLHttpRequest",
"Referer": BASE_URL,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
}
});
if (!res.data.success) throw new Error(res.data.message || "Generate gagal");
return {
success: true,
creator: "ShanMolvyr",
prompt: res.data.prompt,
style: res.data.style,
resolution,
aspectRatio,
images: res.data.images,
creditsDeducted: res.data.credits_deducted,
remainingCredits: res.data.remaining_credits
};
}
async function main() {
const args = process.argv.slice(2);
const prompt = args[0];
const style = args[1];
const resolution = args[2];
const aspectRatio = args[3];
const numImages = args[4] ? parseInt(args[4], 10) : undefined;
if (!prompt) {
console.log(JSON.stringify({
success: false,
message: "Penggunaan: node genmyart.js \"<prompt>\" [style] [resolution] [aspectRatio] [numImages]",
availableStyles: STYLES,
availableResolutions: RESOLUTIONS,
availableAspectRatios: ASPECT_RATIOS
}, null, 2));
process.exit(1);
}
try {
const result = await generateImage({ prompt, style, resolution, aspectRatio, numImages });
console.log(JSON.stringify(result, null, 2));
} catch (err) {
console.log(JSON.stringify({ success: false, message: err.message }, null, 2));
process.exit(1);
}
}
if (require.main === module) main();
module.exports = { generateImage, STYLES, RESOLUTIONS, ASPECT_RATIOS };bashnpm install axios
bashnode genmyart.js \"<prompt>\" [style] [resolution] [aspectRatio] [numImages]
#example
bashnode genmyart.js "dragon on mountain at sunset" anime 1920x1080 landscape 2