Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions app/components/BrowserCheck.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use client";

import { useEffect } from "react";

export default function BrowserCheck() {
useEffect(() => {
async function detectHeadless() {
try {
const isWebdriver = navigator.webdriver;
const hardwareConcurrency = navigator.hardwareConcurrency || 0;

if (isWebdriver || hardwareConcurrency < 2) {
document.title = "Access Denied";
document.body.innerHTML =
"<h1 style='text-align:center;margin-top:20vh;font-family:sans-serif;'>Access Denied</h1>";
window.stop();
}
} catch (err) {
console.error("Browser check error:", err);
}
}

detectHeadless();
}, []);

return null;
}
2 changes: 2 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import DevToolsDetector from "./components/DevToolsDetector";
import NextTopLoader from "nextjs-toploader";
import { headers } from "next/headers";
import NortonSafeweb from "./components/NortonSafeweb";
import BrowserCheck from "./components/BrowserCheck";

const geistSans = Geist({
variable: "--font-geist-sans",
Expand Down Expand Up @@ -120,6 +121,7 @@ export default function RootLayout({
{isProduction && (
<>
<DevToolsDetector />
<BrowserCheck />
</>
)}
</body>
Expand Down
Loading