<script>
// AUTO-INJECT REQUIRED UI CONTAINERS & STYLES FOR EMBEDDED MODES & FALLBACKS
(function() {
if (document.getElementById('hv8-injected-styles')) return;
const style = document.createElement('style');
style.id = 'hv8-injected-styles';
style.innerHTML = `
:root { --bg-color: #0b0f19; --card-bg: #111827; --border-color: #1f2937; --accent-gold: #f59e0b; --accent-blue: #3b82f6; --accent-green: #10b981; --accent-red: #ef4444; --text-main: #f3f4f6; --text-muted: #9ca3af; }
.hv8-card { background-color: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 15px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text-main); }
.hv8-checkbox-sandbox { background: #0f172a; border: 1px dashed #374151; padding: 15px; border-radius: 8px; display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.hv8-custom-checkbox { width: 22px; height: 22px; border: 2px solid var(--text-muted); border-radius: 4px; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.hv8-spinner { width: 14px; height: 14px; border: 2px solid transparent; border-top-color: #fff; border-radius: 50%; animation: hv8-spin 0.8s linear infinite; display: none; }
@keyframes hv8-spin { to { transform: rotate(360deg); } }
.hv8-btn { padding: 10px 14px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.9rem; }
.hv8-btn-gold { background-color: var(--accent-gold); color: #000; }
.hv8-btn-blue { background-color: var(--accent-blue); color: #fff; }
.hv8-btn-dark { background-color: #1f2937; color: var(--text-main); border: 1px solid #374151; }
.hv8-fallback-input { background: #0f172a; border: 1px solid var(--border-color); color: var(--text-main); padding: 10px; border-radius: 6px; font-size: 0.9rem; width: 100%; outline: none; }
`;
document.head.appendChild(style);
// Create Interstitial Overlay
if (!document.getElementById('hv8-interstitial-overlay')) {
const el = document.createElement('div');
el.id = 'hv8-interstitial-overlay';
el.style.cssText = 'position:fixed; top:0; left:0; width:100vw; height:100vh; background:rgba(11, 15, 25, 0.90); backdrop-filter:blur(6px); z-index:999999; display:none; align-items:center; justify-content:center;';
el.innerHTML = `
🔒 Humane Verification Interstitial Shield
Background locked. Complete cryptographic challenge to proceed.
Verify human presence
Cryptographic telemetry evaluation
`;
document.body.appendChild(el);
}
// Create Fallback Modal Overlay
if (!document.getElementById('hv8-fallback-overlay')) {
const el = document.createElement('div');
el.id = 'hv8-fallback-overlay';
el.style.cssText = 'position:fixed; top:0; left:0; width:100vw; height:100vh; background:rgba(11, 15, 25, 0.85); backdrop-filter:blur(6px); z-index:1000000; display:none; align-items:center; justify-content:center;';
el.innerHTML = `
`;
document.body.appendChild(el);
}
// Create Mode 2 Inline Widget Container
if (!document.getElementById('hv8-mode-widget-container')) {
const el = document.createElement('div');
el.id = 'hv8-mode-widget-container';
el.style.cssText = 'position:fixed; top:20px; left:50%; transform:translateX(-50%); z-index:99999; width:90%; max-width:400px; display:none;';
el.innerHTML = `
🛡️ Mode 2: Inline Box Widget
✕
Verify human presence (Inline)
Interactive form container active.
`;
document.body.appendChild(el);
}
// Create Mode 3 Floating Badge Container
if (!document.getElementById('hv8_widget')) {
const el = document.createElement('div');
el.id = 'hv8_widget';
el.setAttribute('data-hv8-sitekey', 'hv8_site_ent_09x');
el.setAttribute('data-hv8-purpose', 'testing');
el.setAttribute('data-hv8-risk', 'medium');
el.setAttribute('data-hv8-language', 'en');
el.style.cssText = 'position:fixed; bottom:16px; right:16px; padding:0.5rem 0.75rem; border-radius:999px; background:#111827; color:#f9fafb; font-size:0.8rem; box-shadow:0 6px 18px rgba(0,0,0,0.25); display:flex; align-items:center; gap:0.4rem; z-index:9999; border:1px solid #1f2937;';
el.innerHTML = `
Protected by Humane Verification v8
`;
document.body.appendChild(el);
}
// Create Hidden Tokens & Inputs
if (!document.getElementById('hv8_token')) {
const container = document.createElement('div');
container.style.display = 'none';
container.innerHTML = `
`;
document.body.appendChild(container);
}
})();
window.hv8Behavior = { clicks: 0, scrolls: 0, keys: 0, pastes: 0, startTime: Date.now() };
document.addEventListener("click", () => window.hv8Behavior.clicks++);
document.addEventListener("scroll", () => window.hv8Behavior.scrolls++);
document.addEventListener("keydown", () => window.hv8Behavior.keys++);
document.addEventListener("paste", () => window.hv8Behavior.pastes++);
// HV3 — BASELINE SCORING
function hv3Baseline() {
let score = 0.9;
const promo = document.getElementById("promo")?.value?.trim?.();
const honeypot = document.getElementById("honeypot")?.value?.trim?.();
if (promo) score -= 0.1;
if (honeypot) score -= 0.3;
return Math.max(0.1, Math.min(1.0, score));
}
// HV3 — FAST WORKER-BASED PROOF OF WORK
function hv3ProofOfWork(challenge, difficulty = 4) {
return new Promise((resolve) => {
const workerCode = `
self.onmessage = async function(e) {
const { challenge, difficulty } = e.data;
let nonce = 0;
const prefix = "0".repeat(difficulty);
const encoder = new TextEncoder();
while (true) {
const input = challenge + nonce;
const hashBuffer = await crypto.subtle.digest("SHA-256", encoder.encode(input));
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, "0")).join("");
if (hashHex.startsWith(prefix)) {
self.postMessage({ nonce, hash: hashHex });
break;
}
nonce++;
}
};
`;
const blob = new Blob([workerCode], { type: "application/javascript" });
const worker = new Worker(URL.createObjectURL(blob));
worker.onmessage = (e) => {
worker.terminate();
resolve(e.data);
};
worker.postMessage({ challenge, difficulty });
});
}
// HV3 — MAIN LOGIC
async function humaneV3Run(action, options = { powBoost: true }) {
const errors = [];
const baseline = hv3Baseline();
const modePowBoost = !!options.powBoost;
const challenge = "hv3-" + (action || "default") + "-" + Date.now() + "-" + Math.random().toString(36).slice(2);
let pow = null;
try { pow = await hv3ProofOfWork(challenge, 4); } catch (err) { errors.push("pow_failed"); }
let score = baseline;
if (modePowBoost) {
if (pow) score += 0.03;
else { score -= 0.1; errors.push("pow_missing"); }
}
if (typeof action === "string") {
const lower = action.toLowerCase();
if (lower.includes("bot") || lower.includes("test")) { score -= 0.2; errors.push("suspicious_action"); }
}
score = Math.max(0.1, Math.min(0.95, score));
const verified = score >= 0.5;
const token = "hv3-" + score.toFixed(2) + "-" + (pow?.nonce ?? "none");
const hv3Field = document.getElementById("hv3_token");
if (hv3Field) hv3Field.value = token;
return { score, verified, token, pow, errors };
}
// HV8 — CONTEXT
function hv8GetContext() {
const widget = document.getElementById("hv8_widget");
const scriptEl = document.currentScript || document.querySelector('script[data-sitekey]');
return {
sitekey: scriptEl?.getAttribute("data-sitekey") || widget?.getAttribute("data-hv8-sitekey") || "hv8_site_ent_09x",
purpose: scriptEl?.getAttribute("data-purpose") || widget?.getAttribute("data-hv8-purpose") || "testing",
risk: scriptEl?.getAttribute("data-risk") || widget?.getAttribute("data-hv8-risk") || "medium",
language: scriptEl?.getAttribute("data-lang") || widget?.getAttribute("data-hv8-language") || "en",
fallbackRoutine: scriptEl?.getAttribute("data-fallback") || "graceful",
secretkey: document.getElementById("hv8_secretkey")?.value || ""
};
}
// HV8 — ENVIRONMENT INTEGRITY
function hv8EnvironmentScore() {
let score = 0.5;
try {
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (tz) score += 0.05;
const lang = navigator.language || "";
if (lang.length >= 2) score += 0.05;
if (navigator.webdriver) score -= 0.2;
} catch (e) { score -= 0.1; }
return Math.max(0.1, Math.min(0.9, score));
}
// HV8 — ADAPTIVE POW v2
async function hv8AdaptivePow(challenge) {
const b = window.hv8Behavior;
let difficulty = 3;
if (b.clicks === 0 && b.scrolls === 0 && b.keys === 0) difficulty = 4;
if (b.pastes > 3) difficulty = 5;
if (b.keys > 20 || b.scrolls > 10) difficulty = 2;
return hv3ProofOfWork(challenge, difficulty);
}
// HV8 — HUMANE SCORING ENGINE
function hv8ScoreLayer(baseScore) {
const b = window.hv8Behavior;
let score = baseScore;
if (b.clicks > 0) score += 0.02;
if (b.scrolls > 0) score += 0.02;
if (b.keys > 0) score += 0.02;
if (b.pastes > 3) score -= 0.1;
const envScore = hv8EnvironmentScore();
score += (envScore - 0.5);
return Math.max(0.10, Math.min(0.90, score));
}
// HV8 — FALLBACK ROUTINE UI HANDLER
function executeHumaneFallbackRoutine(routineType, onComplete) {
const overlay = document.getElementById('hv8-fallback-overlay');
const modalContent = document.getElementById('fallback-modal-content');
if (overlay) overlay.style.display = 'flex';
if (!modalContent) return;
modalContent.innerHTML = `
🛡️ HV8 Fallback Routine Triggered
Executing security protocol: ${routineType}
Proceed with Session
`;
window.activeFallbackCallback = onComplete;
}
window.completeFallbackPass = function(scoreVal, statusStr) {
const overlay = document.getElementById('hv8-fallback-overlay');
if (overlay) overlay.style.display = 'none';
if (window.activeFallbackCallback) {
window.activeFallbackCallback({ score: scoreVal, verified: scoreVal >= 0.5, status: statusStr });
}
};
// HV8 — MAIN LOGIC WITH FULL FALLBACK ROUTINE ROUTING
window.humaneV8Run = async function(action, options = { powBoost: true }) {
const ctx = hv8GetContext();
const hv3Result = await humaneV3Run(action, options);
const challenge = "hv8-" + (action || "default") + "-" + Date.now();
let pow = null;
try { pow = await hv8AdaptivePow(challenge); } catch (e) {}
let score = hv3Result.score;
if (pow) score += 0.03; else score -= 0.05;
if (!ctx.sitekey) score -= 0.2;
if (!ctx.secretkey) score -= 0.2;
score = hv8ScoreLayer(score);
if (score < 0.5 && ctx.fallbackRoutine && ctx.fallbackRoutine !== 'hard-block') {
return new Promise((resolve) => {
executeHumaneFallbackRoutine(ctx.fallbackRoutine, (fallbackResult) => {
const finalScore = fallbackResult.score;
const finalToken = ["hv8", "site:" + ctx.sitekey, "score:" + finalScore.toFixed(2), "fallback:" + ctx.fallbackRoutine].join("|");
const field = document.getElementById("hv8_token");
if (field) field.value = finalToken;
resolve({ score: finalScore, verified: fallbackResult.verified, token: finalToken, hv3: hv3Result, pow, context: ctx, status: fallbackResult.status });
});
});
}
const verified = score >= 0.5;
const token = ["hv8", "site:" + ctx.sitekey, "score:" + score.toFixed(2), "nonce:" + (pow?.nonce ?? "none")].join("|");
const field = document.getElementById("hv8_token");
if (field) field.value = token;
return { score, verified, token, hv3: hv3Result, pow, context: ctx };
};
// AUTO-TRIGGER INITIALIZATION BASED ON EMBED MODE ATTRIBUTE
window.addEventListener('DOMContentLoaded', () => {
const scriptEl = document.querySelector('script[data-mode]');
const mode = scriptEl?.getAttribute('data-mode') || 'widget';
if (mode === 'interstitial') {
const overlay = document.getElementById('hv8-interstitial-overlay');
if (overlay) overlay.style.display = 'flex';
} else if (mode === 'widget') {
const widgetCont = document.getElementById('hv8-mode-widget-container');
if (widgetCont) widgetCont.style.display = 'block';
} else if (mode === 'floating') {
const badge = document.getElementById('hv8_widget');
if (badge) badge.style.display = 'flex';
}
});
</script>