diff --git a/uncloseai.js b/uncloseai.js index 74ab27c..9994edb 100644 --- a/uncloseai.js +++ b/uncloseai.js @@ -1478,8 +1478,21 @@ function openHermesModal() { const pageTitle = document.title; const pageUrl = window.location.href; - // Create cache key based on page content hash - const contentHash = btoa(pageContent.substring(0, 1000)).replace(/[^a-zA-Z0-9]/g, '').substring(0, 32); + // Create cache key based on page content hash (handle Unicode safely) + const contentForHash = pageContent.substring(0, 1000); + let contentHash; + try { + contentHash = btoa(unescape(encodeURIComponent(contentForHash))).replace(/[^a-zA-Z0-9]/g, '').substring(0, 32); + } catch (e) { + // Fallback: use simple string hash if btoa fails + let hash = 0; + for (let i = 0; i < contentForHash.length; i++) { + const char = contentForHash.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; // Convert to 32bit integer + } + contentHash = Math.abs(hash).toString(36).substring(0, 32); + } const cacheKey = `hermes-intro-${contentHash}`; // Check if we have a cached introduction for this page content