@plugin:InjectButton ###BLOCKDEF #::ID GENERATED_ID_Z59E16L6K #::block Button in {{containerSelector}} integrieren: {{messageText}} Anordnung: {{position:dropdown="start","end"}} Url bei Klick: {{actions:statement}} #::code await RAGAI.PARENT.exec(` (function() { // 1. Die globale Funktion im Parent definieren (falls noch nicht geschehen) if (!window.handlePluginButtonClick) { window.handlePluginButtonClick = async function() { var x = \`{{actions}}\`; var y = x.split("window.").join(""); var y2 = y.split("await ").join(""); RAGBOT.send(y2); }; } const targetSelector = {{containerSelector}} || "#target-container"; const pos = {{position}} || "start"; const parent = document.querySelector(targetSelector); const uniqueId = 'btn-inject-' + targetSelector.replace(/[^a-z0-9]/gi, '-'); if (parent && !document.getElementById(uniqueId)) { const btn = document.createElement('button'); btn.id = uniqueId; btn.textContent = {{messageText}}; btn.style.cssText = \` display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; margin: 10px 0; background-color: #007bff; color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.2s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-family: sans-serif; \`; btn.onmouseover = () => btn.style.backgroundColor = '#0056b3'; btn.onmouseout = () => btn.style.backgroundColor = '#007bff'; // 2. Der Button ruft nur noch die injizierte Funktion auf btn.onclick = () => { window.handlePluginButtonClick(); }; if (pos === 'start') { parent.prepend(btn); } else { parent.append(btn); } } })(); `); #::nestings -containerSelector:TEXT|#target-container -messageText:TEXT|Text auf dem Button