Replying to elexis:
Duplicate code must be avoided. you can define the function in functions_global_object.js
It should be avoided, but not at the cost of refering to page-specific globals in gui/common/
.
The issue is related to #2640 which aims at unifying chat parsing, but this never really works out conceptually, since the three chat pages have different features, different variables, different presentation. If deduplicating / unifying the chat, it would probably be cleaner to introduce a prototype about ChatHandling that pleases features of all three pages without becoming odd, without refering to page-specific globals or names (but receiving those as arguments) (#5387).
(Also the patch has turned out to be useful in some situations, thanks again)