That would be a very tight connection. The domestic terminal is maybe 15-20 minutes by taxi as I recall, but it's been a few years since I did that.
Buying the visa only takes a minute. Then you have to stand in a long line for immigration which can take a long time depending on how many 747's arrived just before you. So I don't see any point in buying a visa in advance.