How does a mercury detector work?

I am new to chemistry and saw a "portable mercury vapor monitor." How do these machines work?

There are many ways to detect mercury, and you can find a more detailed analysis of these methods, along with examples of these detectors and their limitations, here.

Gold film sensors

Gold Film Sensors were the first reliable forms of mercury detectors due to gold’s affinity for elemental mercury [...] When a mercury rich air sample passes over a thin gold film, the mercury deposits on the gold and changes the electrical resistance of the foil. This change in resistance is directly proportional to the mass of mercury vapor taken from a known volume of air, which can be calculated in $\mathrm{mg/m^{3}}$.

Cold Vapor Atomic Absorption Spectroscopy (CVAAS)

In mercury CVAAS, a light source of known wavelength and intensity (~254 $\mathrm{nm}$, middle ultraviolet spectrum) is radiated through a sample of air where the light eventually encounters a detector. If mercury is present, electrons from within the mercury atoms will absorb some of this energy from the light source. The difference between the initial energy of the light source and the energy measured by the detector gives you an indirect measurement of how many mercury atoms were initially present.

Atomic Fluorescence Spectroscopy (CVAFS)

Cold Vapor Atomic Fluorescence Spectroscopy (CVAFS) is an improvement upon the traditional CVAAS. When a mercury atom absorbs the energy from the UV wavelength, an electron transitions from a stable ground state to an unstable ‘excited’ state. This excitation event describes atomic absorption as discussed in the [CVAAS] section. However, when the energy source is removed the excited electron returns to its ground state. In doing so, a photon of light is emitted during the loss of potential energy. This fluorescence of light is often unique for various chemical species. Mercury in particular absorbs light at 254 $\mathrm{nm}$ and fluoresces light at the same wavelength. Because the light absorbed and emitted are at the same wavelength, this form of fluorescence is referred to as resonance fluorescence. Other chemicals such as chlorides, sulfides and hydrocarbons absorb light at 254 $\mathrm{nm}$ but either do not fluoresce or fluoresce at a different wavelength.

Most commonly they work by pulling air through a UV absorption cell and simply measuring the absorption at 254 nm. Often there is a pre-concentration step involved. This usually involves a gold-plated region prior to the UV cell. At room temperature mercury adsorbs to the gold, then after some period of time the gold-plated region is flash heated to release all of the mercury at once.