I’ve heard characters described as foils of other characters since I was a kid, but I think I always figured that meant that one character could foil another character’s plans or something. It wasn’t until a few years ago that I learned the real etymology:
Jewelers often put shiny metal foil underneath a gem to make the stone shine brighter. A literary foil serves a similar purpose. This character highlights someone else's trait, usually by contrast.
(Note: The above link is to TV Tropes, which can be a gigantic time sink if you’re not careful.)
The other meaning of foil that I alluded to above, as in “She foiled their plans,” turns out to be from a Middle English word fullen, which, if I’m understanding the etymology in my dictionary right, referred to making cloth fuller. I’m not sure what the connection is between fulling cloth (I didn’t know until now that full was a verb) and thwarting someone.