Skip to content

Commit 3d5942b

Browse files
committed
Condensed array length checks
1 parent 7764b54 commit 3d5942b

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

amazongpt/greasemonkey/amazongpt.user.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @description Adds the magic of AI to Amazon shopping
44
// @author KudoAI
55
// @namespace https://kudoai.com
6-
// @version 2025.1.19.10
6+
// @version 2025.1.20
77
// @license MIT
88
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
99
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
@@ -1299,7 +1299,7 @@
12991299

13001300
update(targetIcons = [], color = '') {
13011301
if (!Array.isArray(targetIcons)) targetIcons = [targetIcons]
1302-
if (targetIcons.length == 0) targetIcons = document.querySelectorAll(`#${app.slug}-icon`)
1302+
if (!targetIcons.length) targetIcons = document.querySelectorAll(`#${app.slug}-icon`)
13031303
targetIcons.forEach(icon => {
13041304
icon.src = GM_getResourceText(`amzgpt${
13051305
color == 'white' || !color && env.ui.app.scheme == 'dark' ? 'DS' : 'LS' }icon`)
@@ -1338,7 +1338,7 @@
13381338

13391339
update(...targetIcons) {
13401340
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
1341-
if (targetIcons.length == 0) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
1341+
if (!targetIcons.length) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
13421342
targetIcons.forEach(icon => {
13431343
icon.firstChild?.remove() // clear prev paths
13441344
icon.append(icons.arrowsDiagonal[config.expanded ? 'inwardSVGpath' : 'outwardSVGpath']())
@@ -1600,7 +1600,7 @@
16001600

16011601
update(...targetLogos) {
16021602
targetLogos = targetLogos.flat() // flatten array args nested by spread operator
1603-
if (targetLogos.length == 0) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
1603+
if (!targetLogos.length) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
16041604
targetLogos.forEach(logo =>
16051605
logo.src = GM_getResourceText(`amzgpt${ env.ui.app.scheme == 'dark' ? 'DS' : 'LS' }logo`))
16061606
}

bravegpt/greasemonkey/bravegpt.user.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.1.20
151+
// @version 2025.1.20.1
152152
// @license MIT
153153
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
154154
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
@@ -1650,7 +1650,7 @@
16501650

16511651
update(...targetIcons) {
16521652
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
1653-
if (targetIcons.length == 0) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
1653+
if (!targetIcons.length) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
16541654
targetIcons.forEach(icon => {
16551655
icon.firstChild?.remove() // clear prev paths
16561656
icon.append(icons.arrowsDiagonal[config.expanded ? 'inwardSVGpath' : 'outwardSVGpath']())
@@ -1969,7 +1969,7 @@
19691969

19701970
update(...targetIcons) {
19711971
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
1972-
if (targetIcons.length == 0)
1972+
if (!targetIcons.length)
19731973
targetIcons = document.querySelectorAll('#widescreen-icon:not(.chatgpt-notif *)')
19741974
targetIcons.forEach(icon => {
19751975
icon.firstChild?.remove() // clear prev paths
@@ -2002,7 +2002,7 @@
20022002

20032003
update(...targetLogos) {
20042004
targetLogos = targetLogos.flat() // flatten array args nested by spread operator
2005-
if (targetLogos.length == 0) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
2005+
if (!targetLogos.length) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
20062006
targetLogos.forEach(logo =>
20072007
logo.src = GM_getResourceText(`bgpt${ env.ui.app.scheme == 'dark' ? 'DS' : 'LS' }logo`))
20082008
}
@@ -2391,7 +2391,7 @@
23912391

23922392
// Filter out inactive ads, pick random active one
23932393
const activeAds = adGroup.ads.filter(ad => ad.active != false)
2394-
if (activeAds.length == 0) continue // to next group since no ads active
2394+
if (!activeAds.length) continue // to next group since no ads active
23952395
const chosenAd = ( // random active one
23962396
activeAds[Math.floor(chatgpt.randomFloat() * activeAds.length)])
23972397

duckduckgpt/greasemonkey/duckduckgpt.user.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.1.20
151+
// @version 2025.1.20.1
152152
// @license MIT
153153
// @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076
154154
// @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076
@@ -1655,7 +1655,7 @@
16551655

16561656
update(...targetIcons) {
16571657
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
1658-
if (targetIcons.length == 0) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
1658+
if (!targetIcons.length) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
16591659
targetIcons.forEach(icon => {
16601660
icon.firstChild?.remove() // clear prev paths
16611661
icon.append(icons.arrowsDiagonal[config.expanded ? 'inwardSVGpath' : 'outwardSVGpath']())
@@ -1974,7 +1974,7 @@
19741974

19751975
update(...targetIcons) {
19761976
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
1977-
if (targetIcons.length == 0)
1977+
if (!targetIcons.length)
19781978
targetIcons = document.querySelectorAll('#widescreen-icon:not(.chatgpt-notif *)')
19791979
targetIcons.forEach(icon => {
19801980
icon.firstChild?.remove() // clear prev paths
@@ -2007,7 +2007,7 @@
20072007

20082008
update(...targetLogos) {
20092009
targetLogos = targetLogos.flat() // flatten array args nested by spread operator
2010-
if (targetLogos.length == 0) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
2010+
if (!targetLogos.length) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
20112011
targetLogos.forEach(logo =>
20122012
logo.src = GM_getResourceText(`ddgpt${ env.ui.app.scheme == 'dark' ? 'DS' : 'LS' }logo`))
20132013
}
@@ -3951,7 +3951,7 @@
39513951

39523952
// Filter out inactive ads, pick random active one
39533953
const activeAds = adGroup.ads.filter(ad => ad.active != false)
3954-
if (activeAds.length == 0) continue // to next group since no ads active
3954+
if (!activeAds.length) continue // to next group since no ads active
39553955
const chosenAd = ( // random active one
39563956
activeAds[Math.floor(chatgpt.randomFloat() * activeAds.length)])
39573957

googlegpt/greasemonkey/googlegpt.user.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
// @description:zu Yengeza izimpendulo ze-AI ku-Google Search (inikwa amandla yi-Google Gemma + GPT-4o!)
150150
// @author KudoAI
151151
// @namespace https://kudoai.com
152-
// @version 2025.1.20
152+
// @version 2025.1.20.1
153153
// @license MIT
154154
// @icon https://assets.googlegpt.io/images/icons/googlegpt/black/icon48.png?v=59409b2
155155
// @icon64 https://assets.googlegpt.io/images/icons/googlegpt/black/icon64.png?v=59409b2
@@ -1798,7 +1798,7 @@
17981798

17991799
update(...targetIcons) {
18001800
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
1801-
if (targetIcons.length == 0) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
1801+
if (!targetIcons.length) targetIcons = document.querySelectorAll('#arrows-diagonal-icon')
18021802
targetIcons.forEach(icon => {
18031803
icon.firstChild?.remove() // clear prev paths
18041804
icon.append(icons.arrowsDiagonal[config.expanded ? 'inwardSVGpath' : 'outwardSVGpath']())
@@ -1938,7 +1938,7 @@
19381938

19391939
update(targetIcons = [], color = '') {
19401940
if (!Array.isArray(targetIcons)) targetIcons = [targetIcons]
1941-
if (targetIcons.length == 0) targetIcons = document.querySelectorAll(`#${app.slug}-icon`)
1941+
if (!targetIcons.length) targetIcons = document.querySelectorAll(`#${app.slug}-icon`)
19421942
targetIcons.forEach(icon => {
19431943
icon.src = GM_getResourceText(`ggptIcon${( color.charAt(0).toUpperCase() + color.slice(1) )
19441944
|| ( env.ui.app.scheme == 'dark' ? 'White' : 'Black' )}`)
@@ -2130,7 +2130,7 @@
21302130

21312131
update(...targetIcons) {
21322132
targetIcons = targetIcons.flat() // flatten array args nested by spread operator
2133-
if (targetIcons.length == 0)
2133+
if (!targetIcons.length)
21342134
targetIcons = document.querySelectorAll('#widescreen-icon:not(.chatgpt-notif *)')
21352135
targetIcons.forEach(icon => {
21362136
icon.firstChild?.remove() // clear prev paths
@@ -2163,7 +2163,7 @@
21632163

21642164
update(...targetLogos) {
21652165
targetLogos = targetLogos.flat() // flatten array args nested by spread operator
2166-
if (targetLogos.length == 0) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
2166+
if (!targetLogos.length) targetLogos = document.querySelectorAll(`#${app.slug}-logo`)
21672167
targetLogos.forEach(logo =>
21682168
logo.src = GM_getResourceText(`ggpt${ env.ui.app.scheme == 'dark' ? 'DS' : 'LS' }logo`))
21692169
}
@@ -2560,7 +2560,7 @@
25602560

25612561
// Filter out inactive ads, pick random active one
25622562
const activeAds = adGroup.ads.filter(ad => ad.active != false)
2563-
if (activeAds.length == 0) continue // to next group since no ads active
2563+
if (!activeAds.length) continue // to next group since no ads active
25642564
const chosenAd = ( // random active one
25652565
activeAds[Math.floor(chatgpt.randomFloat() * activeAds.length)])
25662566

0 commit comments

Comments
 (0)