Skip to content

Commit a4e6cc2

Browse files
committed
Add trustedTypes
1 parent 5a8febb commit a4e6cc2

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

bot.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44
const MESSAGE_DELAY = 1000;
55
const observer = new MutationObserver(onNewMessage);
6+
let HTMLPolicy;
7+
8+
if (window.trustedTypes) {
9+
HTMLPolicy = trustedTypes.createPolicy("HTMLPolicy", {
10+
createHTML: (string) => string,
11+
});
12+
}
613

714
var currentSender = null;
815

@@ -26,7 +33,12 @@ function simulateClick(element) {
2633
}
2734

2835
function sendMessage(messagebody) {
29-
window.bot_textbox.innerHTML = messagebody;
36+
if (window.trustedTypes) {
37+
window.bot_textbox.innerHTML = HTMLPolicy.createHTML(messagebody);
38+
} else {
39+
window.bot_textbox.innerHTML = messagebody;
40+
}
41+
3042
setTimeout(function() {
3143
window.bot_textbox.focus();
3244
simulateClick(window.bot_sendbutton);

0 commit comments

Comments
 (0)