Bookmarklet: Display Optionset values

Unless you have generated strongly typed classes, looking up Optionset values for the selected value or any other value, is one of the most annoying things to do as a developer. You can use the bookmarklet below to display Optionset values, along with the Optionset text for all the Optionsets on a form. You can drag the minified source to your bookmark bar, for creating the bookmarklet.

This is how a sample contact form looks after executing the bookmarklet.

In my scenario I never have any option sets that have a bracket in the text. I put that line in so that even if you run the bookmarklet multiple times it would still produce the same text. It is a choice between a character that looks nice and removing the capability to run the bookmarklet multiple times and producing the same result. What solution do you suggest?

One other reason I did it this way, is not to delete and re-add the options when I see a “(” in the options. This signals to me that it has already been processed and I don’t need to append the text and values again. It probably doesn’t make a huge difference in performance if I do it all again I guess.