Is it possible to display a script via workers for US, UK, Canada traffic only

This is my code, I want it to be on the footer.

<— div id=“amzn-assoc-ad-1f641ce9-7b37-454f-be89-7e1c80577ba6”><script async src=“//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=1f641ce9-7b37-454f-be89-7e1c80577ba6” —><–/script>

You can check the cf-ipcountry header on the request and then modify the body using a regex. If the pages are large you probably should stream the response to make the memory footprint lower.