There isn't much difference in price with applying online in the UK and extending in Thailand so for peace of mind I would apply in the UK. If you apply this weekend you will have it by the middle of next week at the latest.
that makes sense if you can change your flight. I tried a couple of years ago to get a visa through the Embassy in Ankara but it turned out easier to get a visa exemption in Thailand and then do a border run. Now with borders harder to cross I thought it may be easier to get a visa in Turkey before I go later in the year but maybe not! Take care and enjoy your travels.