|
148 | 148 | // @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!) |
149 | 149 | // @author KudoAI |
150 | 150 | // @namespace https://kudoai.com |
151 | | -// @version 2025.5.17.3 |
| 151 | +// @version 2025.5.17.4 |
152 | 152 | // @license MIT |
153 | 153 | // @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076 |
154 | 154 | // @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076 |
|
204 | 204 | // @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/components/chatbot/menus.js#sha256-WmMykl3i2NW2z0q9RnTFGFq175w2mNWN8hnUuh9NFZM= |
205 | 205 | // @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/components/chatbot/tooltip.js#sha256-xrfMTFfKqdqN926lng78y9ECco6ccpi3Mz9LBaTP7Ws= |
206 | 206 | // @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/lib/chatbot/feedback.js#sha256-3X5Xq5EkQKlXuHhWMOEvdCLzNUGcCBG8BIIo2LD5cxw= |
| 207 | +// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@f4da9d4/assets/js/lib/chatbot/log.js#sha256-kjt26UXbx44I0/iDOf50F/LbRtsYcSwMHrexImR4D5A= |
207 | 208 | // @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/lib/chatbot/session.js#sha256-S6MOdBjx8Hci4GDvYl4JlhSdrDk2oaRLU9DrdxyiIss= |
208 | | -// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@b1e28ff/assets/js/lib/chatbot/userscript.js#sha256-SytCWuD3YOcYFDaVfpF8Pq67zDbV8cZcIENz+0zpZ40=// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/lib/crypto-utils.js/dist/crypto-utils.min.js#sha256-xRkis9u0tYeTn/GBN4sqVRqcCdEhDUN16/PlCy9wNnk= |
| 209 | +// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@b1e28ff/assets/js/lib/chatbot/userscript.js#sha256-SytCWuD3YOcYFDaVfpF8Pq67zDbV8cZcIENz+0zpZ40= |
| 210 | +// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/lib/crypto-utils.js/dist/crypto-utils.min.js#sha256-SytCWuD3YOcYFDaVfpF8Pq67zDbV8cZcIENz+0zpZ40= |
209 | 211 | // @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@9b048ff/assets/js/lib/dom.js/dist/dom.min.js#sha256-IGNj9Eoecq7QgY7SAs75wONajgN9Wg0NmCjKTCfu9CY= |
210 | 212 | // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/generate-ip.min.js#sha256-aQQKAQcMgCu8IpJp9HKs387x0uYxngO+Fb4pc5nSF4I= |
211 | 213 | // @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js#sha256-g3pvpbDHNrUrveKythkPMF2j/J7UFoHbUyFQcFe1yEY= |
|
326 | 328 | }))) |
327 | 329 | apis.AIchatOS.userID = '#/chat/' + Date.now() |
328 | 330 |
|
329 | | - // Init DEBUG mode |
| 331 | + // Init SETTINGS |
330 | 332 | window.config = {} |
331 | 333 | window.settings = { |
332 | 334 | load(...keys) { |
|
337 | 339 | }, |
338 | 340 | save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val } |
339 | 341 | } |
340 | | - settings.load('debugMode') |
341 | | - |
342 | | - // Define LOG props/functions |
343 | | - window.log = { |
344 | | - |
345 | | - styles: { |
346 | | - prefix: { |
347 | | - base: `color: white ; padding: 2px 3px 2px 5px ; border-radius: 2px ; ${ |
348 | | - env.browser.isFF ? 'font-size: 13px ;' : '' }`, |
349 | | - info: 'background: linear-gradient(344deg, rgba(0,0,0,1) 0%,' |
350 | | - + 'rgba(0,0,0,1) 39%, rgba(30,29,43,0.6026611328125) 93%)', |
351 | | - working: 'background: linear-gradient(342deg, rgba(255,128,0,1) 0%,' |
352 | | - + 'rgba(255,128,0,0.9612045501794468) 57%, rgba(255,128,0,0.7539216370141807) 93%)' , |
353 | | - success: 'background: linear-gradient(344deg, rgba(0,107,41,1) 0%,' |
354 | | - + 'rgba(3,147,58,1) 39%, rgba(24,126,42,0.7735294801514356) 93%)', |
355 | | - warning: 'background: linear-gradient(344deg, rgba(255,0,0,1) 0%,' |
356 | | - + 'rgba(232,41,41,0.9079832616640406) 57%, rgba(222,49,49,0.6530813008797269) 93%)', |
357 | | - caller: 'color: blue' |
358 | | - }, |
359 | | - |
360 | | - msg: { working: 'color: #ff8000', warning: 'color: red' } |
361 | | - }, |
362 | | - |
363 | | - regEx: { |
364 | | - greenVals: { caseInsensitive: /\b(?:true|\d+)\b|success\W?/i, caseSensitive: /\bON\b/ }, |
365 | | - redVals: { caseInsensitive: /\bfalse\b|error\W?/i, caseSensitive: /\BOFF\b/ }, |
366 | | - purpVals: /[ '"]\w+['"]?: / }, |
367 | | - |
368 | | - prettifyObj(obj) { return JSON.stringify(obj) |
369 | | - .replace(/([{,](?=")|":)/g, '$1 ') // append spaces to { and " |
370 | | - .replace(/((?<!\})\})/g, ' $1') // prepend spaces to } |
371 | | - .replace(/"/g, '\'') // replace " w/ ' |
372 | | - }, |
373 | | - |
374 | | - toTitleCase(str) { return str[0].toUpperCase() + str.slice(1) } |
375 | | - |
376 | | - } ; ['info', 'error', 'debug'].forEach(logType => |
377 | | - log[logType] = function() { |
378 | | - if (logType == 'debug' && !config.debugMode) return |
379 | | - |
380 | | - const args = [...arguments].map(arg => typeof arg == 'object' ? JSON.stringify(arg) : arg) |
381 | | - const msgType = args.some(arg => /\.{3}$/.test(arg)) ? 'working' |
382 | | - : args.some(arg => /\bsuccess\b|!$/i.test(arg)) ? 'success' |
383 | | - : args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning' : 'info' |
384 | | - const prefixStyle = log.styles.prefix.base + log.styles.prefix[msgType] |
385 | | - const baseMsgStyle = log.styles.msg[msgType] || '', msgStyles = [] |
386 | | - |
387 | | - // Combine regex |
388 | | - const allPatterns = Object.values(log.regEx).flatMap(val => |
389 | | - val instanceof RegExp ? [val] : Object.values(val).filter(val => val instanceof RegExp)) |
390 | | - const combinedPattern = new RegExp(allPatterns.map(pattern => pattern.source).join('|'), 'g') |
391 | | - |
392 | | - // Combine args into finalMsg, color chars |
393 | | - let finalMsg = logType == 'error' && args.length == 1 && !/error:/i.test(args[0]) ? 'ERROR: ' : '' |
394 | | - args.forEach((arg, idx) => { |
395 | | - finalMsg += idx > 0 ? (idx == 1 ? ': ' : ' ') : '' // separate multi-args |
396 | | - finalMsg += arg?.toString().replace(combinedPattern, match => { |
397 | | - const matched = ( |
398 | | - Object.values(log.regEx.greenVals).some(val => |
399 | | - val.test(match) && (msgStyles.push('color: green', baseMsgStyle), true)) |
400 | | - || Object.values(log.regEx.redVals).some(val => |
401 | | - val.test(match) && (msgStyles.push('color: red', baseMsgStyle), true)) |
402 | | - ) |
403 | | - if (!matched && log.regEx.purpVals.test(match)) { msgStyles.push('color: #dd29f4', baseMsgStyle) } |
404 | | - return `%c${match}%c` |
405 | | - }) |
406 | | - }) |
407 | | - |
408 | | - console[logType == 'error' ? logType : 'info']( |
409 | | - `${app.symbol} %c${app.name}%c ${ log.caller ? `${log.caller} » ` : '' }%c${finalMsg}`, |
410 | | - prefixStyle, log.styles.prefix.caller, baseMsgStyle, ...msgStyles |
411 | | - ) |
412 | | - } |
413 | | - ) |
414 | | - |
415 | | - // Init SETTINGS |
416 | | - log.debug('Initializing settings...') |
| 342 | + settings.load('debugMode') ; log.debug('Initializing settings...') |
417 | 343 | Object.assign(settings, { controls: { // displays top-to-bottom, left-to-right in Settings modal |
418 | 344 | proxyAPIenabled: { type: 'toggle', icon: 'sunglasses', defaultVal: false, |
419 | 345 | label: app.msgs.menuLabel_proxyAPImode, |
|
0 commit comments