[html]<button onclick="window.parent.postMessage('testsendButtonClicked', '*');">
Отправить что-то там
</button>[/html]
В низ добавить:
Код:
<!-- Send something https://gremlinquisitor.mybb.ru/viewtopic.php?id=30#p152 -->
<script>
$(document).ready(function() {
// Слушаем сообщения от фрейма
window.addEventListener('message', function(event) {
if (event.data === 'testsendButtonClicked') {
console.log('Кнопка в фрейме была нажата!');
test_sendAnyMsg();
}
});
});
function test_sendAnyMsg() {
const messageContent = `Юзверь [url=` + window.location.origin + `/profile.php?id=${UserID}]${UserLogin}[/url] отправил что-то там.`;
setTimeout(function() {
let textarea = document.getElementById('main-reply');
let submitBtn = document.querySelector('input[name="submit"]');
if (!textarea || !submitBtn) {
console.error('❌ Элементы формы не найдены.');
alert('❌ Автопубликация: Элементы формы не найдены.');
return;
}
textarea.value = messageContent;
submitBtn.click();
}, 100);
}
</script>