A programmer has recreated the Marauder’s Map from the Harry Potter book series in digital form by releasing a Chrome extension that allows you track your friends.

Aran Khanna, a student from Cambridge, Massachusetts, put together the tool after realising that Facebook Messenger was broadcasting users’ location with each message sent.

By doing so he claims he could map the movement of his friends – and even strangers he was in conversation with – to within a few metres of where they were standing, much like the magical map he named the extension after.

"I decided to write this extension, because we are constantly being told how we are losing privacy with the increasing digitisation of our lives," he said, writing in a blog post on Medium.

"With this code you can see for yourself the potentially invasive usage of the information you share, and decide for yourself if this is something you should worry about."

Khanna added that the extension works in part because Facebook Messenger is set to automatically broadcast the user’s location with each message sent, though the feature can be turned off.

After he uploaded it to the Google Chrome store it received so much attention that the API [application programming interface] key he used to draw maps was revoked, rendering the app defunct.

However in a message online he said that the code to Marauder’s Map was still functional, and technically savvy users were said to be able to fix the extension by entering their own API key into the code.

Since the map’s release Facebook said they are fixing the issue, which means that even a manual fix will not work for long.

Commenting on his work, Khanna said: "The power of defaults on human behavior is well documented in psychology and suggests that few people will put in the effort to deviate from the default action of sharing.

"Furthermore, because there are no readily visible consequences to sharing your location, users are never incentivised to devote attention to what this default of sharing is actually revealing about them."

He also disclosed that he would be joining Facebook in June of this year on a team unrelated to his project.

Tim Erlin, director of security and product management at security vendor Tripwire, said: "We share more and more data every day, both publically and with third parties like Facebook.

"The idea that these disparate pieces of data can be combined into new and scary tools isn’t new, but people tend to become desensitised to the capabilities without novel reminders, like this Marauder’s Map."