diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.cpp b/Userland/Libraries/LibWeb/HTML/Navigator.cpp
index bbfcd70df0a..df9ec06aeed 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigator.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Navigator.cpp
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
#include
namespace Web::HTML {
@@ -100,4 +101,16 @@ WebIDL::Long Navigator::max_touch_points()
return 0;
}
+// https://www.w3.org/TR/tracking-dnt/#dom-navigator-donottrack
+Optional Navigator::do_not_track() const
+{
+ // The value is null if no DNT header field would be sent (e.g., because a tracking preference is not
+ // enabled and no user-granted exception is applicable); otherwise, the value is a string beginning with
+ // "0" or "1", possibly followed by DNT-extension characters.
+ if (ResourceLoader::the().enable_do_not_track())
+ return "1"_fly_string;
+
+ return {};
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.h b/Userland/Libraries/LibWeb/HTML/Navigator.h
index d8a2eb03a26..3a30b407830 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigator.h
+++ b/Userland/Libraries/LibWeb/HTML/Navigator.h
@@ -50,6 +50,8 @@ public:
[[nodiscard]] JS::NonnullGCPtr clipboard();
[[nodiscard]] JS::NonnullGCPtr user_activation();
+ Optional do_not_track() const;
+
static WebIDL::Long max_touch_points();
virtual ~Navigator() override;
diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.idl b/Userland/Libraries/LibWeb/HTML/Navigator.idl
index b2d2f7faf15..46fd0cbe1fc 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigator.idl
+++ b/Userland/Libraries/LibWeb/HTML/Navigator.idl
@@ -21,6 +21,9 @@ interface Navigator {
// https://html.spec.whatwg.org/multipage/interaction.html#useractivation
[SameObject] readonly attribute UserActivation userActivation;
+
+ // https://www.w3.org/TR/tracking-dnt/#dom-navigator-donottrack
+ readonly attribute DOMString? doNotTrack;
};
// NOTE: As NavigatorContentUtils, NavigatorCookies, NavigatorPlugins, and NavigatorAutomationInformation