If you're trying to chat in a very narrow window, you probably don't need the sidebar anyway. And toggling that script every time is inconvenient. Now you can install this style:
@media screen and (max-width:900px){ #sidebar {display:none} #main {width:unset} }
Change the desired max width at which the sidebar is still visible to what you need. For example, if you are using FULL HD resolution (1920x1080) and you only want this mode to kick in when you put 3 chat windows side by side (right-click on taskbar > Show windows side by side), then 1920/3=640px.