AI-powered gaming assistant with strategic tips, performance analysis, and smart insights
Size
13.0 KB
Version
1.0.1
Created
Feb 2, 2026
Updated
2 days ago
1// ==UserScript==
2// @name Veck.io AI Content Enhancer
3// @description AI-powered gaming assistant with strategic tips, performance analysis, and smart insights
4// @version 1.0.1
5// @match https://*.veck.io/*
6// @icon https://veck.io/favicon/favicon.ico
7// @grant GM.getValue
8// @grant GM.setValue
9// ==/UserScript==
10(function() {
11 'use strict';
12
13 console.log('Veck.io AI Content Enhancer loaded');
14
15 // Utility function to create styled elements
16 function createStyledElement(tag, styles, content = '') {
17 const element = document.createElement(tag);
18 Object.assign(element.style, styles);
19 if (content) element.innerHTML = content;
20 return element;
21 }
22
23 // Debounce function for AI calls
24 function debounce(func, wait) {
25 let timeout;
26 return function executedFunction(...args) {
27 const later = () => {
28 clearTimeout(timeout);
29 func(...args);
30 };
31 clearTimeout(timeout);
32 timeout = setTimeout(later, wait);
33 };
34 }
35
36 // Create AI Enhancement Panel
37 function createAIPanel() {
38 const panel = createStyledElement('div', {
39 position: 'fixed',
40 top: '20px',
41 right: '20px',
42 width: '320px',
43 backgroundColor: 'rgba(20, 20, 30, 0.95)',
44 border: '2px solid #00ff88',
45 borderRadius: '12px',
46 padding: '15px',
47 zIndex: '10000',
48 fontFamily: 'Arial, sans-serif',
49 color: '#ffffff',
50 boxShadow: '0 8px 32px rgba(0, 255, 136, 0.3)',
51 backdropFilter: 'blur(10px)'
52 });
53
54 panel.innerHTML = `
55 <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;">
56 <h3 style="margin: 0; color: #00ff88; font-size: 18px; font-weight: bold;">🤖 AI Assistant</h3>
57 <button id="ai-toggle-btn" style="background: #ff4444; border: none; color: white; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px;">Hide</button>
58 </div>
59 <div id="ai-content">
60 <div style="margin-bottom: 12px;">
61 <label style="display: block; margin-bottom: 5px; color: #00ff88; font-size: 13px; font-weight: bold;">Ask AI:</label>
62 <textarea id="ai-prompt-input" placeholder="Ask for tips, strategies, or game advice..." style="width: 100%; height: 60px; background: rgba(255,255,255,0.1); border: 1px solid #00ff88; border-radius: 6px; padding: 8px; color: white; font-size: 12px; resize: none; box-sizing: border-box;"></textarea>
63 <button id="ai-ask-btn" style="width: 100%; margin-top: 8px; background: linear-gradient(135deg, #00ff88, #00cc6a); border: none; color: #000; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px;">Get AI Advice</button>
64 </div>
65 <div style="margin-bottom: 12px;">
66 <button id="ai-tips-btn" style="width: 100%; background: linear-gradient(135deg, #4488ff, #2266dd); border: none; color: white; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px; margin-bottom: 6px;">Generate Pro Tips</button>
67 <button id="ai-strategy-btn" style="width: 100%; background: linear-gradient(135deg, #ff8844, #dd6622); border: none; color: white; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px; margin-bottom: 6px;">Get Strategy Guide</button>
68 <button id="ai-analyze-btn" style="width: 100%; background: linear-gradient(135deg, #ff44ff, #dd22dd); border: none; color: white; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px;">Analyze Gameplay</button>
69 </div>
70 <div id="ai-response" style="background: rgba(0,0,0,0.4); border: 1px solid #00ff88; border-radius: 6px; padding: 10px; min-height: 100px; max-height: 300px; overflow-y: auto; font-size: 12px; line-height: 1.6; display: none;">
71 <div id="ai-response-content"></div>
72 </div>
73 <div id="ai-loading" style="display: none; text-align: center; padding: 20px;">
74 <div style="display: inline-block; width: 40px; height: 40px; border: 4px solid rgba(0,255,136,0.3); border-top-color: #00ff88; border-radius: 50%; animation: spin 1s linear infinite;"></div>
75 <p style="margin-top: 10px; color: #00ff88; font-size: 13px;">AI is thinking...</p>
76 </div>
77 </div>
78 `;
79
80 // Add CSS animation for loading spinner
81 const style = document.createElement('style');
82 style.textContent = `
83 @keyframes spin {
84 to { transform: rotate(360deg); }
85 }
86 #ai-response::-webkit-scrollbar {
87 width: 8px;
88 }
89 #ai-response::-webkit-scrollbar-track {
90 background: rgba(0,0,0,0.3);
91 border-radius: 4px;
92 }
93 #ai-response::-webkit-scrollbar-thumb {
94 background: #00ff88;
95 border-radius: 4px;
96 }
97 #ai-response::-webkit-scrollbar-thumb:hover {
98 background: #00cc6a;
99 }
100 `;
101 document.head.appendChild(style);
102
103 document.body.appendChild(panel);
104 return panel;
105 }
106
107 // Show loading state
108 function showLoading() {
109 document.getElementById('ai-loading').style.display = 'block';
110 document.getElementById('ai-response').style.display = 'none';
111 }
112
113 // Hide loading state
114 function hideLoading() {
115 document.getElementById('ai-loading').style.display = 'none';
116 }
117
118 // Display AI response
119 function displayResponse(content) {
120 hideLoading();
121 const responseDiv = document.getElementById('ai-response');
122 const contentDiv = document.getElementById('ai-response-content');
123
124 if (typeof content === 'object') {
125 contentDiv.innerHTML = formatStructuredResponse(content);
126 } else {
127 contentDiv.innerHTML = content.replace(/\n/g, '<br>');
128 }
129
130 responseDiv.style.display = 'block';
131 responseDiv.scrollTop = 0;
132 }
133
134 // Format structured AI responses
135 function formatStructuredResponse(data) {
136 let html = '';
137
138 if (data.tips && Array.isArray(data.tips)) {
139 html += '<div style="margin-bottom: 10px;"><strong style="color: #00ff88;">💡 Pro Tips:</strong><ul style="margin: 5px 0; padding-left: 20px;">';
140 data.tips.forEach(tip => {
141 html += `<li style="margin: 5px 0;">${tip}</li>`;
142 });
143 html += '</ul></div>';
144 }
145
146 if (data.strategies && Array.isArray(data.strategies)) {
147 html += '<div style="margin-bottom: 10px;"><strong style="color: #ff8844;">🎯 Strategies:</strong><ul style="margin: 5px 0; padding-left: 20px;">';
148 data.strategies.forEach(strategy => {
149 html += `<li style="margin: 5px 0;">${strategy}</li>`;
150 });
151 html += '</ul></div>';
152 }
153
154 if (data.analysis) {
155 html += `<div style="margin-bottom: 10px;"><strong style="color: #4488ff;">📊 Analysis:</strong><p style="margin: 5px 0;">${data.analysis}</p></div>`;
156 }
157
158 if (data.recommendation) {
159 html += `<div style="margin-bottom: 10px;"><strong style="color: #ff44ff;">⭐ Recommendation:</strong><p style="margin: 5px 0;">${data.recommendation}</p></div>`;
160 }
161
162 return html || JSON.stringify(data, null, 2);
163 }
164
165 // Make AI call with error handling
166 async function makeAICall(prompt, useStructured = false) {
167 showLoading();
168
169 try {
170 let response;
171
172 if (useStructured) {
173 response = await RM.aiCall(prompt, {
174 type: "json_schema",
175 json_schema: {
176 name: "game_advice",
177 schema: {
178 type: "object",
179 properties: {
180 tips: {
181 type: "array",
182 items: { type: "string" },
183 description: "List of actionable tips"
184 },
185 strategies: {
186 type: "array",
187 items: { type: "string" },
188 description: "Strategic advice"
189 },
190 analysis: {
191 type: "string",
192 description: "Overall analysis"
193 },
194 recommendation: {
195 type: "string",
196 description: "Key recommendation"
197 }
198 }
199 }
200 }
201 });
202 } else {
203 response = await RM.aiCall(prompt);
204 }
205
206 displayResponse(response);
207
208 // Cache the response
209 const cacheKey = 'ai_cache_' + Date.now();
210 await GM.setValue(cacheKey, JSON.stringify({
211 prompt: prompt,
212 response: response,
213 timestamp: Date.now()
214 }));
215
216 console.log('AI response received:', response);
217
218 } catch (error) {
219 console.error('AI call failed:', error);
220 hideLoading();
221 displayResponse('❌ <strong>Error:</strong> Failed to get AI response. Please try again.');
222 }
223 }
224
225 // Initialize the AI panel
226 function init() {
227 console.log('Initializing AI Content Enhancer...');
228
229 // Wait for page to be ready
230 if (document.readyState === 'loading') {
231 document.addEventListener('DOMContentLoaded', init);
232 return;
233 }
234
235 // Create the AI panel
236 const panel = createAIPanel();
237
238 // Toggle panel visibility
239 const toggleBtn = document.getElementById('ai-toggle-btn');
240 const aiContent = document.getElementById('ai-content');
241 let isVisible = true;
242
243 toggleBtn.addEventListener('click', () => {
244 isVisible = !isVisible;
245 aiContent.style.display = isVisible ? 'block' : 'none';
246 toggleBtn.textContent = isVisible ? 'Hide' : 'Show';
247 });
248
249 // Custom prompt handler
250 const askBtn = document.getElementById('ai-ask-btn');
251 const promptInput = document.getElementById('ai-prompt-input');
252
253 askBtn.addEventListener('click', async () => {
254 const userPrompt = promptInput.value.trim();
255 if (!userPrompt) {
256 displayResponse('⚠️ Please enter a question or request.');
257 return;
258 }
259
260 const fullPrompt = `You are an expert gaming assistant for Veck.io, a fast-paced FPS io game. Answer this player's question with helpful, actionable advice: ${userPrompt}`;
261 await makeAICall(fullPrompt, false);
262 });
263
264 // Enter key support for prompt input
265 promptInput.addEventListener('keypress', (e) => {
266 if (e.key === 'Enter' && !e.shiftKey) {
267 e.preventDefault();
268 askBtn.click();
269 }
270 });
271
272 // Pro Tips button
273 document.getElementById('ai-tips-btn').addEventListener('click', async () => {
274 const prompt = `Generate 5 professional gaming tips for Veck.io, a competitive FPS io game. Focus on aiming, movement, positioning, weapon selection, and survival tactics. Make them specific and actionable.`;
275 await makeAICall(prompt, true);
276 });
277
278 // Strategy Guide button
279 document.getElementById('ai-strategy-btn').addEventListener('click', async () => {
280 const prompt = `Create a comprehensive strategy guide for Veck.io FPS game. Include tips for beginners, intermediate tactics, advanced strategies, and map control advice. Format as structured advice.`;
281 await makeAICall(prompt, true);
282 });
283
284 // Analyze Gameplay button
285 document.getElementById('ai-analyze-btn').addEventListener('click', async () => {
286 const prompt = `Analyze optimal gameplay strategies for Veck.io FPS game. Provide analysis on: weapon effectiveness, movement patterns, positioning tactics, and how to improve K/D ratio. Include specific recommendations.`;
287 await makeAICall(prompt, true);
288 });
289
290 console.log('AI Content Enhancer initialized successfully!');
291 }
292
293 // Start the extension
294 init();
295
296})();