Fix compatibility with communication module skins that don't support window_type=self

This commit is contained in:
Kijin Sung 2023-08-20 16:59:13 +09:00
parent 42d09bde65
commit e6dd1b2bb6
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,22 @@
'use strict';
(function($) {
$(function() {
// Find forms that submit to the Communication module.
const regexp = /^procCommunication(SendMessage|AddFriend(Group?))$/;
const forms = $('form').filter(function() {
return String($(this).find('input[name=act]').val()).match(regexp);
});
// Add window_type=self to each form.
forms.each(function() {
if ($(this).find('input[name=window_type]').length) {
return;
}
const hiddenInput = $('<input type="hidden" name="window_type" value="self" />')
hiddenInput.insertAfter($(this).find('input[name=act]'));
});
});
})(jQuery);