Use settings.value rather than localStorage · feildmaster/UnderScript@5efd666 · GitHub
Skip to content

Commit 5efd666

Browse files
committed
Use settings.value rather than localStorage
1 parent f8f8503 commit 5efd666

8 files changed

Lines changed: 15 additions & 16 deletions

File tree

src/base/battleLog.js

Lines changed: 1 addition & 1 deletion

src/base/cardskinshop.layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ settings.register({
1414
}
1515
},
1616
note: () => {
17-
if (onPage('CardSkinsShop') && !$('#cardedSkins').length && localStorage.getItem('underscript.disable.cardskins')) {
17+
if (onPage('CardSkinsShop') && !$('#cardedSkins').length && settings.value('underscript.disable.cardskins')) {
1818
return 'Enabling will refresh the page';
1919
}
2020
},
2121
});
2222

2323
onPage('CardSkinsShop', function () {
2424
debug('Skin shop');
25-
if (localStorage.getItem('underscript.disable.cardskins')) return;
25+
if (settings.value('underscript.disable.cardskins')) return;
2626
const cards = [];
2727
$('table#cardSkinsList > tbody > tr').each(function(row) {
2828
// Is this still supported?

src/base/chatContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ eventManager.on('ChatDetected' , () => {
4747
mute.append(' ', muteTime);
4848

4949
function open(event) {
50-
if (event.ctrlKey || localStorage.getItem('underscript.disable.chatContext')) return;
50+
if (event.ctrlKey || settings.value('underscript.disable.chatContext')) return;
5151
if (toast) {
5252
toast.close();
5353
}

src/base/deckStorage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ onPage('Decks', function deckStorage() {
4545
processNext();
4646
});
4747

48-
for (let i = 1, x = Math.max(parseInt(localStorage.getItem('underscript.storage.rows') || '1'), 1) * 3; i <= x; i++) {
48+
for (let i = 1, x = Math.max(parseInt(settings.value('underscript.storage.rows')), 1) * 3; i <= x; i++) {
4949
buttons.push($(`<button>${i}</button>`)
5050
.addClass('btn btn-sm btn-danger')
5151
.css({

src/base/endTurn.hotkey.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ settings.register({
55
settings.register({
66
name: 'Disable End Turn with Space',
77
key: 'underscript.disable.endTurn.space',
8-
disabled: () => localStorage.getItem('underscript.disable.endTurn') === '1',
8+
disabled: () => settings.value('underscript.disable.endTurn'),
99
note: () => {
1010
if (typeof gameId === 'undefined') return;
1111
return 'Will require you to refresh the page';
@@ -14,7 +14,7 @@ settings.register({
1414
settings.register({
1515
name: 'Disable End Turn with Middle Click',
1616
key: 'underscript.disable.endTurn.middleClick',
17-
disabled: () => localStorage.getItem('underscript.disable.endTurn') === '1',
17+
disabled: () => settings.value('underscript.disable.endTurn'),
1818
note: () => {
1919
if (typeof gameId === 'undefined') return;
2020
return 'Will require you to refresh the page';
@@ -24,13 +24,13 @@ settings.register({
2424
eventManager.on("PlayingGame", function bindHotkeys() {
2525
// Binds to Space, Middle Click
2626
const hotkey = new Hotkey("End turn").run((e) => {
27-
if (localStorage.getItem('underscript.disable.endTurn')) return;
27+
if (settings.value('underscript.disable.endTurn')) return;
2828
if (!$(e.target).is("#endTurnBtn") && userTurn === userId) endTurn();
2929
});
30-
if (!localStorage.getItem('underscript.disable.endTurn.space')) {
30+
if (!settings.value('underscript.disable.endTurn.space')) {
3131
hotkey.bindKey(32);
3232
}
33-
if (!localStorage.getItem('underscript.disable.endTurn.middleClick')) {
33+
if (!settings.value('underscript.disable.endTurn.middleClick')) {
3434
hotkey.bindClick(2);
3535
}
3636
hotkeys.push(hotkey);

src/base/indexLayout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ settings.register({
44
});
55

66
onPage('', function adjustSpectateView() {
7-
if (localStorage.getItem('underscript.disable.adjustSpectateView')) return;
7+
if (settings.value('underscript.disable.adjustSpectateView')) return;
88
const spectate = $('.spectateTable');
99
const tbody = $('.spectateTable tbody');
1010
const footer = $('.mainContent footer');

src/base/resultToast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ eventManager.on('getResult', function resultToast() {
1515
document.location.href = "/";
1616
},
1717
};
18-
if (!localStorage.getItem('underscript.disable.resultToast') && fn.toast(toast)) {
18+
if (!settings.value('underscript.disable.resultToast') && fn.toast(toast)) {
1919
BootstrapDialog.closeAll();
2020
}
2121
});

src/utils/settings.js

Lines changed: 3 additions & 4 deletions

0 commit comments

Comments
 (0)