One possibility is to use a lookup table. Suppose we have 8 values (#50, #51, #52, #53, #54, #55, #56, #57) at address #6400 (our lookup table). Then you can use this "macro" whenever you need to change the page:
; A = page number we want to set
ld ($ + 4),a ; modify the lookup address in the next opcode
ld a,(#6400) ; pick value
out (253),a ; set page
For Amstrad the lookup table would be different with flipped 1-3 and 4-6 entries but your code can still index pages using the same logical number taken from Sinclair.
As for detection, you could simply ask the user before loading. Alternatively you could set a page that you know is different (such as 1) and count how many loops the CPU does between two successive interrupts.
Also note that there's no contention in the "border area" so if you execute something before or after the paper is drawn, any page will do.