Files
ladybird/Libraries/LibWeb/Loader/UserAgent.h
Andreas Kling c505240401 LibWeb: Put "Chrome" in the default User-Agent string for compatibility
This is a sad compatibility hack, but it's unfortunately necessary for
many prominent websites to work in Ladybird.

With our previous UA string, we've observed things like:

- Getting HTTP 403 for every request
- Being served "your browser is not supported" pages
- Being served outdated/broken content
- Extreme network throttling
- Other annoyances that magically go away if we change the UA string

By playing along with the silly game and putting Chrome in the string,
most such problems disappear instantly and anyone trying to use Ladybird
has a much better time.

Note that Ladybird *is* still in the UA string as well, so you can
easily identify us if you want to.
2026-01-17 09:30:16 +01:00

75 lines
2.1 KiB
C++

/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Platform.h>
#include <AK/StringView.h>
#include <LibWeb/Loader/NavigatorCompatibilityMode.h>
namespace Web {
#if ARCH(X86_64)
# define CPU_STRING "x86_64"
#elif ARCH(AARCH64)
# define CPU_STRING "AArch64"
#elif ARCH(I386)
# define CPU_STRING "x86"
#elif ARCH(RISCV64)
# define CPU_STRING "RISC-V 64"
#elif ARCH(PPC64) || ARCH(PPC64LE)
# define CPU_STRING "PowerPC 64"
#elif ARCH(PPC)
# define CPU_STRING "PowerPC"
#else
# error Unknown architecture
#endif
#if defined(AK_OS_SERENITY)
# define OS_STRING "SerenityOS"
#elif defined(AK_OS_ANDROID)
# define OS_STRING "Android 10"
#elif defined(AK_OS_LINUX)
# define OS_STRING "Linux"
#elif defined(AK_OS_MACOS)
# define OS_STRING "macOS"
#elif defined(AK_OS_IOS)
# define OS_STRING "iOS"
#elif defined(AK_OS_WINDOWS)
# define OS_STRING "Windows"
#elif defined(AK_OS_FREEBSD)
# define OS_STRING "FreeBSD"
#elif defined(AK_OS_OPENBSD)
# define OS_STRING "OpenBSD"
#elif defined(AK_OS_NETBSD)
# define OS_STRING "NetBSD"
#elif defined(AK_OS_DRAGONFLY)
# define OS_STRING "DragonFly"
#elif defined(AK_OS_SOLARIS)
# define OS_STRING "SunOS"
#elif defined(AK_OS_HAIKU)
# define OS_STRING "Haiku"
#elif defined(AK_OS_GNU_HURD)
# define OS_STRING "GNU/Hurd"
#else
# error Unknown OS
#endif
#define BROWSER_NAME "Ladybird"
#define BROWSER_VERSION "1.0"
// NB: Some web servers treat us very badly unless we pretend to be one of the major browsers.
// This token is appended to the User-Agent string to improve compatibility.
// We will need to update this periodically to match a somewhat recent version.
#define SAD_COMPATIBILITY_HACK "Chrome/140.0.0.0"
constexpr auto default_user_agent = "Mozilla/5.0 (" OS_STRING "; " CPU_STRING ") " BROWSER_NAME "/" BROWSER_VERSION " " SAD_COMPATIBILITY_HACK ""sv;
constexpr auto default_platform = OS_STRING " " CPU_STRING ""sv;
constexpr auto default_navigator_compatibility_mode = NavigatorCompatibilityMode::Chrome;
}