Are fart jokes universal?

Not sf, but Salman Rushdie told a version of it in The Satanic Verses.

And I remember an old English variant in which a bowing nobleman farted in front of Queen Elizabeth I, and at once fled the palace in mortification. Many years later, after living as a virtual recluse, he thought, “Surely everyone will have forgotten by now,” and returned to court.

The Queen greeted him by saying, “My lord, welcome back! I had quite forgot the fart.”

That is indeed from Riverworld, the first novel of the eponymous serial. Richard Burton relates it around a campfire one night.

And, of course, Burton would have known of it from The Book of a Thousand Nights and a Night (as mbh relates). And Farmer probably knew of it and of Burton because of that book.
I find it intriguing that of all the stories in the 1001 nights, this is one of the very few to make it into the Penguin collection Tales from the Arabian Nights (and into its audio edition, as well). *

Nitpick – the first novel is only “eponymous” because it names the world “Riverworld”. The title of the first novel is To Your Scattered Bodies Go. Farmer did write a short story entitled “Riverworld” (It’s in the collection Riverworld and other stories), but it has nothing to do with the Burton/Twain main story thread.

*and the editors of the Penguin edition hate the Burton translation, by the way