File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import ignoreUser from 'src/utils/ignoreUser.js';
99import decode from 'src/utils/decode.js' ;
1010import { buttonCSS , window } from 'src/utils/1.variables.js' ;
1111import Translation from 'src/structures/constants/translation.ts' ;
12+ import isCtrl from 'src/utils/isCtrl' ;
1213
1314const setting = settings . register ( {
1415 name : Translation . Setting ( 'chat.rightclick' ) ,
@@ -98,7 +99,7 @@ eventManager.on('jQuery', () => {
9899 mute . append ( ' ' , muteTime ) ;
99100
100101 function open ( event ) {
101- if ( event . ctrlKey || setting . value ( ) ) return ;
102+ if ( isCtrl ( event ) || setting . value ( ) ) return ;
102103 if ( toast ) {
103104 toast . close ( 'opened' ) ;
104105 }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import onPage from 'src/utils/onPage.js';
66import * as hover from 'src/utils/hover.js' ;
77import * as cardHelper from 'src/utils/cardHelper.js' ;
88import Translation from 'src/structures/constants/translation.js' ;
9+ import isCtrl from 'src/utils/isCtrl.js' ;
910import setBypass from './protection.js' ;
1011
1112const setting = settings . register ( {
@@ -50,7 +51,7 @@ onPage('Crafting', function craftMax() {
5051 card . off ( 'click' ) . on ( 'click.script' , ( e ) => {
5152 const id = parseInt ( card . attr ( 'id' ) , 10 ) ;
5253 const shiny = card . hasClass ( 'shiny' ) ;
53- if ( e . ctrlKey ) {
54+ if ( isCtrl ( e ) ) {
5455 hover . hide ( ) ;
5556 const count = max - cardHelper . quantity ( el ) ;
5657 if ( count <= 0 ) return ;
Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ eventManager.on(':preload:Decks', () => {
102102 clearDeck . after ( ' ' , button ) ;
103103} ) ;
104104
105- function getMode ( { ctrlKey = false , shiftKey = false } ) {
106- if ( ctrlKey ) return true ;
105+ function getMode ( { ctrlKey = false , metaKey = false , shiftKey = false } ) {
106+ if ( ctrlKey || metaKey ) return true ;
107107 if ( shiftKey ) return false ;
108108 return undefined ;
109109}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { cardName } from 'src/utils/cardHelper.js';
1111import { translateText } from 'src/utils/translate' ;
1212import { getTranslationArray } from 'src/base/underscript/translation' ;
1313import Translation from 'src/structures/constants/translation.ts' ;
14+ import isCtrl from 'src/utils/isCtrl' ;
1415
1516// TODO: translation
1617const setting = settings . register ( {
@@ -220,10 +221,11 @@ onPage('Decks', function deckStorage() {
220221 saveButton ( ) ;
221222 return ;
222223 }
223- if ( e . ctrlKey && e . shiftKey ) { // Crazy people...
224+ const ctrlKey = isCtrl ( e ) ;
225+ if ( ctrlKey && e . shiftKey ) { // Crazy people...
224226 return ;
225227 }
226- if ( e . ctrlKey ) { // ERASE
228+ if ( ctrlKey ) { // ERASE
227229 localStorage . removeItem ( nameKey ) ;
228230 localStorage . removeItem ( deckKey ) ;
229231 refreshHover ( ) ; // Update
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import wrap from 'src/utils/2.pokemon.js';
55import sleep from 'src/utils/sleep.js' ;
66import * as api from 'src/utils/4.api.js' ;
77import Translation from 'src/structures/constants/translation.ts' ;
8+ import isCtrl from 'src/utils/isCtrl.js' ;
89import { getTranslationArray } from '../underscript/translation.js' ;
910
1011wrap ( ( ) => {
@@ -39,7 +40,7 @@ wrap(() => {
3940 }
4041
4142 function getCount ( e , cost , baseCost ) {
42- if ( e . ctrlKey ) return Math . floor ( parseInt ( $ ( cost ? '#ucp' : '#golds' ) . text ( ) , 10 ) / baseCost ) ;
43+ if ( isCtrl ( e ) ) return Math . floor ( parseInt ( $ ( cost ? '#ucp' : '#golds' ) . text ( ) , 10 ) / baseCost ) ;
4344 if ( e . altKey ) return 10 ;
4445 return 1 ;
4546 }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { getCollection } from 'src/utils/user.js';
1111import { buttonCSS as css , window } from 'src/utils/1.variables.js' ;
1212import Item from 'src/structures/constants/item.js' ;
1313import length from 'src/utils/length' ;
14+ import isCtrl from 'src/utils/isCtrl' ;
1415
1516onPage ( 'Packs' , async function quickOpenPack ( ) {
1617 const collection = await getCollection ( ) ;
@@ -281,7 +282,7 @@ onPage('Packs', async function quickOpenPack() {
281282 } ) ;
282283 // TODO: translation
283284 $ ( '[id^="btnOpen"]' ) . on ( 'click.script' , ( event ) => {
284- autoOpen = event . ctrlKey ;
285+ autoOpen = isCtrl ( event ) ;
285286 const type = $ ( event . target ) . prop ( 'id' ) . substring ( 7 ) ;
286287 const count = autoOpen ? 1 : parseInt ( $ ( `#nb${ type } Packs` ) . text ( ) , 10 ) ;
287288 if ( event . shiftKey ) {
Original file line number Diff line number Diff line change @@ -3,14 +3,15 @@ import * as settings from 'src/utils/settings/index.js';
33import { global , globalSet } from 'src/utils/global.js' ;
44import * as hover from 'src/utils/hover.js' ;
55import Translation from 'src/structures/constants/translation.ts' ;
6+ import isCtrl from 'src/utils/isCtrl' ;
67
78const disable = settings . register ( {
89 name : Translation . Setting ( 'page.jump' ) ,
910 key : 'underscript.disable.quickpages' ,
1011} ) ;
1112
1213function ignoring ( e ) {
13- const ignore = disable . value ( ) || ! e . ctrlKey ;
14+ const ignore = disable . value ( ) || ! isCtrl ( e ) ;
1415 if ( ignore && [ 0 , global ( 'getMaxPage' ) ( ) ] . includes ( global ( 'currentPage' ) ) ) hover . hide ( ) ;
1516 return ignore ;
1617}
Original file line number Diff line number Diff line change 1+ /**
2+ * @param {KeyboardEvent } event
3+ */
4+ export default function isCtrl ( event ) {
5+ return event . ctrlKey || event . metaKey ;
6+ }
You can’t perform that action at this time.
0 commit comments