If there's already text in the page and the user clicks "extract text", we show a confirmation dialog as per T281767. If and when the user then clicks "OK", we send a request to the OCR tool and proceed as usual.
I think we might look into sending the request immediately (i.e. before the user clicks "OK"), and ignoring the result if "Cancel" was clicked instead. This way the whole process should seem faster to the user, since we might get a response before "OK" is clicked.
One possible caveat is that if we already got the response before "OK" is clicked and we replace the text immediately, the user might not realize what happened, since the popup closing animation might hide that. So we might want to have a small delay, e.g. 100ms, after the popup is closed before replacing the text.