Skip to content

Commit

Permalink
Improved log methods def
Browse files Browse the repository at this point in the history
- Condensed `msgType` init
+ Added empty fallback to `baseMsgStyle` init to avoid logging 'undefined' for success/error/info msg types
  • Loading branch information
adamlui committed Jan 27, 2025
1 parent 2675249 commit 5948f38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
7 changes: 3 additions & 4 deletions amazongpt/greasemonkey/amazongpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @description Adds the magic of AI to Amazon shopping
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.26.18
// @version 2025.1.26.19
// @license MIT
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
Expand Down Expand Up @@ -288,10 +288,9 @@
const args = Array.from(arguments).map(arg => typeof arg == 'object' ? JSON.stringify(arg) : arg)
const msgType = args.some(arg => /\.{3}$/.test(arg)) ? 'working'
: args.some(arg => /\bsuccess\b|!$/i.test(arg)) ? 'success'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning'
: 'info'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning' : 'info'
const prefixStyle = log.styles.prefix.base + log.styles.prefix[msgType]
const baseMsgStyle = log.styles.msg[msgType], msgStyles = []
const baseMsgStyle = log.styles.msg[msgType] || '', msgStyles = []

// Combine regex
const allPatterns = Object.values(log.regEx).flatMap(val =>
Expand Down
7 changes: 3 additions & 4 deletions bravegpt/greasemonkey/bravegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.26.18
// @version 2025.1.26.19
// @license MIT
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
Expand Down Expand Up @@ -442,10 +442,9 @@
const args = Array.from(arguments).map(arg => typeof arg == 'object' ? JSON.stringify(arg) : arg)
const msgType = args.some(arg => /\.{3}$/.test(arg)) ? 'working'
: args.some(arg => /\bsuccess\b|!$/i.test(arg)) ? 'success'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning'
: 'info'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning' : 'info'
const prefixStyle = log.styles.prefix.base + log.styles.prefix[msgType]
const baseMsgStyle = log.styles.msg[msgType], msgStyles = []
const baseMsgStyle = log.styles.msg[msgType] || '', msgStyles = []

// Combine regex
const allPatterns = Object.values(log.regEx).flatMap(val =>
Expand Down
7 changes: 3 additions & 4 deletions duckduckgpt/greasemonkey/duckduckgpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.26.19
// @version 2025.1.26.20
// @license MIT
// @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076
// @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076
Expand Down Expand Up @@ -443,10 +443,9 @@
const args = Array.from(arguments).map(arg => typeof arg == 'object' ? JSON.stringify(arg) : arg)
const msgType = args.some(arg => /\.{3}$/.test(arg)) ? 'working'
: args.some(arg => /\bsuccess\b|!$/i.test(arg)) ? 'success'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning'
: 'info'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning' : 'info'
const prefixStyle = log.styles.prefix.base + log.styles.prefix[msgType]
const baseMsgStyle = log.styles.msg[msgType], msgStyles = []
const baseMsgStyle = log.styles.msg[msgType] || '', msgStyles = []

// Combine regex
const allPatterns = Object.values(log.regEx).flatMap(val =>
Expand Down
7 changes: 3 additions & 4 deletions googlegpt/greasemonkey/googlegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-Google Search (inikwa amandla yi-Google Gemma + GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.26.18
// @version 2025.1.26.19
// @license MIT
// @icon https://assets.googlegpt.io/images/icons/googlegpt/black/icon48.png?v=59409b2
// @icon64 https://assets.googlegpt.io/images/icons/googlegpt/black/icon64.png?v=59409b2
Expand Down Expand Up @@ -631,10 +631,9 @@
const args = Array.from(arguments).map(arg => typeof arg == 'object' ? JSON.stringify(arg) : arg)
const msgType = args.some(arg => /\.{3}$/.test(arg)) ? 'working'
: args.some(arg => /\bsuccess\b|!$/i.test(arg)) ? 'success'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning'
: 'info'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning' : 'info'
const prefixStyle = log.styles.prefix.base + log.styles.prefix[msgType]
const baseMsgStyle = log.styles.msg[msgType], msgStyles = []
const baseMsgStyle = log.styles.msg[msgType] || '', msgStyles = []

// Combine regex
const allPatterns = Object.values(log.regEx).flatMap(val =>
Expand Down

0 comments on commit 5948f38

Please sign in to comment.