Former NASA engineer-turned-YouTube star Mark Rober has received plaudits online after designing a booby trap to bust delivery thieves.

As many as 30 percent of Americans say they’ve suffered from missing or stolen delivery orders, according to a survey by Xfinity Home.

They say revenge is a dish best served cold. But for Mark Rober, it’s much sweeter served smart, smelly and covered in glitter.

The former NASA engineer-turned-YouTube star has received plaudits online after designing a booby trap to avenge all those who’ve fallen victim to a new wave of neighborhood crime: doorstep delivery theft.

Rober spent six months combining GPS tracking, cameras, fart spray and glitter in an elaborate and amusing mechanism after discovering thieves had stolen an Amazon delivery from his doorstep.

In a video posted on his channel, the 38-year-old, who helped design the U.S. space agency’s Curiosity Rover, said his engineering experience left him well-placed to “take a stand” after dismissive police left him feeling “powerless.”

“If anyone was going to make a revenge ... package and over-engineer the crap out of it, it was going to be me,” said Rober, who spent nine years with NASA.

So-called “porch pirates” — thieves who steal packages off people’s doorsteps — have become an increasing issue as bad actors have sought to take advantage of growing demand for delivery services.

“I felt like something needs to be done to take a stand against dishonest punks like this,” said Rober in his video entitled “Package Thief vs. Glitter Bomb Trap.”

The video, which was sponsored by NordVPN, has so far received more than 4 million views since being posted on Dec. 17, 2018.

It shows how Rober connected four phones to a GPS-connected circuit board inside an Apple box. Once removed from a home by a would-be thief, the geo-tracking would alert Rober while also triggering the phones to begin recording and uploading footage to the cloud.

Meanwhile, when the box’s lid was lifted, it would set off a can of “fart spray” and a centrifugal motor attached to a cup of glitter, prompting comical responses from the thieves.

Rober, who has more than 4.3 million subscribers on YouTube, described the package prank as his “Magnum Opus,” Latin for great work, or masterpiece.

In keeping with the holiday season, he even drew inspiration from his “hero” and fellow prankster, “Home Alone’s” Kevin McCallister, including his name on the box’s fake delivery label.

“If the thief wasn’t in such a hurry they’d see that the package is actually coming from my childhood hero and the inspiration for this project,” joked Rober.

“So the moral of the story is, just don’t take other people’s stuff,” he said.

Disclosure: Comcast is the owner of NBCUniversal, parent company of CNBC and CNBC.com.