In Revelation 17:17 the angel, whose origin and station are in heaven, tells John that God himself is behind this hatred and killing of the prostitute. Remember that the “seven heads” of the beast were “seven mountains” (Revelation 17:9), which indicates that people were helpless in the face of the beast and the woman riding it (Revelation 13:7). But though people could not dislodge the unholy alliance between the prostitute, the beast, and the kings, God at his time would tear that alliance apart to the extent that the one would consume the other. His heavenly plan shall prevail (Psalm 138:8; Proverbs 16:9). Here the subtext mentioned in relation to Revelation 17:12 comes clearly to the surface.
17 for God has put it into their hearts to carry out his purpose by being of one mind and handing over their royal power to the beast, until the words of God are fulfilled.