2021-03-04 19:00:00 +01:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2021-06-28 11:51:13 +02:00
|
|
|
<script>
|
|
|
|
var script = document.createElement('script');
|
2021-06-28 13:55:17 +02:00
|
|
|
// Don't do this at home kids! The "document.referrer" part is actually inserting a XSS security.
|
|
|
|
// We are OK in this precise case because the HTML page is hosted on the "maps" domain that contains only static files.
|
2021-06-28 11:51:13 +02:00
|
|
|
script.setAttribute('src', document.referrer + 'iframe_api.js');
|
|
|
|
document.head.appendChild(script);
|
|
|
|
</script>
|
2021-03-04 19:00:00 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<button id="sendchat">Send chat message</button>
|
|
|
|
<script>
|
|
|
|
document.getElementById('sendchat').onclick = () => {
|
2021-06-28 11:51:13 +02:00
|
|
|
WA.chat.sendChatMessage('Hello world!', 'Mr ROBOT');
|
2021-03-04 19:00:00 +01:00
|
|
|
}
|
|
|
|
</script>
|
2021-03-06 15:26:07 +01:00
|
|
|
<div id="chatSent"></div>
|
|
|
|
<script>
|
2021-06-28 11:51:13 +02:00
|
|
|
window.addEventListener('load', () => {
|
|
|
|
WA.chat.onChatMessage((message => {
|
|
|
|
const chatDiv = document.createElement('p');
|
|
|
|
chatDiv.innerText = message;
|
|
|
|
document.getElementById('chatSent').append(chatDiv);
|
|
|
|
}));
|
|
|
|
})
|
2021-05-12 14:30:12 +02:00
|
|
|
</script>
|
2021-03-04 19:00:00 +01:00
|
|
|
</body>
|
|
|
|
</html>
|