Générateur de Prompts Image - Labo des CIP
/* --- CSS INDESTRUCTIBLE --- */
#cip-widget-container {
all: initial; /* Reset total */
font-family: 'Inter', sans-serif;
display: block;
width: 100%;
max-width: 600px;
margin: 20px auto;
}
#cip-widget-container * { box-sizing: border-box; }
#cip-widget-wrapper {
background-color: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 12px;
overflow: hidden;
color: #0f172a;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
/* HEADER */
.cip-header {
display: flex; align-items: center; gap: 16px; padding: 20px;
background: #ffffff; border-bottom: 1px solid #e2e8f0;
}
.cip-logo {
width: 40px; height: 40px; background: #39ff14; color: #052e0e;
border-radius: 8px; display: flex; align-items: center; justify-content: center;
font-weight: 800; font-size: 20px; flex-shrink: 0;
}
.cip-header-text h1 {
margin: 0; font-size: 18px; line-height: 1.2; font-weight: 800; color: #0f172a; font-family: 'Inter', sans-serif;
}
.cip-header-text p {
margin: 4px 0 0 0; font-size: 13px; color: #64748b; font-family: 'Inter', sans-serif;
}
.cip-body { padding: 20px; }
/* SECTIONS */
.cip-section { margin-bottom: 20px; border-bottom: 1px dashed #e2e8f0; padding-bottom: 20px; }
.cip-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.cip-section-title {
display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.cip-section-title h2 {
margin: 0; font-size: 14px; font-weight: 700; text-transform: uppercase; color: #0f172a; font-family: 'Inter', sans-serif;
}
.cip-badge {
background: #f1f5f9; color: #475569; font-size: 11px; font-weight: 700;
padding: 2px 8px; border-radius: 12px; font-family: 'Inter', sans-serif;
}
/* GRIDS */
.cip-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .cip-grid-2 { grid-template-columns: 1fr; } }
.cip-field { margin-bottom: 12px; }
.cip-field label {
display: block; font-size: 12px; font-weight: 600; color: #64748b; margin-bottom: 4px; font-family: 'Inter', sans-serif;
}
/* INPUTS FORCĂS */
.cip-input-style {
width: 100%; padding: 10px;
border: 1px solid #cbd5e1; border-radius: 6px;
font-size: 14px; background-color: #ffffff; color: #0f172a;
font-family: 'Inter', sans-serif; height: 42px;
-webkit-appearance: none; -moz-appearance: none; appearance: none;
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input.cip-input-style { background-image: none; }
.cip-input-style:focus { outline: 2px solid #39ff14; border-color: #39ff14; }
/* TEXTAREA */
.cip-result-area {
width: 100%; min-height: 100px; padding: 12px;
background-color: #f8fafc; border: 1px solid #cbd5e1; border-radius: 8px;
font-family: monospace; font-size: 13px; color: #334155; resize: vertical; margin-bottom: 10px;
}
/* BOUTONS */
.cip-btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.cip-btn {
flex: 1; padding: 12px; border: none; border-radius: 6px;
font-size: 13px; font-weight: 700; cursor: pointer; text-align: center;
transition: filter 0.2s; font-family: 'Inter', sans-serif; display: flex; justify-content: center; align-items: center; gap: 6px;
}
.cip-btn:hover { filter: brightness(0.95); }
.cip-btn-primary { background: #39ff14; color: #052e0e; } /* Vert Labo */
.cip-btn-dark { background: #0f172a; color: #ffffff; } /* Noir */
.cip-btn-ghost { background: #ffffff; border: 1px solid #e2e8f0; color: #0f172a; }
/* Checkbox */
.cip-check-row {
display: flex; align-items: center; gap: 10px; padding: 10px;
background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; cursor: pointer;
}
.cip-check-row input { width: 16px; height: 16px; accent-color: #16a34a; }
.cip-check-text { font-size: 12px; color: #166534; font-weight: 500; }
#cip-status { font-size: 11px; text-align: center; margin-top: 5px; color: #94a3b8; }
/* --- LE SCRIPT CHASSEUR DE WORDPRESS (V3 - Anti-Doublon) --- */
(function() {
console.log("CIP Widget: Démarrage du script...");
// 1. La fonction qui fait le travail (générer le texte)
function buildPrompt() {
var getVal = function(id) {
var el = document.getElementById(id); return el ? el.value : '';
};
var style = getVal('cip-style');
var subject = getVal('cip-subject');
var expression = getVal('cip-expression');
var outfit = getVal('cip-outfit');
var envSelect = document.getElementById('cip-env').value;
var envCustom = document.getElementById('cip-env-custom').value;
var env = envCustom ? envCustom : envSelect;
var acc = getVal('cip-acc');
var light = getVal('cip-light');
var format = getVal('cip-format');
var framing = getVal('cip-framing');
var palette = getVal('cip-palette');
var touchEl = document.getElementById('cip-labo-touch');
var touch = touchEl ? touchEl.checked : false;
// Construction
var textParts = [];
// Style
if(style) textParts.push("**Style:** " + style);
// Sujet
var subjTxt = "**Sujet:** " + subject + ", expression " + expression + ", portant " + outfit;
textParts.push(subjTxt);
// Contexte
var ctxTxt = "**Contexte:** " + env;
if(acc) ctxTxt += ", avec " + acc;
if(light) ctxTxt += ". Ăclairage: " + light;
textParts.push(ctxTxt);
// Technique
var techTxt = "**Technique:** " + format + ", " + framing;
if(palette) techTxt += ", palette " + palette;
textParts.push(techTxt + ", Haute résolution 4k.");
// Bonus
if(touch) {
textParts.push("**Note:** Ajouter une touche distinctive de vert fluo (#39ff14) pour l'identité visuelle.");
}
// CONTRAINTE IMAGE-TO-IMAGE STRICTE
textParts.push("**Contrainte:** Lâimage doit montrer exactement la mĂȘme personne que sur la photo fournie : mĂȘmes yeux, mĂȘme structure du visage, mĂȘme texture de peau, mĂȘme style gĂ©nĂ©ral. Ne pas rĂ©interprĂ©ter lâidentitĂ©. Câest la mĂȘme personne, dans une autre scĂšne.");
var finalTxt = textParts.join("\n\n");
var output = document.getElementById('cip-output');
if (output) {
output.value = finalTxt;
output.style.borderColor = "#39ff14"; // Petit flash vert
setTimeout(function(){ output.style.borderColor = "#cbd5e1"; }, 300);
}
}
// Boucle de surveillance (Watchdog)
var attempts = 0;
var finderInterval = setInterval(function() {
var widget = document.getElementById('cip-widget-wrapper');
attempts++;
if (widget) {
// Widget trouvé !
clearInterval(finderInterval);
var status = document.getElementById('cip-status');
if(status) status.innerHTML = "PrĂȘt Ă l'emploi â
";
// Attacher les écouteurs (Le Mouchard)
var inputs = widget.querySelectorAll('select, input');
for (var i = 0; i < inputs.length; i++) {
// On met à jour l'objet input directement pour écraser d'éventuels anciens listeners
inputs[i].onchange = buildPrompt;
inputs[i].oninput = buildPrompt;
}
// Bouton COPIER - Utilisation de onclick pour écraser les anciens éventuels
var btnCopy = document.getElementById('cip-btn-copy');
if(btnCopy) {
btnCopy.onclick = function(e) {
e.preventDefault();
var txt = document.getElementById('cip-output');
txt.select();
document.execCommand('copy');
var oldText = this.innerText;
this.innerText = "CopiĂ© ! â
";
var that = this;
setTimeout(function(){ that.innerText = oldText; }, 2000);
};
}
// Bouton CHATGPT - Utilisation de onclick (Anti-doublon fenĂȘtre)
var btnChat = document.getElementById('cip-btn-chatgpt');
if(btnChat) {
btnChat.onclick = function(e) {
e.preventDefault();
var txt = document.getElementById('cip-output').value;
if(txt.length < 5) { alert("Générez un prompt d'abord !"); return; }
// Encodage propre pour l'URL
var url = "https://chatgpt.com/?q=" + encodeURIComponent("GénÚre une image avec ce prompt :\n" + txt);
window.open(url, "_blank");
};
}
// Bouton RESET
var btnReset = document.getElementById('cip-btn-reset');
if(btnReset) {
btnReset.onclick = function(e) {
e.preventDefault();
document.getElementById('cip-env-custom').value = "";
document.getElementById('cip-labo-touch').checked = false;
var sels = widget.querySelectorAll('select');
for(var k=0; k 20) clearInterval(finderInterval); // Stop aprÚs 10s si non trouvé
}
}, 500);
})();