bielik-czat / public /script.js
jglowa's picture
Update public/script.js
c6f596c verified
raw
history blame contribute delete
721 Bytes
(function () {
const params = new URLSearchParams(location.search);
if (params.has('q')) {
new MutationObserver((mut, obs) => {
for (const m of mut) {
for (const node of m.addedNodes) {
if (node instanceof HTMLElement) {
const input = node.querySelector('#chat-input');
if (input) {
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value').set.call(input, params.get('q'));
input.dispatchEvent(new Event('input', {bubbles: true}));
obs.disconnect();
return;
}
}
}
}
}).observe(document.getElementById('root'), {childList: true, subtree: true});
}
})();