const axios = require('axios'); const cheerio = require('cheerio'); async function unrestrictedai(prompt, style = 'anime') { try { const styles = ['photorealistic', 'digital-art', 'impressionist', 'anime', 'fantasy', 'sci-fi', 'vintage']; if (!prompt) throw new Error('Prompt is required.'); if (!styles.includes(style)) throw new Error(`Available styles: ${styles.join(', ')}.`); const { data: html } = await axios.get('https://unrestrictedaiimagegenerator.com/', { headers: { origin: 'https://unrestrictedaiimagegenerator.com', referer: 'https://unrestrictedaiimagegenerator.com/', 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36' } }); const $ = cheerio.load(html); const nonce = $('input[name="_wpnonce"]').attr('value'); if (!nonce) throw new Error('Nonce not found.'); const { data } = await axios.post('https://unrestrictedaiimagegenerator.com/', new URLSearchParams({ generate_image: true, image_description: prompt, image_style: style, _wpnonce: nonce }).toString(), { headers: { origin: 'https://unrestrictedaiimagegenerator.com', referer: 'https://unrestrictedaiimagegenerator.com/', 'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36' } }); const $$ = cheerio.load(data); const img = $$('img#resultImage').attr('src'); if (!img) throw new Error('No result found.'); return img; } catch (error) { throw new Error(error.message); } }; // Usage: unrestrictedai('girl wearing glasses').then(console.log);