Moved to the scripting forum...
You should ask scripting questions here in the future, please.
...without switching ON...
Do you mean without switching its property "visible" ON?
No way, I am afraid. If conditional text visibility is switched OFF - whole text disappears as an object, so story.length is changed and findText() returns null as well.
In attempting to provide a helpful response, I have myself run into an issue. I constructed a very simple example with the following text (Using InDesign CC 22.214.171.124):
Hello Bonjour This is a message.
Error: undefined is not an object
But if I try:
Apparently, app.selection.parentStory.textStyleRanges is the hidden English text.
So, this is a puzzle.
And before I could post this, I realized what was happening: the selection includes the hidden English text. Wow, that's something to watch out for when working with conditions. If the selection you make in text is hard up against a hidden condition, that hidden text is incorporated into the selection yet it doesn't actually exist. But this doesn't affect non-condition related properties. For example pointSize returns the correct value.
app.selection.insertionPoints.appliedConditions.name fails. As does app.selection.characters.appliedConditions.name. But app.selection.characters.appliedConditions.name correctly returns French.
And now the real reason becomes clear: the first character is some kind of marker that invisibly indicates that there is hidden text at that location. But it appears to be a marker for which you cannot search.
Hmm. I'm not sure whether I'm helping here!
My original thought was that to address the question a script could note the state of the condition of interest, turn it on, analyze the affected text and then if necessary turn it off again.
@ Dave, could you check in your example:
a) when both condition are visible
b) when one is hidden
it looks differ on my side, so... no object... no puzzle...
Everything works just fine when all is visible. The issue is that when text is invisible it is replaced by a marker that counts as a character as far as JS is concerned and which is selected if in the UI you click after the space and then do Command-Shift-Up-Arrow to select to the start of the paragraph (which I now realize is what I did).
Thanks for the details, now I able to get the condition details for the selected contents, but my requirement is to get the text applied with the conditions which will be available in hidden mode.