For reason(s) best known to you, you might want to check if WordPress TinyMCE Editor is in visual (rich text) or text mode.

The variable is_tinymce_active returns true if TinyMCE is in visual mode and false otherwise.

[javascript]

var is_tinymce_active = (typeof tinyMCE != “undefined”) && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden();

[/javascript]

Alternatively, simply check if tinymce is undefined

[javascript]

var is_tinymce_active = typeof tinyMCE != “undefined”;

[/javascript]

Credit: http://stackoverflow.com/questions/1179136/way-to-check-whether-tinymce-is-active-in-wordpress