mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 20:35:51 +00:00
Add files via upload
This commit is contained in:
36
core/tavern-helper/Wrapperiframe.js
Normal file
36
core/tavern-helper/Wrapperiframe.js
Normal file
@@ -0,0 +1,36 @@
|
||||
(function(){
|
||||
if (window.frameElement) {
|
||||
window.frameElement.style.height = 'auto';
|
||||
}
|
||||
function getGlobal() {
|
||||
if (typeof self !== 'undefined') { return self; }
|
||||
if (typeof window !== 'undefined') { return window; }
|
||||
if (typeof global !== 'undefined') { return global; }
|
||||
throw new Error('unable to locate global object');
|
||||
}
|
||||
const globalScope = getGlobal();
|
||||
if (globalScope.generate_send_button_onclick) {
|
||||
globalScope.generate_send_button_onclick_old = globalScope.generate_send_button_onclick;
|
||||
globalScope.generate_send_button_onclick = function(event) {
|
||||
try {
|
||||
const textarea = document.getElementById('send_textarea');
|
||||
if (textarea && textarea.value) {
|
||||
const customEvent = new CustomEvent('xb-send-message', {
|
||||
detail: {
|
||||
message: textarea.value,
|
||||
event: event
|
||||
},
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
if (!window.dispatchEvent(customEvent)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error in xb-send-message event dispatch:', e);
|
||||
}
|
||||
globalScope.generate_send_button_onclick_old(event);
|
||||
};
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user