Setting user preferences via JavaScript Console

While upgrading a huge Alfresco system from 3.4 to 4.0 I was asked if it is possible to collapse all sections (excepting the actions) on the document-details page.

The state of these twisters is saved for each user in his preferences (preference: org.alfresco.share.twisters.collapsed), so I wrote a little script using the JavaScript Console: