Skip to content

Commit 0344239

Browse files
committed
chore: cleanup
1 parent 4961cec commit 0344239

File tree

8 files changed

+15
-22
lines changed

8 files changed

+15
-22
lines changed

src/base/chat/disableEmotes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ function updateEmotes() {
4747
});
4848
}
4949

50-
compound('Chat:Connected', 'translation:loaded', init);
50+
compound('Chat:Connected', 'translation:underscript', init);
5151
eventManager.on('connect', updateEmotes);

src/base/library/deck/storage.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import compound from 'src/utils/compoundEvent.js';
99
import hasOwn from 'src/utils/hasOwn.js';
1010
import { cardName } from 'src/utils/cardHelper.js';
1111

12+
// TODO: translation
1213
const setting = settings.register({
1314
name: 'Disable Deck Storage',
1415
key: 'underscript.storage.disable',
@@ -33,17 +34,9 @@ onPage('Decks', function deckStorage() {
3334
function getFromLibrary(id, library = [], shiny = undefined) {
3435
return library.find((card) => card.id === id && (shiny === undefined || card.shiny === shiny));
3536
}
36-
function getCardData(id, shiny, deep) {
37+
function getCardData(id, shiny) {
38+
// TODO: Filter out cards with insufficient quantity
3739
const library = global('deckCollections', 'collections');
38-
if (deep) {
39-
// Search all decks
40-
const keys = Object.keys(library);
41-
for (let i = 0; i < keys.length; i++) {
42-
const card = getFromLibrary(id, library[keys[i]], shiny);
43-
if (card) return card;
44-
}
45-
return null;
46-
}
4740
return getFromLibrary(id, library[global('soul')], shiny);
4841
}
4942

@@ -113,10 +106,8 @@ onPage('Decks', function deckStorage() {
113106
const deck = JSON.parse(localStorage.getItem(key));
114107
if (!deck) return null;
115108
if (trim) {
116-
return deck.cards.filter(({ id, shiny }) => {
117-
const data = getCardData(id, shiny);
118-
return data && cardName(data);
119-
});
109+
// TODO: Filter out cards with insufficient quantity
110+
return deck.cards.filter(({ id, shiny }) => getCardData(id, shiny));
120111
}
121112
return deck.cards;
122113
}
@@ -147,6 +138,7 @@ onPage('Decks', function deckStorage() {
147138
function cards(list) {
148139
const names = [];
149140
list.forEach((card) => {
141+
// TODO: Filter out cards with insufficient quantity
150142
let data = getCardData(card.id, card.shiny);
151143
const name = data ?
152144
`<span class="${data.rarity}">${cardName(data)}</span>` :
@@ -196,6 +188,7 @@ onPage('Decks', function deckStorage() {
196188
if (e.type === 'mouseenter') {
197189
const deck = getDeck(i);
198190
fixClass(!!deck);
191+
// TODO: translation
199192
if (deck) {
200193
text = `
201194
<div id="deckName">${localStorage.getItem(nameKey) || `${soul}-${i + 1}`}</div>

src/base/underscript/patchnotes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ wrap(function patchNotes() {
1313
key: 'underscript.disable.patches',
1414
});
1515

16-
cleanData('underscript.update.', scriptVersion, 'last', 'checking', 'latest');
16+
cleanData('underscript.update.', scriptVersion, 'last', 'checking', 'debug');
1717
style.add(css`
1818
#AlertToast div.uschangelog span:nth-of-type(2) {
1919
max-height: 300px;

src/hooks/friends.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios';
22
import eventManager from 'src/utils/eventManager.js';
33
import decrypt from 'src/utils/decrypt.emails.js';
4-
import { debugToast as debug } from 'src/utils/debug.js';
4+
import debug from 'src/utils/debugToast';
55
import sleep from 'src/utils/sleep.js';
66
import { window } from 'src/utils/1.variables.js';
77

src/hooks/zz.loaded.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function done() {
2222

2323
if (location.host.includes('undercards.net')) {
2424
console.log(`UnderScript(v${scriptVersion}): Loaded`); // eslint-disable-line no-console
25-
if (document.title.includes('Undercards')) {
25+
if (!location.pathname.includes('/', 1)) {
2626
register();
2727
}
2828
}

src/utils/decrypt.emails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const selector = 'a[href="/cdn-cgi/l/email-protection"]';
22

33
function hexAt(str = '', index = 0) {
4-
const r = str.substr(index, 2);
4+
const r = str.substring(index, index + 2);
55
return parseInt(r, 16);
66
}
77

src/utils/menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function open() {
8686
};
8787
button.on('click', callable)
8888
.on('keydown', (e) => {
89-
if (e.which !== 32 && e.which !== 13) return;
89+
if (e.key !== ' ' && e.key !== 'Enter') return;
9090
e.preventDefault();
9191
callable(e);
9292
}).css({
@@ -140,7 +140,7 @@ export function addButton(button = {}) {
140140
hidden: () => typeof hidden === 'function' && hidden() || false,
141141
};
142142
if (button.top) {
143-
buttons.splice(0, 0, safeButton);
143+
buttons.unshift(safeButton);
144144
} else {
145145
buttons.push(safeButton);
146146
}

src/utils/settings/types/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export default class Select extends Setting {
2424
function options(data = [], current = '') {
2525
return data.map((o) => {
2626
const [l, v = l] = toArray(o);
27-
return `<option value="${v}"${current === `${v}` ? ' selected' : ''}>${translateText(l)}</option>`;
27+
return `<option value="${v}"${`${current}` === `${v}` ? ' selected' : ''}>${translateText(l)}</option>`;
2828
});
2929
}

0 commit comments

Comments
 (0)