Well, the paragraphs in the overset are not paragraphs of the text frame, so it makes sense that they are skipped in your script. To access all the paragraphs of the text frames + those that are in the overset part, you will need to access all paragraphs of the parent story (a story is the text entity that describes all the text within linked text frames and the overset text) of the text frame.
You can do so like this:
if(app.selection[0].constructor.name === "TextFrame") {
var myParagraphs = app.selection[0].parentStory.paragraphs;
for (var i = 0; i < myParagraphs.length; i++) {
myParagraphs[i].appliedParagraphStyle = app.activeDocument.paragraphStyles.item("Format XYZ");
}
}
Be aware though that this will handle all paragraphs in all text frames that are linked to your text frame in case there are any of those.
Also, since it looks like you need to apply the paragraph style on each paragraph of the entire story, you might as well apply the paragraph style to the entire story directly instead of looping over the paragraphs:
app.selection[0].parentStory.appliedParagraphStyle = app.activeDocument.paragraphStyles.item("Format XYZ");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…