@@ -257,6 +257,23 @@ const createContextMenu = () => {
257
257
} ) ;
258
258
} ) ;
259
259
}
260
+
261
+ if ( options . servers . length > 1 ) {
262
+ chrome . contextMenus . create ( {
263
+ id : 'add-torrent-server' ,
264
+ title : chrome . i18n . getMessage ( 'addTorrentServerAction' ) ,
265
+ contexts : [ 'link' ] ,
266
+ } ) ;
267
+
268
+ options . servers . forEach ( ( server , i ) => {
269
+ chrome . contextMenus . create ( {
270
+ id : 'add-torrent-server-' + i . toString ( ) ,
271
+ parentId : 'add-torrent-server' ,
272
+ title : server . name ,
273
+ contexts : [ 'link' ] ,
274
+ } ) ;
275
+ } ) ;
276
+ }
260
277
} else if ( client . clientCapabilities ) {
261
278
if ( client . clientCapabilities . includes ( 'label' ) && options . globals . labels . length ) {
262
279
chrome . contextMenus . create ( {
@@ -314,6 +331,7 @@ const registerHandler = () => {
314
331
const currentServer = info . menuItemId . match ( / ^ c u r r e n t - s e r v e r - ( \d + ) $ / ) ;
315
332
const labelId = info . menuItemId . match ( / ^ a d d - t o r r e n t - l a b e l - ( \d + ) $ / ) ;
316
333
const pathId = info . menuItemId . match ( / ^ a d d - t o r r e n t - p a t h - ( \d + ) $ / ) ;
334
+ const serverId = info . menuItemId . match ( / ^ a d d - t o r r e n t - s e r v e r - ( \d + ) $ / ) ;
317
335
318
336
const clientOptions = options . servers [ options . globals . currentServer ] . clientOptions || { } ;
319
337
@@ -343,6 +361,16 @@ const registerHandler = () => {
343
361
path : options . servers [ options . globals . currentServer ] . directories [ ~ ~ pathId [ 1 ] ] ,
344
362
...clientOptions
345
363
} ) ;
364
+ else if ( serverId ) {
365
+ const selectedServerId = parseInt ( serverId [ 1 ] , 10 ) ;
366
+ const selectedClientOptions = options . servers [ selectedServerId ] . clientOptions || { } ;
367
+
368
+ addTorrent ( info . linkUrl , tab . id , {
369
+ paused : options . globals . addPaused ,
370
+ server : selectedServerId ,
371
+ ...selectedClientOptions ,
372
+ } ) ;
373
+ }
346
374
else if ( info . menuItemId === 'add-torrent-advanced' )
347
375
addAdvancedDialog ( info . linkUrl , ! isMagnetUrl ( info . linkUrl ) ? tab . id : null ) ;
348
376
else if ( currentServer )
0 commit comments