Create unrestricted-ai-image-generator.js
Browse files
unrestricted-ai-image-generator.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const axios = require('axios');
|
| 2 |
+
|
| 3 |
+
const cheerio = require('cheerio');
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
async function unrestrictedai(prompt, style = 'anime') {
|
| 8 |
+
|
| 9 |
+
try {
|
| 10 |
+
|
| 11 |
+
const styles = ['photorealistic', 'digital-art', 'impressionist', 'anime', 'fantasy', 'sci-fi', 'vintage'];
|
| 12 |
+
|
| 13 |
+
if (!prompt) throw new Error('Prompt is required.');
|
| 14 |
+
|
| 15 |
+
if (!styles.includes(style)) throw new Error(`Available styles: ${styles.join(', ')}.`);
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
const { data: html } = await axios.get('https://unrestrictedaiimagegenerator.com/', {
|
| 20 |
+
|
| 21 |
+
headers: {
|
| 22 |
+
|
| 23 |
+
origin: 'https://unrestrictedaiimagegenerator.com',
|
| 24 |
+
|
| 25 |
+
referer: 'https://unrestrictedaiimagegenerator.com/',
|
| 26 |
+
|
| 27 |
+
'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'
|
| 28 |
+
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
const $ = cheerio.load(html);
|
| 36 |
+
|
| 37 |
+
const nonce = $('input[name="_wpnonce"]').attr('value');
|
| 38 |
+
|
| 39 |
+
if (!nonce) throw new Error('Nonce not found.');
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
const { data } = await axios.post('https://unrestrictedaiimagegenerator.com/', new URLSearchParams({
|
| 44 |
+
|
| 45 |
+
generate_image: true,
|
| 46 |
+
|
| 47 |
+
image_description: prompt,
|
| 48 |
+
|
| 49 |
+
image_style: style,
|
| 50 |
+
|
| 51 |
+
_wpnonce: nonce
|
| 52 |
+
|
| 53 |
+
}).toString(), {
|
| 54 |
+
|
| 55 |
+
headers: {
|
| 56 |
+
|
| 57 |
+
origin: 'https://unrestrictedaiimagegenerator.com',
|
| 58 |
+
|
| 59 |
+
referer: 'https://unrestrictedaiimagegenerator.com/',
|
| 60 |
+
|
| 61 |
+
'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'
|
| 62 |
+
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
const $$ = cheerio.load(data);
|
| 70 |
+
|
| 71 |
+
const img = $$('img#resultImage').attr('src');
|
| 72 |
+
|
| 73 |
+
if (!img) throw new Error('No result found.');
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
return img;
|
| 78 |
+
|
| 79 |
+
} catch (error) {
|
| 80 |
+
|
| 81 |
+
throw new Error(error.message);
|
| 82 |
+
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
};
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
// Usage:
|
| 90 |
+
|
| 91 |
+
unrestrictedai('girl wearing glasses').then(console.log);
|