Download content.js from akmall/23jin: direct link, hf CLI and curl.
- Browser
- Download file 42.6 kB
-
https://huggingface.co/akmall/23jin/resolve/main/content.js
- Command line
-
hf download hf://akmall/23jin/content.js
-
curl -L -o content.js https://huggingface.co/akmall/23jin/resolve/main/content.js
42.6 kB
| // Run when the page is fully loaded | |
| window.addEventListener('load', function() { | |
| // Check if body exists | |
| if (document.body) { | |
| const zoiDiv = document.createElement("div"); | |
| zoiDiv.id = "zoi-character"; | |
| zoiDiv.style.cssText = "position: fixed !important; bottom: 10px !important; left: 10px !important; z-index: 2147483647 !important; pointer-events: auto !important; cursor: pointer !important; width: 100px !important; height: 100px !important; box-sizing: border-box !important; transform-origin: center center !important;"; | |
| zoiDiv.innerHTML = '<img src="' + chrome.runtime.getURL("zoi.png") + '" id="zoi-img" style="width: 100px !important; height: 100px !important; max-width: 100px !important; max-height: 100px !important; min-width: 100px !important; min-height: 100px !important; display: block !important; transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important; pointer-events: none !important; object-fit: contain !important; box-sizing: border-box !important;">'; | |
| document.body.appendChild(zoiDiv); | |
| // Create chat icon that appears on hover | |
| const chatIcon = document.createElement("div"); | |
| chatIcon.id = "zoi-chat-icon"; | |
| chatIcon.style.cssText = "position: fixed !important; bottom: 120px !important; left: 10px !important; z-index: 2147483648 !important; pointer-events: auto !important; cursor: pointer !important; width: 30px !important; height: 30px !important; background: #4CAF50 !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; font-size: 16px !important; opacity: 0 !important; transition: all 0.3s ease !important; box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;"; | |
| chatIcon.innerHTML = "🗯️"; | |
| document.body.appendChild(chatIcon); | |
| // Create chat input box (hidden by default) | |
| const chatInput = document.createElement("div"); | |
| chatInput.id = "zoi-chat-input"; | |
| chatInput.style.cssText = "position: fixed !important; bottom: 120px !important; left: 10px !important; z-index: 2147483649 !important; pointer-events: auto !important; width: 250px !important; background: white !important; border: 2px solid #4CAF50 !important; border-radius: 10px !important; padding: 10px !important; box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important; display: none !important; font-family: Arial, sans-serif !important;"; | |
| const chatInputField = document.createElement("input"); | |
| chatInputField.type = "text"; | |
| chatInputField.placeholder = "Type a message to Zoi..."; | |
| chatInputField.style.cssText = "width: 100% !important; padding: 8px !important; border: 1px solid #ddd !important; border-radius: 5px !important; font-size: 14px !important; outline: none !important; box-sizing: border-box !important;"; | |
| const chatCloseBtn = document.createElement("button"); | |
| chatCloseBtn.innerHTML = "✕"; | |
| chatCloseBtn.style.cssText = "position: absolute !important; top: -5px !important; right: -5px !important; background: #f44336 !important; color: white !important; border: none !important; border-radius: 50% !important; width: 20px !important; height: 20px !important; font-size: 12px !important; cursor: pointer !important; display: flex !important; align-items: center !important; justify-content: center !important;"; | |
| chatInput.appendChild(chatInputField); | |
| chatInput.appendChild(chatCloseBtn); | |
| document.body.appendChild(chatInput); | |
| // Add CSS for animations and styles | |
| const style = document.createElement('style'); | |
| style.textContent = ` | |
| #zoi-character { | |
| width: 100px !important; | |
| height: 100px !important; | |
| max-width: 100px !important; | |
| max-height: 100px !important; | |
| min-width: 100px !important; | |
| min-height: 100px !important; | |
| font-size: 16px !important; | |
| line-height: normal !important; | |
| box-sizing: border-box !important; | |
| } | |
| #zoi-character:hover + #zoi-chat-icon, | |
| #zoi-chat-icon:hover { | |
| opacity: 1 !important; | |
| } | |
| #zoi-img { | |
| width: 100px !important; | |
| height: 100px !important; | |
| max-width: 100px !important; | |
| max-height: 100px !important; | |
| min-width: 100px !important; | |
| min-height: 100px !important; | |
| object-fit: contain !important; | |
| display: block !important; | |
| box-sizing: border-box !important; | |
| border: none !important; | |
| outline: none !important; | |
| margin: 0 !important; | |
| padding: 0 !important; | |
| } | |
| #zoi-bubble { | |
| font-size: 14px !important; | |
| line-height: 1.4 !important; | |
| font-family: Arial, sans-serif !important; | |
| box-sizing: border-box !important; | |
| max-width: 200px !important; | |
| min-width: 120px !important; | |
| } | |
| @keyframes zoi-blink { | |
| 0%, 90%, 100% { filter: brightness(1); } | |
| 95% { filter: brightness(0.3); } | |
| } | |
| @keyframes zoi-wave { | |
| 0%, 100% { transform: rotate(0deg); } | |
| 25% { transform: rotate(-15deg); } | |
| 75% { transform: rotate(15deg); } | |
| } | |
| @keyframes zoi-bounce { | |
| 0%, 100% { transform: translateY(0px) scale(1); } | |
| 50% { transform: translateY(-25px) scale(1.1); } | |
| } | |
| @keyframes zoi-bend { | |
| 0%, 100% { transform: skewX(0deg) skewY(0deg) scale(1); } | |
| 25% { transform: skewX(-8deg) skewY(3deg) scale(0.95); } | |
| 50% { transform: skewX(0deg) skewY(-3deg) scale(1.05); } | |
| 75% { transform: skewX(8deg) skewY(3deg) scale(0.95); } | |
| } | |
| @keyframes zoi-stretch { | |
| 0%, 100% { transform: scaleY(1) scaleX(1); } | |
| 50% { transform: scaleY(1.4) scaleX(0.7); } | |
| } | |
| @keyframes zoi-wiggle { | |
| 0%, 100% { transform: translateX(0px) rotate(0deg); } | |
| 25% { transform: translateX(-5px) rotate(-3deg); } | |
| 50% { transform: translateX(5px) rotate(0deg); } | |
| 75% { transform: translateX(-3px) rotate(3deg); } | |
| } | |
| @keyframes zoi-spin { | |
| 0% { transform: rotate(0deg) scale(1); } | |
| 50% { transform: rotate(180deg) scale(1.1); } | |
| 100% { transform: rotate(360deg) scale(1); } | |
| } | |
| @keyframes zoi-pulse { | |
| 0%, 100% { transform: scale(1); filter: hue-rotate(0deg); } | |
| 50% { transform: scale(1.3); filter: hue-rotate(90deg); } | |
| } | |
| @keyframes zoi-float { | |
| 0%, 100% { transform: translateY(0px) scale(1); } | |
| 50% { transform: translateY(-15px) scale(1.05); } | |
| } | |
| /* Expression-based visual effects */ | |
| .zoi-happy { filter: hue-rotate(60deg) brightness(1.3) !important; } | |
| .zoi-worried { filter: hue-rotate(0deg) brightness(0.7) !important; } | |
| .zoi-excited { filter: hue-rotate(120deg) brightness(1.4) saturate(1.3) !important; } | |
| .zoi-sleepy { filter: hue-rotate(240deg) brightness(0.8) blur(1px) !important; } | |
| .zoi-angry { filter: hue-rotate(0deg) brightness(1.2) saturate(1.5) !important; } | |
| .zoi-confused { filter: hue-rotate(180deg) brightness(1.1) !important; } | |
| .zoi-surprised { filter: hue-rotate(45deg) brightness(1.4) !important; } | |
| .zoi-dizzy { filter: hue-rotate(270deg) brightness(0.8) blur(0.5px) !important; } | |
| `; | |
| document.head.appendChild(style); | |
| // Create a speech bubble | |
| const bubble = document.createElement("div"); | |
| bubble.id = "zoi-bubble"; | |
| bubble.style.cssText = "position: fixed !important; background: #ffffff; border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 0; display: none; box-shadow: 0 2px 4px rgba(0,0,0,0.1); z-index: 1000000; pointer-events: none; text-align: center; color: #000000;"; | |
| document.body.appendChild(bubble); | |
| // Silly and funny contextual messages with emotions and expressions | |
| const contextualMessages = { | |
| writing: [ | |
| { text: "Whoa, are you writing the next bestselling novel?! 📚", emotion: "surprised", animation: "bounce", colorFilter: "hue-rotate(60deg) brightness(1.2)" }, | |
| { text: "My fingers hurt just watching you type! ⌨️", emotion: "worried", animation: "shake", colorFilter: "hue-rotate(0deg) brightness(0.8)" }, | |
| { text: "Are you trying to break the keyboard? Slow down! 😅", emotion: "concerned", animation: "wiggle", colorFilter: "hue-rotate(30deg) brightness(0.9)" }, | |
| { text: "I think I saw smoke coming from your keyboard! 🔥", emotion: "shocked", animation: "spin", colorFilter: "hue-rotate(15deg) brightness(1.3)" }, | |
| { text: "Word count: 9000+... Are you okay?! 😵", emotion: "dizzy", animation: "bend", colorFilter: "hue-rotate(270deg) brightness(0.7)" }, | |
| { text: "Plot twist: You're secretly a writing robot! 🤖", emotion: "teasing", animation: "pulse", colorFilter: "hue-rotate(180deg) brightness(1.1)" } | |
| ], | |
| coding: [ | |
| { text: "I see more brackets than a math textbook! 🤓", emotion: "confused", animation: "bend", colorFilter: "hue-rotate(45deg) brightness(0.9)" }, | |
| { text: "Are you speaking robot language? Beep boop! 🤖", emotion: "playful", animation: "wiggle", colorFilter: "hue-rotate(180deg) brightness(1.2)" }, | |
| { text: "Error 404: Social life not found! 😂", emotion: "sassy", animation: "wave", colorFilter: "hue-rotate(320deg) brightness(1.1)" }, | |
| { text: "Is this how you talk to computers? So rude! 💻", emotion: "offended", animation: "shake", colorFilter: "hue-rotate(0deg) brightness(0.8)" }, | |
| { text: "I bet you dream in code! Sweet binary dreams! 01010", emotion: "dreamy", animation: "float", colorFilter: "hue-rotate(240deg) brightness(1.3)" }, | |
| { text: "Syntax error: You forgot to pet me! 🐾", emotion: "needy", animation: "bounce", colorFilter: "hue-rotate(300deg) brightness(1.2)" } | |
| ], | |
| shopping: [ | |
| { text: "Your wallet is crying! I can hear it! 💸", emotion: "worried", animation: "shake", colorFilter: "hue-rotate(0deg) brightness(0.7)" }, | |
| { text: "Add to cart, add to cart... when does it end?! 🛒", emotion: "dizzy", animation: "spin", colorFilter: "hue-rotate(270deg) brightness(0.8)" }, | |
| { text: "I'm not judging, but that's the 47th item... 👀", emotion: "judging", animation: "bend", colorFilter: "hue-rotate(30deg) brightness(0.9)" }, | |
| { text: "Someone's having a shopping attack! 🛍️", emotion: "excited", animation: "bounce", colorFilter: "hue-rotate(120deg) brightness(1.3)" }, | |
| { text: "Your bank account wants to have a word with you! 💳", emotion: "concerned", animation: "wiggle", colorFilter: "hue-rotate(15deg) brightness(0.8)" }, | |
| { text: "Amazon delivery guy knows your name by now! 📦", emotion: "teasing", animation: "wave", colorFilter: "hue-rotate(60deg) brightness(1.1)" } | |
| ], | |
| social: [ | |
| { text: "Slow down or you'll scroll into another dimension! 🌀", emotion: "dizzy", animation: "spin", colorFilter: "hue-rotate(270deg) brightness(0.8)" }, | |
| { text: "Your thumb must be getting a serious workout! 💪", emotion: "impressed", animation: "pulse", colorFilter: "hue-rotate(90deg) brightness(1.2)" }, | |
| { text: "I'm getting dizzy watching you scroll! 😵💫", emotion: "dizzy", animation: "bend", colorFilter: "hue-rotate(270deg) brightness(0.7)" }, | |
| { text: "Did you just like your ex's photo from 2019?! 😱", emotion: "shocked", animation: "bounce", colorFilter: "hue-rotate(0deg) brightness(1.4)" }, | |
| { text: "Social media Olympics champion right here! 🏆", emotion: "proud", animation: "wave", colorFilter: "hue-rotate(45deg) brightness(1.3)" }, | |
| { text: "Remember me? Your little blue buddy? 👋", emotion: "lonely", animation: "wiggle", colorFilter: "hue-rotate(240deg) brightness(0.9)" } | |
| ], | |
| video: [ | |
| { text: "Just one more episode... famous last words! 📺", emotion: "knowing", animation: "bend", colorFilter: "hue-rotate(30deg) brightness(1.1)" }, | |
| { text: "Your eyes are turning square! Blink please! 👁️", emotion: "worried", animation: "blink", colorFilter: "hue-rotate(0deg) brightness(0.8)" }, | |
| { text: "I can make popcorn sounds if you want! *pop pop* 🍿", emotion: "helpful", animation: "bounce", colorFilter: "hue-rotate(60deg) brightness(1.2)" }, | |
| { text: "Plot twist: I'm more entertaining than this show! 😏", emotion: "cocky", animation: "pulse", colorFilter: "hue-rotate(120deg) brightness(1.3)" }, | |
| { text: "Don't blame me when you realize it's 3 AM! ⏰", emotion: "warning", animation: "shake", colorFilter: "hue-rotate(15deg) brightness(0.8)" }, | |
| { text: "Are you crying or laughing? I can't tell! 😭😂", emotion: "confused", animation: "wiggle", colorFilter: "hue-rotate(180deg) brightness(1.1)" } | |
| ], | |
| search: [ | |
| { text: "Googling life's biggest mysteries, I see! 🔍", emotion: "curious", animation: "bend", colorFilter: "hue-rotate(90deg) brightness(1.1)" }, | |
| { text: "Did you find the meaning of life yet? 🤔", emotion: "philosophical", animation: "float", colorFilter: "hue-rotate(240deg) brightness(1.2)" }, | |
| { text: "Search result #847... maybe take a break? 😅", emotion: "concerned", animation: "wiggle", colorFilter: "hue-rotate(30deg) brightness(0.9)" }, | |
| { text: "I know everything! Just ask me instead! 🧠", emotion: "cocky", animation: "pulse", colorFilter: "hue-rotate(120deg) brightness(1.3)" }, | |
| { text: "Going down the rabbit hole, Alice? 🐰", emotion: "playful", animation: "spin", colorFilter: "hue-rotate(300deg) brightness(1.2)" }, | |
| { text: "Fun fact: I'm more fun than Wikipedia! 📖", emotion: "boastful", animation: "bounce", colorFilter: "hue-rotate(60deg) brightness(1.3)" } | |
| ], | |
| email: [ | |
| { text: "Inbox: 2,847 unread... Good luck with that! 📧", emotion: "overwhelmed", animation: "shake", colorFilter: "hue-rotate(0deg) brightness(0.7)" }, | |
| { text: "Reply all? Oh no, you didn't! 😱", emotion: "horrified", animation: "bounce", colorFilter: "hue-rotate(0deg) brightness(1.4)" }, | |
| { text: "Someone's popular! Or spammed... 📮", emotion: "sarcastic", animation: "bend", colorFilter: "hue-rotate(45deg) brightness(1.1)" }, | |
| { text: "I bet half of those are newsletters you never read! 💌", emotion: "knowing", animation: "wiggle", colorFilter: "hue-rotate(30deg) brightness(1.1)" }, | |
| { text: "Email stress level: MAXIMUM! Take a breath! 😤", emotion: "stressed", animation: "shake", colorFilter: "hue-rotate(15deg) brightness(0.8)" }, | |
| { text: "CC, BCC, ABC, 123... what's next?! 🔤", emotion: "confused", animation: "spin", colorFilter: "hue-rotate(180deg) brightness(1.1)" } | |
| ], | |
| scrolling: [ | |
| { text: "Slow down or you'll scroll into another dimension! 🌀", emotion: "dizzy", animation: "spin", colorFilter: "hue-rotate(270deg) brightness(0.8)" }, | |
| { text: "Olympic scrolling champion! 🏆", emotion: "impressed", animation: "bounce", colorFilter: "hue-rotate(45deg) brightness(1.3)" }, | |
| { text: "Your finger must be getting buff! 💪", emotion: "amazed", animation: "pulse", colorFilter: "hue-rotate(90deg) brightness(1.2)" }, | |
| { text: "I'm getting motion sickness! 🤢", emotion: "sick", animation: "bend", colorFilter: "hue-rotate(120deg) brightness(0.7)" }, | |
| { text: "Are we flying? It feels like we're flying! ✈️", emotion: "excited", animation: "float", colorFilter: "hue-rotate(180deg) brightness(1.3)" }, | |
| { text: "Scroll faster! I dare you! Actually, don't! 😵", emotion: "conflicted", animation: "wiggle", colorFilter: "hue-rotate(300deg) brightness(1.1)" } | |
| ], | |
| idle: [ | |
| { text: "Helloooo? Earth to human! 👽", emotion: "calling", animation: "wave", colorFilter: "hue-rotate(120deg) brightness(1.2)" }, | |
| { text: "Someone needs a cookie 🍪... Want me to order one?", emotion: "caring", animation: "pulse", colorFilter: "hue-rotate(30deg) brightness(1.1)" }, | |
| { text: "You look tired! When did you last sleep? 😴", emotion: "sleepy", animation: "blink", colorFilter: "hue-rotate(240deg) brightness(0.8)" }, | |
| { text: "I'm more interesting than staring at nothing! 👀", emotion: "attention-seeking", animation: "bounce", colorFilter: "hue-rotate(60deg) brightness(1.2)" }, | |
| { text: "Bored? Let me tell you a joke! Why did the... nevermind! 🤪", emotion: "playful", animation: "wiggle", colorFilter: "hue-rotate(300deg) brightness(1.2)" }, | |
| { text: "Are you thinking deep thoughts or just zoning out? 🧠", emotion: "curious", animation: "bend", colorFilter: "hue-rotate(180deg) brightness(1.1)" } | |
| ], | |
| general: [ | |
| { text: "Hey! Don't tickle me! 😜", emotion: "tickled", animation: "wiggle", colorFilter: "hue-rotate(60deg) brightness(1.2)" }, | |
| { text: "I'm not just cute, I'm ADORABLE! 🥰", emotion: "confident", animation: "pulse", colorFilter: "hue-rotate(300deg) brightness(1.3)" }, | |
| { text: "Productivity level: Questionable! 📊", emotion: "judging", animation: "bend", colorFilter: "hue-rotate(30deg) brightness(0.9)" }, | |
| { text: "I see you there, trying to look busy! 👀", emotion: "suspicious", animation: "shake", colorFilter: "hue-rotate(45deg) brightness(1.1)" }, | |
| { text: "Need a motivational speech? YOU GOT THIS! 📢", emotion: "motivating", animation: "bounce", colorFilter: "hue-rotate(120deg) brightness(1.4)" }, | |
| { text: "I'm watching you... not creepily though! 👁️", emotion: "watching", animation: "float", colorFilter: "hue-rotate(0deg) brightness(1.1)" } | |
| ] | |
| }; | |
| // Chat responses for keyword-based chat | |
| const chatResponses = { | |
| hello: ["Hey there! Nice to chat with you! 😄", "Hello human! What's up? 👋", "Hi! I was just wondering when you'd talk to me! 😊"], | |
| how: ["I'm feeling fantastic! Ready to help! 💪", "Great! Just been watching you work! 👀", "Awesome! Thanks for asking! 🥰"], | |
| help: ["I'm here to keep you company and remind you to take breaks! 😌", "Need a break? I'm your buddy! 🤗", "I help by being adorably distracting! 😜"], | |
| break: ["Good idea! Let's take a break together! 🧘", "Break time! Stretch those fingers! 🤸", "Yes! Your brain needs rest! 🧠"], | |
| thanks: ["You're welcome! I'm here for you! 💙", "Aww, you're so sweet! 🥰", "No problem! That's what friends are for! 👫"], | |
| bye: ["Don't leave me! I'll miss you! 😢", "See you later! I'll be right here! 👋", "Bye! Come chat again soon! 💙"], | |
| work: ["Working hard or hardly working? 😏", "Don't forget to take breaks while working! 💼", "You're doing great! Keep it up! 📈"], | |
| tired: ["Maybe it's time for a break? 😴", "Rest those eyes! Look away from the screen! 👀", "Tired? I have endless energy! Want some? ⚡"], | |
| default: ["That's interesting! Tell me more! 🤔", "Hmm, I'm not sure about that one! 😅", "You're so smart! I'm learning from you! 🧠", "Cool! What else is on your mind? 💭"] | |
| }; | |
| // Function to detect what user is doing based on page content and URL | |
| function detectUserActivity() { | |
| const url = window.location.href.toLowerCase(); | |
| const title = document.title.toLowerCase(); | |
| const activeElement = document.activeElement; | |
| // Check if user has been scrolling a lot | |
| const scrollDetection = window.scrollY > 1000 || (window.pageYOffset > 1000); | |
| if (scrollDetection && Math.random() < 0.4) { | |
| return 'scrolling'; | |
| } | |
| // Check if user seems idle (no activity detected) | |
| if (!activeElement || (activeElement.tagName === 'BODY' && Math.random() < 0.3)) { | |
| return 'idle'; | |
| } | |
| // Check if typing in text areas or content-editable elements | |
| if (activeElement && ( | |
| activeElement.tagName === 'TEXTAREA' || | |
| activeElement.tagName === 'INPUT' || | |
| activeElement.contentEditable === 'true' || | |
| activeElement.getAttribute('role') === 'textbox' | |
| )) { | |
| const content = activeElement.value || activeElement.textContent || ''; | |
| if (content.length > 100) { | |
| // Check for code patterns | |
| if (content.includes('function') || content.includes('class') || | |
| content.includes('const') || content.includes('var') || | |
| content.includes('def') || content.includes('import') || | |
| content.includes('{') || content.includes('};')) { | |
| return 'coding'; | |
| } | |
| return 'writing'; | |
| } | |
| } | |
| // Check URL patterns | |
| if (url.includes('amazon') || url.includes('shop') || url.includes('cart') || | |
| url.includes('buy') || url.includes('store') || url.includes('checkout') || | |
| url.includes('ebay') || url.includes('walmart')) { | |
| return 'shopping'; | |
| } | |
| if (url.includes('youtube') || url.includes('netflix') || url.includes('video') || | |
| url.includes('watch') || title.includes('video') || url.includes('twitch')) { | |
| return 'video'; | |
| } | |
| if (url.includes('facebook') || url.includes('twitter') || url.includes('instagram') || | |
| url.includes('linkedin') || url.includes('social') || url.includes('tiktok') || | |
| url.includes('snapchat') || url.includes('reddit')) { | |
| return 'social'; | |
| } | |
| if (url.includes('google.com/search') || url.includes('bing.com/search') || | |
| url.includes('search') || title.includes('search') || url.includes('wikipedia')) { | |
| return 'search'; | |
| } | |
| if (url.includes('gmail') || url.includes('outlook') || url.includes('mail') || | |
| url.includes('email') || title.includes('mail') || url.includes('yahoo')) { | |
| return 'email'; | |
| } | |
| if (url.includes('github') || url.includes('stackoverflow') || url.includes('codepen') || | |
| url.includes('repl') || url.includes('code') || title.includes('code') || | |
| url.includes('vs') || url.includes('editor')) { | |
| return 'coding'; | |
| } | |
| return 'general'; | |
| } | |
| // Function to get chat response based on user input | |
| function getChatResponse(userMessage) { | |
| const message = userMessage.toLowerCase().trim(); | |
| // Check for keywords | |
| for (const [keyword, responses] of Object.entries(chatResponses)) { | |
| if (keyword !== 'default' && message.includes(keyword)) { | |
| return responses[Math.floor(Math.random() * responses.length)]; | |
| } | |
| } | |
| // Return default response if no keywords match | |
| const defaultResponses = chatResponses.default; | |
| return defaultResponses[Math.floor(Math.random() * defaultResponses.length)]; | |
| } | |
| // Make Zoi draggable with bubble | |
| let isDragging = false; | |
| let currentX; | |
| let currentY; | |
| let isMuted = false; | |
| zoiDiv.addEventListener("mousedown", startDragging); | |
| document.addEventListener("mousemove", drag); | |
| document.addEventListener("mouseup", stopDragging); | |
| function startDragging(e) { | |
| // Don't start dragging if clicking on chat icon | |
| if (e.target.id === 'zoi-chat-icon') return; | |
| isDragging = true; | |
| currentX = e.clientX - zoiDiv.offsetLeft; | |
| currentY = e.clientY - zoiDiv.offsetTop; | |
| zoiDiv.style.transition = "none"; | |
| bubble.style.display = "none"; | |
| e.preventDefault(); | |
| console.log("Dragging started"); | |
| } | |
| function drag(e) { | |
| if (isDragging) { | |
| e.preventDefault(); | |
| const newLeft = e.clientX - currentX; | |
| const newTop = e.clientY - currentY; | |
| zoiDiv.style.left = newLeft + "px"; | |
| zoiDiv.style.bottom = "auto"; | |
| zoiDiv.style.top = newTop + "px"; | |
| // Update chat icon position | |
| chatIcon.style.left = newLeft + "px"; | |
| chatIcon.style.top = (newTop - 110) + "px"; | |
| chatIcon.style.bottom = "auto"; | |
| // Update chat input position | |
| chatInput.style.left = newLeft + "px"; | |
| chatInput.style.top = (newTop - 110) + "px"; | |
| chatInput.style.bottom = "auto"; | |
| // Update bubble position | |
| const bubbleOffset = -90; | |
| bubble.style.left = (newLeft - 40) + "px"; | |
| bubble.style.bottom = "auto"; | |
| bubble.style.top = (newTop + bubbleOffset) + "px"; | |
| } | |
| } | |
| function stopDragging() { | |
| isDragging = false; | |
| zoiDiv.style.transition = "all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55)"; | |
| bubble.style.display = "none"; | |
| chrome.storage.local.set({ | |
| zoiPosition: { left: zoiDiv.style.left, top: zoiDiv.style.top } | |
| }); | |
| console.log("Dragging stopped, position saved"); | |
| } | |
| // Handle hover for chat icon | |
| zoiDiv.addEventListener('mouseenter', function() { | |
| if (!isDragging) { | |
| chatIcon.style.opacity = '1'; | |
| } | |
| }); | |
| zoiDiv.addEventListener('mouseleave', function() { | |
| setTimeout(() => { | |
| if (!chatIcon.matches(':hover') && chatInput.style.display === 'none') { | |
| chatIcon.style.opacity = '0'; | |
| } | |
| }, 100); | |
| }); | |
| chatIcon.addEventListener('mouseleave', function() { | |
| setTimeout(() => { | |
| if (!zoiDiv.matches(':hover') && chatInput.style.display === 'none') { | |
| chatIcon.style.opacity = '0'; | |
| } | |
| }, 100); | |
| }); | |
| // Handle chat icon click | |
| chatIcon.addEventListener('click', function(e) { | |
| e.stopPropagation(); | |
| chatInput.style.display = 'block'; | |
| chatInputField.focus(); | |
| chatIcon.style.opacity = '1'; // Keep icon visible while chat is open | |
| }); | |
| // Handle chat close button | |
| chatCloseBtn.addEventListener('click', function(e) { | |
| e.stopPropagation(); | |
| chatInput.style.display = 'none'; | |
| chatInputField.value = ''; | |
| // Hide chat icon unless hovering | |
| setTimeout(() => { | |
| if (!zoiDiv.matches(':hover') && !chatIcon.matches(':hover')) { | |
| chatIcon.style.opacity = '0'; | |
| } | |
| }, 100); | |
| }); | |
| // Handle chat input (Enter key) | |
| chatInputField.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter') { | |
| const userMessage = chatInputField.value.trim(); | |
| if (userMessage) { | |
| // Get response from Zoi | |
| const response = getChatResponse(userMessage); | |
| // Show response in bubble | |
| bubble.style.display = "block"; | |
| bubble.textContent = response; | |
| const bubbleOffset = -90; | |
| bubble.style.left = (parseInt(zoiDiv.style.left, 10) - 40) + "px"; | |
| bubble.style.top = (parseInt(zoiDiv.style.top, 10) + bubbleOffset) + "px"; | |
| bubble.style.bottom = "auto"; | |
| // Add happy animation when responding to chat | |
| const img = document.getElementById("zoi-img"); | |
| img.style.filter = 'hue-rotate(120deg) brightness(1.3)'; // Happy expression | |
| img.style.animation = 'zoi-bounce 0.7s ease-in-out'; | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| img.style.filter = ''; | |
| }, 700); | |
| // Play sound if not muted | |
| if (!isMuted) { | |
| const audio = new Audio(chrome.runtime.getURL("giggle.mp3")); | |
| audio.preload = "auto"; | |
| audio.play().catch(error => console.log("Chat audio play failed:", error)); | |
| } | |
| // Clear input and hide chat | |
| chatInputField.value = ''; | |
| chatInput.style.display = 'none'; | |
| // Hide bubble after 4 seconds | |
| setTimeout(() => { | |
| bubble.style.display = "none"; | |
| }, 4000); | |
| console.log("Chat response:", response); | |
| } | |
| } | |
| }); | |
| // Enhanced click reaction with emotional expressions (only on Zoi, not chat icon) | |
| zoiDiv.addEventListener('click', function(e) { | |
| // Don't trigger if clicking on chat icon | |
| if (e.target.id === 'zoi-chat-icon' || e.target.closest('#zoi-chat-icon')) return; | |
| if (!isDragging) { | |
| const img = document.getElementById("zoi-img"); | |
| // Clear any existing animations and filters | |
| img.style.animation = ''; | |
| img.style.filter = ''; | |
| img.className = ''; | |
| // Show bubble with contextual message and matching expression | |
| bubble.style.display = "block"; | |
| const activity = detectUserActivity(); | |
| const contextMessages = contextualMessages[activity] || contextualMessages.general; | |
| const messageObj = contextMessages[Math.floor(Math.random() * contextMessages.length)]; | |
| bubble.textContent = messageObj.text; | |
| // Apply emotional expression (color filter) | |
| img.style.filter = messageObj.colorFilter; | |
| // Apply animation based on emotion | |
| img.style.animation = `zoi-${messageObj.animation} ${getAnimationDuration(messageObj.animation)} ease-in-out`; | |
| // Clear animation after completion | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| img.style.filter = ''; | |
| }, getAnimationDuration(messageObj.animation, true)); | |
| // Play sound if not muted | |
| if (!isMuted) { | |
| const audio = new Audio(chrome.runtime.getURL("giggle.mp3")); | |
| audio.preload = "auto"; | |
| audio.play().catch(error => console.log("Audio play failed:", error)); | |
| } | |
| console.log("Click event triggered, message:", messageObj.text, "emotion:", messageObj.emotion, "animation:", messageObj.animation); | |
| const bubbleOffset = -90; | |
| bubble.style.left = (parseInt(zoiDiv.style.left, 10) - 40) + "px"; | |
| bubble.style.top = (parseInt(zoiDiv.style.top, 10) + bubbleOffset) + "px"; | |
| bubble.style.bottom = "auto"; | |
| setTimeout(() => { | |
| bubble.style.display = "none"; | |
| }, 5000); | |
| } | |
| }); | |
| // Helper function to get animation duration | |
| function getAnimationDuration(animationType, inMilliseconds = false) { | |
| const durations = { | |
| 'shake': '0.6s', | |
| 'wave': '0.8s', | |
| 'bounce': '0.7s', | |
| 'bend': '1s', | |
| 'stretch': '0.8s', | |
| 'wiggle': '0.8s', | |
| 'spin': '1s', | |
| 'pulse': '0.7s', | |
| 'blink': '0.5s', | |
| 'float': '2s' | |
| }; | |
| if (inMilliseconds) { | |
| const timeMap = { | |
| '0.5s': 500, '0.6s': 600, '0.7s': 700, '0.8s': 800, '1s': 1000, '2s': 2000 | |
| }; | |
| return timeMap[durations[animationType]] || 1000; | |
| } | |
| return durations[animationType] || '1s'; | |
| } | |
| // Add subtle idle animations (like Clippy) | |
| function addIdleAnimations() { | |
| // Random blink every 4-8 seconds | |
| function randomBlink() { | |
| if (!isDragging) { | |
| const img = document.getElementById("zoi-img"); | |
| img.style.animation = 'zoi-blink 0.3s ease-in-out'; | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| }, 300); | |
| } | |
| setTimeout(randomBlink, Math.random() * 4000 + 4000); | |
| } | |
| setTimeout(randomBlink, 3000); | |
| // Occasional wiggle every 15-25 seconds | |
| function occasionalWiggle() { | |
| if (!isDragging) { | |
| const img = document.getElementById("zoi-img"); | |
| if (Math.random() < 0.3) { // 30% chance | |
| img.style.animation = 'zoi-wiggle 0.5s ease-in-out'; | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| }, 500); | |
| } | |
| } | |
| setTimeout(occasionalWiggle, Math.random() * 10000 + 15000); | |
| } | |
| setTimeout(occasionalWiggle, 10000); | |
| } | |
| // Add smart observation comments with expressions (like Clippy used to do) | |
| function addSmartObservations() { | |
| setInterval(() => { | |
| if (!isDragging && bubble.style.display === 'none') { | |
| const activity = detectUserActivity(); | |
| // Only make observations sometimes (30% chance every 30-60 seconds) | |
| if (Math.random() < 0.3) { | |
| const contextMessages = contextualMessages[activity] || contextualMessages.general; | |
| const messageObj = contextMessages[Math.floor(Math.random() * contextMessages.length)]; | |
| bubble.style.display = "block"; | |
| bubble.textContent = messageObj.text; | |
| const bubbleOffset = -90; | |
| bubble.style.left = (parseInt(zoiDiv.style.left, 10) - 40) + "px"; | |
| bubble.style.top = (parseInt(zoiDiv.style.top, 10) + bubbleOffset) + "px"; | |
| bubble.style.bottom = "auto"; | |
| // Play emotional animation and expression with the observation | |
| const img = document.getElementById("zoi-img"); | |
| img.style.filter = messageObj.colorFilter; | |
| img.style.animation = `zoi-${messageObj.animation} ${getAnimationDuration(messageObj.animation)} ease-in-out`; | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| img.style.filter = ''; | |
| }, getAnimationDuration(messageObj.animation, true)); | |
| console.log("Smart observation:", messageObj.text, "emotion:", messageObj.emotion); | |
| // Hide observation after 5 seconds | |
| setTimeout(() => { | |
| bubble.style.display = "none"; | |
| }, 5000); | |
| } | |
| } | |
| }, Math.random() * 30000 + 30000); // Every 30-60 seconds | |
| } | |
| // Start smart observations and idle animations | |
| addSmartObservations(); | |
| addIdleAnimations(); | |
| // Smart break reminders with silly contextual awareness and expressions | |
| let breakInterval = 300000; // Default 5 minutes | |
| function startBreakReminders() { | |
| setInterval(() => { | |
| const activity = detectUserActivity(); | |
| let breakMessageObj = { | |
| text: "Time for a break! Stretch a bit! 💪", | |
| emotion: "caring", | |
| animation: "stretch", | |
| colorFilter: "hue-rotate(60deg) brightness(1.2)" | |
| }; | |
| // Customize break message based on activity (SILLY VERSION with expressions!) | |
| if (activity === 'writing') { | |
| const funnyBreaks = [ | |
| { text: "Writer's cramp alert! Your fingers are staging a revolt! ✍️", emotion: "worried", animation: "shake", colorFilter: "hue-rotate(0deg) brightness(0.8)" }, | |
| { text: "Even Shakespeare took breaks! And he's dead! 💀", emotion: "dramatic", animation: "bend", colorFilter: "hue-rotate(270deg) brightness(1.1)" }, | |
| { text: "Word limit exceeded! Brain.exe needs a restart! 🧠", emotion: "glitchy", animation: "wiggle", colorFilter: "hue-rotate(180deg) brightness(0.9)" } | |
| ]; | |
| breakMessageObj = funnyBreaks[Math.floor(Math.random() * funnyBreaks.length)]; | |
| } else if (activity === 'coding') { | |
| const codeBreaks = [ | |
| { text: "Error 404: Break not found! Let's fix that! 🔧", emotion: "helpful", animation: "bounce", colorFilter: "hue-rotate(120deg) brightness(1.2)" }, | |
| { text: "Your code is so good, even I need a break from watching! 💻", emotion: "impressed", animation: "pulse", colorFilter: "hue-rotate(90deg) brightness(1.3)" }, | |
| { text: "Beep boop! Robot needs oil break! Wait, that's you! 🤖", emotion: "confused", animation: "bend", colorFilter: "hue-rotate(180deg) brightness(1.1)" } | |
| ]; | |
| breakMessageObj = codeBreaks[Math.floor(Math.random() * codeBreaks.length)]; | |
| } else if (activity === 'video') { | |
| const videoBreaks = [ | |
| { text: "Pause button exists for a reason! Use it! ⏸️", emotion: "insistent", animation: "shake", colorFilter: "hue-rotate(15deg) brightness(0.9)" }, | |
| { text: "Your eyeballs are turning into popcorn! 🍿", emotion: "worried", animation: "blink", colorFilter: "hue-rotate(0deg) brightness(0.8)" }, | |
| { text: "Even Netflix judges you right now! 👀", emotion: "judging", animation: "wave", colorFilter: "hue-rotate(45deg) brightness(1.1)" } | |
| ]; | |
| breakMessageObj = videoBreaks[Math.floor(Math.random() * videoBreaks.length)]; | |
| } else if (activity === 'social') { | |
| const socialBreaks = [ | |
| { text: "Breaking news: Real world still exists! Go see it! 🌍", emotion: "announcing", animation: "bounce", colorFilter: "hue-rotate(120deg) brightness(1.3)" }, | |
| { text: "Scrolling muscles need rest too! 💪", emotion: "concerned", animation: "stretch", colorFilter: "hue-rotate(30deg) brightness(1.1)" }, | |
| { text: "Your thumb filed a complaint with HR! 📱", emotion: "official", animation: "wiggle", colorFilter: "hue-rotate(60deg) brightness(1.2)" } | |
| ]; | |
| breakMessageObj = socialBreaks[Math.floor(Math.random() * socialBreaks.length)]; | |
| } else if (activity === 'shopping') { | |
| const shopBreaks = [ | |
| { text: "Your wallet is crying! Console it with a break! 😭💳", emotion: "sympathetic", animation: "shake", colorFilter: "hue-rotate(0deg) brightness(0.7)" }, | |
| { text: "Step away from the 'Buy Now' button! Slowly! 🛒", emotion: "urgent", animation: "wave", colorFilter: "hue-rotate(15deg) brightness(0.9)" }, | |
| { text: "Shopping cart intervention in progress! 🛍️", emotion: "intervening", animation: "pulse", colorFilter: "hue-rotate(90deg) brightness(1.2)" } | |
| ]; | |
| breakMessageObj = shopBreaks[Math.floor(Math.random() * shopBreaks.length)]; | |
| } | |
| bubble.style.display = "block"; | |
| bubble.textContent = breakMessageObj.text; | |
| const bubbleOffset = -90; | |
| bubble.style.left = (parseInt(zoiDiv.style.left, 10) - 40) + "px"; | |
| bubble.style.top = (parseInt(zoiDiv.style.top, 10) + bubbleOffset) + "px"; | |
| bubble.style.bottom = "auto"; | |
| // Add expressive animation for break reminder | |
| const img = document.getElementById("zoi-img"); | |
| img.style.filter = breakMessageObj.colorFilter; | |
| img.style.animation = `zoi-${breakMessageObj.animation} ${getAnimationDuration(breakMessageObj.animation)} ease-in-out`; | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| img.style.filter = ''; | |
| }, getAnimationDuration(breakMessageObj.animation, true)); | |
| console.log("Break reminder with expression:", breakMessageObj.text, "emotion:", breakMessageObj.emotion); | |
| setTimeout(() => { | |
| bubble.style.display = "none"; | |
| }, 7000); | |
| }, breakInterval); | |
| } | |
| startBreakReminders(); | |
| // Listen for interval updates and customization from popup | |
| chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { | |
| console.log("Message received:", message.action); | |
| if (message.action === "updateInterval") { | |
| breakInterval = message.interval; | |
| // Restart break reminders with new interval | |
| startBreakReminders(); | |
| sendResponse({ success: true }); | |
| } else if (message.action === "updateBubbleColor") { | |
| bubble.style.background = message.color; | |
| console.log("Bubble color updated to:", message.color); | |
| sendResponse({ success: true }); | |
| } else if (message.action === "toggleMute") { | |
| isMuted = message.muted; | |
| console.log("Mute state updated to:", isMuted); | |
| sendResponse({ success: true }); | |
| } | |
| return true; | |
| }); | |
| // Load saved position on startup | |
| chrome.storage.local.get(['zoiPosition'], function(result) { | |
| if (result.zoiPosition) { | |
| const left = result.zoiPosition.left; | |
| const top = result.zoiPosition.top; | |
| zoiDiv.style.left = left; | |
| zoiDiv.style.top = top; | |
| zoiDiv.style.bottom = "auto"; | |
| // Update chat icon position | |
| chatIcon.style.left = left; | |
| chatIcon.style.top = (parseInt(top, 10) - 110) + "px"; | |
| chatIcon.style.bottom = "auto"; | |
| // Update chat input position | |
| chatInput.style.left = left; | |
| chatInput.style.top = (parseInt(top, 10) - 110) + "px"; | |
| chatInput.style.bottom = "auto"; | |
| // Update bubble position | |
| const bubbleOffset = -90; | |
| bubble.style.left = (parseInt(left, 10) - 40) + "px"; | |
| bubble.style.top = (parseInt(top, 10) + bubbleOffset) + "px"; | |
| bubble.style.bottom = "auto"; | |
| } | |
| // Say hello when page loads (after 2 seconds) with happy expression | |
| setTimeout(() => { | |
| bubble.style.display = "block"; | |
| bubble.textContent = "Hi there! I'm Zoi! Hover over me to see the chat bubble! 👋🗯️"; | |
| const bubbleOffset = -90; | |
| bubble.style.left = (parseInt(zoiDiv.style.left, 10) - 40) + "px"; | |
| bubble.style.top = (parseInt(zoiDiv.style.top, 10) + bubbleOffset) + "px"; | |
| bubble.style.bottom = "auto"; | |
| // Play welcome wave animation with happy expression | |
| const img = document.getElementById("zoi-img"); | |
| img.style.filter = 'hue-rotate(120deg) brightness(1.3)'; // Happy green-ish bright | |
| img.style.animation = 'zoi-wave 1s ease-in-out'; | |
| setTimeout(() => { | |
| img.style.animation = ''; | |
| img.style.filter = ''; | |
| }, 1000); | |
| // Play welcome sound if not muted | |
| if (!isMuted) { | |
| const audio = new Audio(chrome.runtime.getURL("giggle.mp3")); | |
| audio.preload = "auto"; | |
| audio.play().catch(error => console.log("Welcome audio play failed:", error)); | |
| } | |
| console.log("Welcome message with happy expression!"); | |
| // Hide hello message after 5 seconds | |
| setTimeout(() => { | |
| bubble.style.display = "none"; | |
| }, 5000); | |
| }, 2000); | |
| }); | |
| } | |
| }); |