Skip to content

Commit 41e742d

Browse files
committed
chore: reuse buttonCSS
1 parent 2bd92b8 commit 41e742d

File tree

13 files changed

+36
-87
lines changed

13 files changed

+36
-87
lines changed

src/base/chat/context.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as fnUser from '../../utils/user.js';
88
import ignoreUser from '../../utils/ignoreUser.js';
99
import decode from '../../utils/decode.js';
1010
import css from '../../utils/css.js';
11+
import { buttonCSS } from '../../utils/1.variables.js';
1112

1213
const setting = settings.register({
1314
name: 'Disable Chat Context (right click)',
@@ -144,14 +145,7 @@ eventManager.on('jQuery', () => {
144145
'background-color': 'rgba(208, 0, 0, 0.6)',
145146
},
146147
buttons: [{
147-
css: {
148-
border: '',
149-
height: '',
150-
background: '',
151-
'font-size': '',
152-
margin: '',
153-
'border-radius': '',
154-
},
148+
css: buttonCSS,
155149
text: 'Undo',
156150
className: 'dismiss',
157151
onclick: () => {

src/base/chat/largeIconMode.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { buttonCSS as css } from '../../utils/1.variables.js';
12
import { infoToast } from '../../utils/2.toasts.js';
23
import eventManager from '../../utils/eventManager.js';
34
import * as settings from '../../utils/settings/index.js';
@@ -34,14 +35,7 @@ eventManager.on('ChatDetected', () => {
3435
const buttons = {
3536
text: value ? 'Revert it!' : 'Enable it!',
3637
className: 'dismiss',
37-
css: {
38-
border: '',
39-
height: '',
40-
background: '',
41-
'font-size': '',
42-
margin: '',
43-
'border-radius': '',
44-
},
38+
css,
4539
onclick: (e) => {
4640
setting.set(!value);
4741
},

src/base/chat/notify.new.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import pendingIgnore from '../../utils/pendingIgnore.js';
55
import pingRegex from '../../utils/pingRegex.js';
66
import { pingExtras } from './toast.js';
77
import { infoToast } from '../../utils/2.toasts.js';
8+
import { buttonCSS } from '../../utils/1.variables.js';
89

910
const setting = settings.register({
1011
name: 'Disable Chat Ping <span style="color: yellow;">(highlighting)</span>',
@@ -74,12 +75,7 @@ function notify() {
7475
className: 'dismissable',
7576
css: {
7677
button: {
77-
border: '',
78-
height: '',
79-
background: '',
80-
'font-size': '',
81-
margin: '',
82-
'border-radius': '',
78+
...buttonCSS,
8379
'white-space': 'normal',
8480
},
8581
},

src/base/friendship/magic.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import eventManager from '../../utils/eventManager.js';
33
import * as settings from '../../utils/settings/index.js';
44
import { toast } from '../../utils/2.toasts.js';
55
import getLevel from '../../utils/getFriendshipLevel.js';
6+
import { buttonCSS as css } from '../../utils/1.variables.js';
67

78
const setting = settings.register({
89
name: 'Disable Friendship Notification',
@@ -31,14 +32,7 @@ function getFriendship() {
3132
buttons: {
3233
text: 'Go now!',
3334
className: 'dismiss',
34-
css: {
35-
border: '',
36-
height: '',
37-
background: '',
38-
'font-size': '',
39-
margin: '',
40-
'border-radius': '',
41-
},
35+
css,
4236
onclick: (e) => {
4337
location.href = '/Friendship';
4438
},

src/base/game/hotkeys/endTurn.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as settings from '../../../utils/settings/index.js';
33
import { global } from '../../../utils/global.js';
44
import { infoToast } from '../../../utils/2.toasts.js';
55
import Hotkey from '../../../utils/hotkey.class.js';
6-
import { hotkeys } from '../../../utils/1.variables.js';
6+
import { buttonCSS as css, hotkeys } from '../../../utils/1.variables.js';
77
import { BUTTON as MOUSE_BUTTON } from '../../../utils/mouse.js';
88

99
const fullDisable = settings.register({
@@ -46,14 +46,7 @@ eventManager.on('PlayingGame', function bindHotkeys() {
4646
buttons: {
4747
text: 'Open Settings',
4848
className: 'dismiss',
49-
css: {
50-
border: '',
51-
height: '',
52-
background: '',
53-
'font-size': '',
54-
margin: '',
55-
'border-radius': '',
56-
},
49+
css,
5750
onclick: (_) => {
5851
settings.open('Game');
5952
},

src/base/plugin/enabled.local.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { buttonCSS } from '../../utils/1.variables.js';
1+
import { buttonCSS as css } from '../../utils/1.variables.js';
22
import wrap from '../../utils/2.pokemon.js';
33
import { registerModule } from '../../utils/plugin.js';
44
import * as settings from '../../utils/settings/index.js';
@@ -47,14 +47,14 @@ wrap(() => {
4747
},
4848
buttons: [{
4949
text: isEnabled ? 'Disable' : 'Enable',
50-
css: buttonCSS,
50+
css,
5151
onclick() {
5252
enabled.set(!isEnabled);
5353
registered.set(true);
5454
},
5555
}, {
5656
text: 'Dismiss',
57-
css: buttonCSS,
57+
css,
5858
onclick() {
5959
enabled.set(isEnabled);
6060
registered.set(true);

src/base/store/quickPacks.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { blankToast, toast as basicToast } from '../../utils/2.toasts.js';
88
import * as api from '../../utils/4.api.js';
99
import formatNumber from '../../utils/formatNumber.js';
1010
import { getCollection } from '../../utils/user.js';
11+
import { buttonCSS as css } from '../../utils/1.variables.js';
1112

1213
onPage('Packs', async function quickOpenPack() {
1314
const collection = await getCollection();
@@ -138,14 +139,7 @@ onPage('Packs', async function quickOpenPack() {
138139
buttons: {
139140
text: 'Stop',
140141
className: 'dismiss',
141-
css: {
142-
border: '',
143-
height: '',
144-
background: '',
145-
'font-size': '',
146-
margin: '',
147-
'border-radius': '',
148-
},
142+
css,
149143
onclick: (e) => {
150144
events.emit('cancel');
151145
},

src/base/streamer/message.private.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { toast } from '../../utils/2.toasts.js';
55
import { debug } from '../../utils/debug.js';
66
import each from '../../utils/each.js';
77
import streaming from './0.streamer.js';
8+
import { buttonCSS as css } from '../../utils/1.variables.js';
89

910
/* eslint-disable no-multi-assign */
1011
// Toast for private messages while streaming mode is on
@@ -50,14 +51,7 @@ eventManager.on('preChat:getPrivateMessage', function streamerMode(data) {
5051
toasts[userId] = toast({
5152
text: `Message from ${user.name(user)}`,
5253
buttons: [{
53-
css: {
54-
border: '',
55-
height: '',
56-
background: '',
57-
'font-size': '',
58-
margin: '',
59-
'border-radius': '',
60-
},
54+
css,
6155
text: 'Open',
6256
className: 'dismiss',
6357
onclick: () => {

src/base/underscript/updates.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { toast as BasicToast } from '../../utils/2.toasts.js';
88
import sleep from '../../utils/sleep.js';
99
import * as menu from '../../utils/menu.js';
1010
import semver from '../../utils/version.js';
11-
import { scriptVersion } from '../../utils/1.variables.js';
11+
import { buttonCSS, scriptVersion } from '../../utils/1.variables.js';
1212
import css from '../../utils/css.js';
1313
import { captureError } from '../../utils/sentry.js';
1414

@@ -99,34 +99,26 @@ wrap(() => {
9999
latest.set(data);
100100
if (updateToast) updateToast.close('stale');
101101
const path = `underscript@${data.version}/${data.unpkg}`;
102-
const baseStyle = {
103-
border: '',
104-
height: '',
105-
background: '',
106-
'font-size': '',
107-
margin: '',
108-
'border-radius': '',
109-
};
110102
updateToast = BasicToast({
111103
title: '[UnderScript] Update Available!',
112104
text: `Version ${data.version}.`,
113105
className: 'dismissable',
114106
buttons: [{
115107
text: 'Update (github)',
116108
className: 'dismiss',
117-
css: baseStyle,
109+
css: buttonCSS,
118110
}, {
119111
text: 'Update (unpkg)',
120112
className: 'dismiss',
121-
css: baseStyle,
113+
css: buttonCSS,
122114
onclick(e) {
123115
location.href = `${baseURL}/${path}`;
124116
updateToast.close('update');
125117
},
126118
}, {
127119
text: 'Update (jsdelivr)',
128120
className: 'dismiss',
129-
css: baseStyle,
121+
css: buttonCSS,
130122
onclick: (e) => {
131123
location.href = `https://cdn.jsdelivr.net/npm/${path}`;
132124
updateToast.close('update');

src/utils/1.variables.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ export const footer = '<div style="width:100%;text-align:center;font-size:12px;f
33
export const footer2 = '<div style="width:100%;text-align:center;font-size:12px;font-family:monospace;">via UnderScript</div>';
44
export const hotkeys = [];
55
export const scriptVersion = GM_info.script.version;
6+
export const buttonCSS = {
7+
border: '',
8+
height: '',
9+
background: '',
10+
'font-size': '',
11+
margin: '',
12+
'border-radius': '',
13+
};
614

715
export const SOCKET_SCRIPT_CLOSED = 3500;
816

0 commit comments

Comments
 (0)