-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmb_enhanced_cover_art_uploads.user.js
4853 lines (3957 loc) · 232 KB
/
mb_enhanced_cover_art_uploads.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name MB: Enhanced Cover Art Uploads
// @description Enhance the cover art uploader! Upload directly from a URL, automatically import covers from Discogs/Spotify/Apple Music/..., automatically retrieve the largest version, and more!
// @version 2021.11.7
// @author ROpdebee
// @license MIT; https://opensource.org/licenses/MIT
// @namespace https://github.com/ROpdebee/mb-userscripts
// @homepageURL https://github.com/ROpdebee/mb-userscripts
// @supportURL https://github.com/ROpdebee/mb-userscripts/issues
// @downloadURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_enhanced_cover_art_uploads.user.js
// @updateURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_enhanced_cover_art_uploads.meta.js
// @match *://*.musicbrainz.org/release/*/add-cover-art
// @match *://*.musicbrainz.org/release/*/add-cover-art?*
// @match *://atisket.pulsewidth.org.uk/*
// @match *://vgmdb.net/album/*
// @exclude *://atisket.pulsewidth.org.uk/
// @require https://github.com/qsniyg/maxurl/blob/563626fe3b7c5ed3f6dc19d90a356746c68b5b4b/userscript.user.js?raw=true
// @resource amazonFavicon https://www.amazon.com/favicon.ico
// @run-at document-end
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
// @grant GM_getValue
// @grant GM.getValue
// @grant GM_setValue
// @grant GM.setValue
// @grant GM_getResourceURL
// @grant GM.getResourceUrl
// @connect *
// ==/UserScript==
(function () {
'use strict';
/* minified: babel helpers, core-js, gm4-polyfill, nativejsx, regenerator-runtime, @babel, ts-custom-error, p-throttle */
var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},check=function(e){return e&&e.Math==Math&&e},global$l=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof commonjsGlobal&&commonjsGlobal)||function(){return this}()||Function("return this")(),objectGetOwnPropertyDescriptor={},fails$5=function(e){try{return !!e()}catch(t){return !0}},fails$4=fails$5,descriptors=!fails$4((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),call$4=Function.prototype.call,functionCall=call$4.bind?call$4.bind(call$4):function(){return call$4.apply(call$4,arguments)},objectPropertyIsEnumerable={},$propertyIsEnumerable={}.propertyIsEnumerable,getOwnPropertyDescriptor$1=Object.getOwnPropertyDescriptor,NASHORN_BUG=getOwnPropertyDescriptor$1&&!$propertyIsEnumerable.call({1:2},1);objectPropertyIsEnumerable.f=NASHORN_BUG?function(e){var t=getOwnPropertyDescriptor$1(this,e);return !!t&&t.enumerable}:$propertyIsEnumerable;var match,version,createPropertyDescriptor$2=function(e,t){return {enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},FunctionPrototype$1=Function.prototype,bind=FunctionPrototype$1.bind,call$3=FunctionPrototype$1.call,callBind=bind&&bind.bind(call$3),functionUncurryThis=bind?function(e){return e&&callBind(call$3,e)}:function(e){return e&&function(){return call$3.apply(e,arguments)}},uncurryThis$8=functionUncurryThis,toString$1=uncurryThis$8({}.toString),stringSlice=uncurryThis$8("".slice),classofRaw=function(e){return stringSlice(toString$1(e),8,-1)},global$k=global$l,uncurryThis$7=functionUncurryThis,fails$3=fails$5,classof=classofRaw,Object$3=global$k.Object,split=uncurryThis$7("".split),indexedObject=fails$3((function(){return !Object$3("z").propertyIsEnumerable(0)}))?function(e){return "String"==classof(e)?split(e,""):Object$3(e)}:Object$3,global$j=global$l,TypeError$7=global$j.TypeError,requireObjectCoercible$2=function(e){if(null==e)throw TypeError$7("Can't call method on "+e);return e},IndexedObject=indexedObject,requireObjectCoercible$1=requireObjectCoercible$2,toIndexedObject$4=function(e){return IndexedObject(requireObjectCoercible$1(e))},isCallable$9=function(e){return "function"==typeof e},isCallable$8=isCallable$9,isObject$5=function(e){return "object"==typeof e?null!==e:isCallable$8(e)},global$i=global$l,isCallable$7=isCallable$9,aFunction=function(e){return isCallable$7(e)?e:void 0},getBuiltIn$4=function(e,t){return arguments.length<2?aFunction(global$i[e]):global$i[e]&&global$i[e][t]},uncurryThis$6=functionUncurryThis,objectIsPrototypeOf=uncurryThis$6({}.isPrototypeOf),getBuiltIn$3=getBuiltIn$4,engineUserAgent=getBuiltIn$3("navigator","userAgent")||"",global$h=global$l,userAgent=engineUserAgent,process=global$h.process,Deno=global$h.Deno,versions=process&&process.versions||Deno&&Deno.version,v8=versions&&versions.v8;v8&&(version=(match=v8.split("."))[0]>0&&match[0]<4?1:+(match[0]+match[1])),!version&&userAgent&&(!(match=userAgent.match(/Edge\/(\d+)/))||match[1]>=74)&&(match=userAgent.match(/Chrome\/(\d+)/))&&(version=+match[1]);var engineV8Version=version,V8_VERSION=engineV8Version,fails$2=fails$5,nativeSymbol=!!Object.getOwnPropertySymbols&&!fails$2((function(){var e=Symbol();return !String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&V8_VERSION&&V8_VERSION<41})),NATIVE_SYMBOL$1=nativeSymbol,useSymbolAsUid=NATIVE_SYMBOL$1&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,global$g=global$l,getBuiltIn$2=getBuiltIn$4,isCallable$6=isCallable$9,isPrototypeOf=objectIsPrototypeOf,USE_SYMBOL_AS_UID$1=useSymbolAsUid,Object$2=global$g.Object,isSymbol$2=USE_SYMBOL_AS_UID$1?function(e){return "symbol"==typeof e}:function(e){var t=getBuiltIn$2("Symbol");return isCallable$6(t)&&isPrototypeOf(t.prototype,Object$2(e))},global$f=global$l,String$2=global$f.String,tryToString$1=function(e){try{return String$2(e)}catch(t){return "Object"}},global$e=global$l,isCallable$5=isCallable$9,tryToString=tryToString$1,TypeError$6=global$e.TypeError,aCallable$1=function(e){if(isCallable$5(e))return e;throw TypeError$6(tryToString(e)+" is not a function")},aCallable=aCallable$1,getMethod$1=function(e,t){var r=e[t];return null==r?void 0:aCallable(r)},global$d=global$l,call$2=functionCall,isCallable$4=isCallable$9,isObject$4=isObject$5,TypeError$5=global$d.TypeError,ordinaryToPrimitive$1=function(e,t){var r,n;if("string"===t&&isCallable$4(r=e.toString)&&!isObject$4(n=call$2(r,e)))return n;if(isCallable$4(r=e.valueOf)&&!isObject$4(n=call$2(r,e)))return n;if("string"!==t&&isCallable$4(r=e.toString)&&!isObject$4(n=call$2(r,e)))return n;throw TypeError$5("Can't convert object to primitive value")},shared$3={exports:{}},global$c=global$l,defineProperty=Object.defineProperty,setGlobal$3=function(e,t){try{defineProperty(global$c,e,{value:t,configurable:!0,writable:!0});}catch(r){global$c[e]=t;}return t},global$b=global$l,setGlobal$2=setGlobal$3,SHARED="__core-js_shared__",store$3=global$b[SHARED]||setGlobal$2(SHARED,{}),sharedStore=store$3,store$2=sharedStore;(shared$3.exports=function(e,t){return store$2[e]||(store$2[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.19.1",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var global$a=global$l,requireObjectCoercible=requireObjectCoercible$2,Object$1=global$a.Object,toObject$2=function(e){return Object$1(requireObjectCoercible(e))},uncurryThis$5=functionUncurryThis,toObject$1=toObject$2,hasOwnProperty=uncurryThis$5({}.hasOwnProperty),hasOwnProperty_1=Object.hasOwn||function(e,t){return hasOwnProperty(toObject$1(e),t)},uncurryThis$4=functionUncurryThis,id=0,postfix=Math.random(),toString=uncurryThis$4(1..toString),uid$2=function(e){return "Symbol("+(void 0===e?"":e)+")_"+toString(++id+postfix,36)},global$9=global$l,shared$2=shared$3.exports,hasOwn$6=hasOwnProperty_1,uid$1=uid$2,NATIVE_SYMBOL=nativeSymbol,USE_SYMBOL_AS_UID=useSymbolAsUid,WellKnownSymbolsStore=shared$2("wks"),Symbol$1=global$9.Symbol,symbolFor=Symbol$1&&Symbol$1.for,createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol$1:Symbol$1&&Symbol$1.withoutSetter||uid$1,wellKnownSymbol$2=function(e){if(!hasOwn$6(WellKnownSymbolsStore,e)||!NATIVE_SYMBOL&&"string"!=typeof WellKnownSymbolsStore[e]){var t="Symbol."+e;NATIVE_SYMBOL&&hasOwn$6(Symbol$1,e)?WellKnownSymbolsStore[e]=Symbol$1[e]:WellKnownSymbolsStore[e]=USE_SYMBOL_AS_UID&&symbolFor?symbolFor(t):createWellKnownSymbol(t);}return WellKnownSymbolsStore[e]},global$8=global$l,call$1=functionCall,isObject$3=isObject$5,isSymbol$1=isSymbol$2,getMethod=getMethod$1,ordinaryToPrimitive=ordinaryToPrimitive$1,wellKnownSymbol$1=wellKnownSymbol$2,TypeError$4=global$8.TypeError,TO_PRIMITIVE=wellKnownSymbol$1("toPrimitive"),toPrimitive$1=function(e,t){if(!isObject$3(e)||isSymbol$1(e))return e;var r,n=getMethod(e,TO_PRIMITIVE);if(n){if(void 0===t&&(t="default"),r=call$1(n,e,t),!isObject$3(r)||isSymbol$1(r))return r;throw TypeError$4("Can't convert object to primitive value")}return void 0===t&&(t="number"),ordinaryToPrimitive(e,t)},toPrimitive=toPrimitive$1,isSymbol=isSymbol$2,toPropertyKey$2=function(e){var t=toPrimitive(e,"string");return isSymbol(t)?t:t+""},global$7=global$l,isObject$2=isObject$5,document$1=global$7.document,EXISTS$1=isObject$2(document$1)&&isObject$2(document$1.createElement),documentCreateElement$1=function(e){return EXISTS$1?document$1.createElement(e):{}},DESCRIPTORS$5=descriptors,fails$1=fails$5,createElement=documentCreateElement$1,ie8DomDefine=!DESCRIPTORS$5&&!fails$1((function(){return 7!=Object.defineProperty(createElement("div"),"a",{get:function(){return 7}}).a})),DESCRIPTORS$4=descriptors,call=functionCall,propertyIsEnumerableModule=objectPropertyIsEnumerable,createPropertyDescriptor$1=createPropertyDescriptor$2,toIndexedObject$3=toIndexedObject$4,toPropertyKey$1=toPropertyKey$2,hasOwn$5=hasOwnProperty_1,IE8_DOM_DEFINE$1=ie8DomDefine,$getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;objectGetOwnPropertyDescriptor.f=DESCRIPTORS$4?$getOwnPropertyDescriptor:function(e,t){if(e=toIndexedObject$3(e),t=toPropertyKey$1(t),IE8_DOM_DEFINE$1)try{return $getOwnPropertyDescriptor(e,t)}catch(r){}if(hasOwn$5(e,t))return createPropertyDescriptor$1(!call(propertyIsEnumerableModule.f,e,t),e[t])};var objectDefineProperty={},global$6=global$l,isObject$1=isObject$5,String$1=global$6.String,TypeError$3=global$6.TypeError,anObject$4=function(e){if(isObject$1(e))return e;throw TypeError$3(String$1(e)+" is not an object")},global$5=global$l,DESCRIPTORS$3=descriptors,IE8_DOM_DEFINE=ie8DomDefine,anObject$3=anObject$4,toPropertyKey=toPropertyKey$2,TypeError$2=global$5.TypeError,$defineProperty=Object.defineProperty;objectDefineProperty.f=DESCRIPTORS$3?$defineProperty:function(e,t,r){if(anObject$3(e),t=toPropertyKey(t),anObject$3(r),IE8_DOM_DEFINE)try{return $defineProperty(e,t,r)}catch(n){}if("get"in r||"set"in r)throw TypeError$2("Accessors not supported");return "value"in r&&(e[t]=r.value),e};var DESCRIPTORS$2=descriptors,definePropertyModule$3=objectDefineProperty,createPropertyDescriptor=createPropertyDescriptor$2,createNonEnumerableProperty$3=DESCRIPTORS$2?function(e,t,r){return definePropertyModule$3.f(e,t,createPropertyDescriptor(1,r))}:function(e,t,r){return e[t]=r,e},redefine$1={exports:{}},uncurryThis$3=functionUncurryThis,isCallable$3=isCallable$9,store$1=sharedStore,functionToString=uncurryThis$3(Function.toString);isCallable$3(store$1.inspectSource)||(store$1.inspectSource=function(e){return functionToString(e)});var set,get,has,inspectSource$2=store$1.inspectSource,global$4=global$l,isCallable$2=isCallable$9,inspectSource$1=inspectSource$2,WeakMap$2=global$4.WeakMap,nativeWeakMap=isCallable$2(WeakMap$2)&&/native code/.test(inspectSource$1(WeakMap$2)),shared$1=shared$3.exports,uid=uid$2,keys=shared$1("keys"),sharedKey$2=function(e){return keys[e]||(keys[e]=uid(e))},hiddenKeys$4={},NATIVE_WEAK_MAP=nativeWeakMap,global$3=global$l,uncurryThis$2=functionUncurryThis,isObject=isObject$5,createNonEnumerableProperty$2=createNonEnumerableProperty$3,hasOwn$4=hasOwnProperty_1,shared=sharedStore,sharedKey$1=sharedKey$2,hiddenKeys$3=hiddenKeys$4,OBJECT_ALREADY_INITIALIZED="Object already initialized",TypeError$1=global$3.TypeError,WeakMap$1=global$3.WeakMap,enforce=function(e){return has(e)?get(e):set(e,{})},getterFor=function(e){return function(t){var r;if(!isObject(t)||(r=get(t)).type!==e)throw TypeError$1("Incompatible receiver, "+e+" required");return r}};if(NATIVE_WEAK_MAP||shared.state){var store=shared.state||(shared.state=new WeakMap$1),wmget=uncurryThis$2(store.get),wmhas=uncurryThis$2(store.has),wmset=uncurryThis$2(store.set);set=function(e,t){if(wmhas(store,e))throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);return t.facade=e,wmset(store,e,t),t},get=function(e){return wmget(store,e)||{}},has=function(e){return wmhas(store,e)};}else {var STATE=sharedKey$1("state");hiddenKeys$3[STATE]=!0,set=function(e,t){if(hasOwn$4(e,STATE))throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);return t.facade=e,createNonEnumerableProperty$2(e,STATE,t),t},get=function(e){return hasOwn$4(e,STATE)?e[STATE]:{}},has=function(e){return hasOwn$4(e,STATE)};}var internalState={set:set,get:get,has:has,enforce:enforce,getterFor:getterFor},DESCRIPTORS$1=descriptors,hasOwn$3=hasOwnProperty_1,FunctionPrototype=Function.prototype,getDescriptor=DESCRIPTORS$1&&Object.getOwnPropertyDescriptor,EXISTS=hasOwn$3(FunctionPrototype,"name"),PROPER=EXISTS&&"something"===function(){}.name,CONFIGURABLE=EXISTS&&(!DESCRIPTORS$1||DESCRIPTORS$1&&getDescriptor(FunctionPrototype,"name").configurable),functionName={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE},global$2=global$l,isCallable$1=isCallable$9,hasOwn$2=hasOwnProperty_1,createNonEnumerableProperty$1=createNonEnumerableProperty$3,setGlobal$1=setGlobal$3,inspectSource=inspectSource$2,InternalStateModule=internalState,CONFIGURABLE_FUNCTION_NAME=functionName.CONFIGURABLE,getInternalState=InternalStateModule.get,enforceInternalState=InternalStateModule.enforce,TEMPLATE=String(String).split("String");(redefine$1.exports=function(e,t,r,n){var o,i=!!n&&!!n.unsafe,a=!!n&&!!n.enumerable,c=!!n&&!!n.noTargetGet,l=n&&void 0!==n.name?n.name:t;isCallable$1(r)&&("Symbol("===String(l).slice(0,7)&&(l="["+String(l).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!hasOwn$2(r,"name")||CONFIGURABLE_FUNCTION_NAME&&r.name!==l)&&createNonEnumerableProperty$1(r,"name",l),(o=enforceInternalState(r)).source||(o.source=TEMPLATE.join("string"==typeof l?l:""))),e!==global$2?(i?!c&&e[t]&&(a=!0):delete e[t],a?e[t]=r:createNonEnumerableProperty$1(e,t,r)):a?e[t]=r:setGlobal$1(t,r);})(Function.prototype,"toString",(function(){return isCallable$1(this)&&getInternalState(this).source||inspectSource(this)}));var objectGetOwnPropertyNames={},ceil=Math.ceil,floor=Math.floor,toIntegerOrInfinity$3=function(e){var t=+e;return t!=t||0===t?0:(t>0?floor:ceil)(t)},toIntegerOrInfinity$2=toIntegerOrInfinity$3,max=Math.max,min$1=Math.min,toAbsoluteIndex$1=function(e,t){var r=toIntegerOrInfinity$2(e);return r<0?max(r+t,0):min$1(r,t)},toIntegerOrInfinity$1=toIntegerOrInfinity$3,min=Math.min,toLength$1=function(e){return e>0?min(toIntegerOrInfinity$1(e),9007199254740991):0},toLength=toLength$1,lengthOfArrayLike$2=function(e){return toLength(e.length)},toIndexedObject$2=toIndexedObject$4,toAbsoluteIndex=toAbsoluteIndex$1,lengthOfArrayLike$1=lengthOfArrayLike$2,createMethod=function(e){return function(t,r,n){var o,i=toIndexedObject$2(t),a=lengthOfArrayLike$1(i),c=toAbsoluteIndex(n,a);if(e&&r!=r){for(;a>c;)if((o=i[c++])!=o)return !0}else for(;a>c;c++)if((e||c in i)&&i[c]===r)return e||c||0;return !e&&-1}},arrayIncludes={includes:createMethod(!0),indexOf:createMethod(!1)},uncurryThis$1=functionUncurryThis,hasOwn$1=hasOwnProperty_1,toIndexedObject$1=toIndexedObject$4,indexOf=arrayIncludes.indexOf,hiddenKeys$2=hiddenKeys$4,push=uncurryThis$1([].push),objectKeysInternal=function(e,t){var r,n=toIndexedObject$1(e),o=0,i=[];for(r in n)!hasOwn$1(hiddenKeys$2,r)&&hasOwn$1(n,r)&&push(i,r);for(;t.length>o;)hasOwn$1(n,r=t[o++])&&(~indexOf(i,r)||push(i,r));return i},enumBugKeys$3=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],internalObjectKeys$1=objectKeysInternal,enumBugKeys$2=enumBugKeys$3,hiddenKeys$1=enumBugKeys$2.concat("length","prototype");objectGetOwnPropertyNames.f=Object.getOwnPropertyNames||function(e){return internalObjectKeys$1(e,hiddenKeys$1)};var objectGetOwnPropertySymbols={};objectGetOwnPropertySymbols.f=Object.getOwnPropertySymbols;var activeXDocument,getBuiltIn$1=getBuiltIn$4,uncurryThis=functionUncurryThis,getOwnPropertyNamesModule=objectGetOwnPropertyNames,getOwnPropertySymbolsModule=objectGetOwnPropertySymbols,anObject$2=anObject$4,concat=uncurryThis([].concat),ownKeys$2=getBuiltIn$1("Reflect","ownKeys")||function(e){var t=getOwnPropertyNamesModule.f(anObject$2(e)),r=getOwnPropertySymbolsModule.f;return r?concat(t,r(e)):t},hasOwn=hasOwnProperty_1,ownKeys$1=ownKeys$2,getOwnPropertyDescriptorModule=objectGetOwnPropertyDescriptor,definePropertyModule$2=objectDefineProperty,copyConstructorProperties$1=function(e,t){for(var r=ownKeys$1(t),n=definePropertyModule$2.f,o=getOwnPropertyDescriptorModule.f,i=0;i<r.length;i++){var a=r[i];hasOwn(e,a)||n(e,a,o(t,a));}},fails=fails$5,isCallable=isCallable$9,replacement=/#|\.prototype\./,isForced$1=function(e,t){var r=data[normalize(e)];return r==POLYFILL||r!=NATIVE&&(isCallable(t)?fails(t):!!t)},normalize=isForced$1.normalize=function(e){return String(e).replace(replacement,".").toLowerCase()},data=isForced$1.data={},NATIVE=isForced$1.NATIVE="N",POLYFILL=isForced$1.POLYFILL="P",isForced_1=isForced$1,global$1=global$l,getOwnPropertyDescriptor=objectGetOwnPropertyDescriptor.f,createNonEnumerableProperty=createNonEnumerableProperty$3,redefine=redefine$1.exports,setGlobal=setGlobal$3,copyConstructorProperties=copyConstructorProperties$1,isForced=isForced_1,_export=function(e,t){var r,n,o,i,a,c=e.target,l=e.global,u=e.stat;if(r=l?global$1:u?global$1[c]||setGlobal(c,{}):(global$1[c]||{}).prototype)for(n in t){if(i=t[n],o=e.noTargetGet?(a=getOwnPropertyDescriptor(r,n))&&a.value:r[n],!isForced(l?n:c+(u?".":"#")+n,e.forced)&&void 0!==o){if(typeof i==typeof o)continue;copyConstructorProperties(i,o);}(e.sham||o&&o.sham)&&createNonEnumerableProperty(i,"sham",!0),redefine(r,n,i,e);}},internalObjectKeys=objectKeysInternal,enumBugKeys$1=enumBugKeys$3,objectKeys$1=Object.keys||function(e){return internalObjectKeys(e,enumBugKeys$1)},DESCRIPTORS=descriptors,definePropertyModule$1=objectDefineProperty,anObject$1=anObject$4,toIndexedObject=toIndexedObject$4,objectKeys=objectKeys$1,objectDefineProperties=DESCRIPTORS?Object.defineProperties:function(e,t){anObject$1(e);for(var r,n=toIndexedObject(t),o=objectKeys(t),i=o.length,a=0;i>a;)definePropertyModule$1.f(e,r=o[a++],n[r]);return e},getBuiltIn=getBuiltIn$4,html$1=getBuiltIn("document","documentElement"),anObject=anObject$4,defineProperties=objectDefineProperties,enumBugKeys=enumBugKeys$3,hiddenKeys=hiddenKeys$4,html=html$1,documentCreateElement=documentCreateElement$1,sharedKey=sharedKey$2,GT=">",LT="<",PROTOTYPE="prototype",SCRIPT="script",IE_PROTO=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return LT+SCRIPT+GT+e+LT+"/"+SCRIPT+GT},NullProtoObjectViaActiveX=function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t},NullProtoObjectViaIFrame=function(){var e,t=documentCreateElement("iframe"),r="java"+SCRIPT+":";return t.style.display="none",html.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F},NullProtoObject=function(){try{activeXDocument=new ActiveXObject("htmlfile");}catch(t){}NullProtoObject="undefined"!=typeof document?document.domain&&activeXDocument?NullProtoObjectViaActiveX(activeXDocument):NullProtoObjectViaIFrame():NullProtoObjectViaActiveX(activeXDocument);for(var e=enumBugKeys.length;e--;)delete NullProtoObject[PROTOTYPE][enumBugKeys[e]];return NullProtoObject()};hiddenKeys[IE_PROTO]=!0;var objectCreate=Object.create||function(e,t){var r;return null!==e?(EmptyConstructor[PROTOTYPE]=anObject(e),r=new EmptyConstructor,EmptyConstructor[PROTOTYPE]=null,r[IE_PROTO]=e):r=NullProtoObject(),void 0===t?r:defineProperties(r,t)},wellKnownSymbol=wellKnownSymbol$2,create=objectCreate,definePropertyModule=objectDefineProperty,UNSCOPABLES=wellKnownSymbol("unscopables"),ArrayPrototype=Array.prototype;null==ArrayPrototype[UNSCOPABLES]&&definePropertyModule.f(ArrayPrototype,UNSCOPABLES,{configurable:!0,value:create(null)});var addToUnscopables$1=function(e){ArrayPrototype[UNSCOPABLES][e]=!0;},$=_export,toObject=toObject$2,lengthOfArrayLike=lengthOfArrayLike$2,toIntegerOrInfinity=toIntegerOrInfinity$3,addToUnscopables=addToUnscopables$1;function _asyncIterator(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new AsyncFromSyncIterator(t.call(e));r="@@asyncIterator",n="@@iterator";}throw new TypeError("Object is not async iterable")}function AsyncFromSyncIterator(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return {value:e,done:t}}))}return AsyncFromSyncIterator=function(e){this.s=e,this.n=e.next;},AsyncFromSyncIterator.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AsyncFromSyncIterator(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _AwaitValue(e){this.wrapped=e;}function _AsyncGenerator(e){var t,r;function n(t,r){try{var i=e[t](r),a=i.value,c=a instanceof _AwaitValue;Promise.resolve(c?a.wrapped:a).then((function(e){c?n("return"===t?"return":"next",e):o(i.done?"return":"normal",e);}),(function(e){n("throw",e);}));}catch(l){o("throw",l);}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1});}(t=t.next)?n(t.key,t.arg):r=null;}this._invoke=function(e,o){return new Promise((function(i,a){var c={key:e,arg:o,resolve:i,reject:a,next:null};r?r=r.next=c:(t=r=c,n(e,o));}))},"function"!=typeof e.return&&(this.return=void 0);}function _wrapAsyncGenerator(e){return function(){return new _AsyncGenerator(e.apply(this,arguments))}}function _awaitAsyncGenerator(e){return new _AwaitValue(e)}function _asyncGeneratorDelegate(e,t){var r={},n=!1;function o(r,o){return n=!0,o=new Promise((function(t){t(e[r](o));})),{done:!1,value:t(o)}}return r["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},r.next=function(e){return n?(n=!1,e):o("next",e)},"function"==typeof e.throw&&(r.throw=function(e){if(n)throw n=!1,e;return o("throw",e)}),"function"==typeof e.return&&(r.return=function(e){return n?(n=!1,e):o("return",e)}),r}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value;}catch(u){return void r(u)}c.done?t(l):Promise.resolve(l).then(n,o);}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){asyncGeneratorStep(i,n,o,a,c,"next",e);}function c(e){asyncGeneratorStep(i,n,o,a,c,"throw",e);}a(void 0);}))}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t);}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return !1}}function _construct(e,t,r){return _construct=_isNativeReflectConstruct()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&_setPrototypeOf(o,r.prototype),o},_construct.apply(null,arguments)}function _isNativeFunction(e){return -1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r);}function r(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,e)},_wrapNativeSuper(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var o=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,o);}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(e,t,r){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=_superPropBase(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(r):o.value}},_get(e,t,r||e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toArray(e){return _arrayWithHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(l){c=!0,o=l;}finally{try{a||null==r.return||r.return();}finally{if(c)throw o}}return i}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return {s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return {s:function(){r=r.call(e);},n:function(){var e=r.next();return a=e.done,e},e:function(e){c=!0,i=e;},f:function(){try{a||null==r.return||r.return();}finally{if(c)throw i}}}}function _classPrivateFieldGet(e,t){return _classApplyDescriptorGet(e,_classExtractFieldDescriptor(e,t,"get"))}function _classPrivateFieldSet(e,t,r){return _classApplyDescriptorSet(e,_classExtractFieldDescriptor(e,t,"set"),r),r}function _classExtractFieldDescriptor(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function _classApplyDescriptorGet(e,t){return t.get?t.get.call(e):t.value}function _classApplyDescriptorSet(e,t,r){if(t.set)t.set.call(e,r);else {if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r;}}function _classPrivateMethodGet(e,t,r){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return r}function _checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateFieldInitSpec(e,t,r){_checkPrivateRedeclaration(e,t),t.set(e,r);}function _classPrivateMethodInitSpec(e,t){_checkPrivateRedeclaration(e,t),t.add(e);}$({target:"Array",proto:!0},{at:function(e){var t=toObject(this),r=lengthOfArrayLike(t),n=toIntegerOrInfinity(e),o=n>=0?n:r+n;return o<0||o>=r?void 0:t[o]}}),addToUnscopables("at"),_AsyncGenerator.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},_AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)},_AsyncGenerator.prototype.throw=function(e){return this._invoke("throw",e)},_AsyncGenerator.prototype.return=function(e){return this._invoke("return",e)};var _this=this;"undefined"==typeof GM&&(commonjsGlobal.GM={}),"undefined"==typeof GM_addStyle&&(commonjsGlobal.GM_addStyle=function(e){var t=document.getElementsByTagName("head")[0];if(t){var r=document.createElement("style");return r.setAttribute("type","text/css"),r.textContent=e,t.appendChild(r),r}return null}),"undefined"==typeof GM_registerMenuCommand&&(commonjsGlobal.GM_registerMenuCommand=function(e,t,r){if(document.body){var n=document.body.getAttribute("contextmenu"),o=n?document.querySelector("menu#"+n):null;o||((o=document.createElement("menu")).setAttribute("id","gm-registered-menu"),o.setAttribute("type","context"),document.body.appendChild(o),document.body.setAttribute("contextmenu","gm-registered-menu"));var i=document.createElement("menuitem");i.textContent=e,i.addEventListener("click",t,!0),o.appendChild(i);}else "loading"===document.readyState&&document.documentElement&&"html"===document.documentElement.localName?new MutationObserver((function(n,o){document.body&&(o.disconnect(),GM_registerMenuCommand(e,t,r));})).observe(document.documentElement,{childList:!0}):console.error("GM_registerMenuCommand got no body.");}),"undefined"==typeof GM_getResourceText&&(commonjsGlobal.GM_getResourceText=function(e){return GM.getResourceUrl(e).then((function(e){return fetch(e)})).then((function(e){return e.text()})).catch((function(e){return GM.log("Request failed",e),null}))}),Object.entries({log:console.log.bind(console),info:GM_info}).forEach((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];n&&void 0===GM[r]&&(GM[r]=n);})),Object.entries({GM_addStyle:"addStyle",GM_deleteValue:"deleteValue",GM_getResourceURL:"getResourceUrl",GM_getValue:"getValue",GM_listValues:"listValues",GM_notification:"notification",GM_openInTab:"openInTab",GM_registerMenuCommand:"registerMenuCommand",GM_setClipboard:"setClipboard",GM_setValue:"setValue",GM_xmlhttpRequest:"xmlHttpRequest",GM_getResourceText:"getResourceText"}).forEach((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1],o=_this[r];o&&void 0===GM[n]&&(GM[n]=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return new Promise((function(t,n){try{t(o.apply(e,r));}catch(i){n(i);}}))});}));var appendChildren=function(e,t){(t=Array.isArray(t)?t:[t]).forEach((function(t){t instanceof HTMLElement?e.appendChild(t):(t||"string"==typeof t)&&e.appendChild(document.createTextNode(t.toString()));}));},setStyles=function(e,t){for(var r in t)e.style[r]=t[r];},runtime={exports:{}};!function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"");}catch(C){l=function(e,t,r){return e[t]=r};}function u(e,t,r,n){var o=t&&t.prototype instanceof h?t:h,i=Object.create(o.prototype),a=new j(n||[]);return i._invoke=function(e,t,r){var n=f;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===b){if("throw"===o)throw i;return A()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=P(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=b,r.arg;r.dispatchException(r.arg);}else "return"===r.method&&r.abrupt("return",r.arg);n=p;var l=s(e,t,r);if("normal"===l.type){if(n=r.done?b:y,l.arg===d)continue;return {value:l.arg,done:r.done}}"throw"===l.type&&(n=b,r.method="throw",r.arg=l.arg);}}}(e,r,a),i}function s(e,t,r){try{return {type:"normal",arg:e.call(t,r)}}catch(C){return {type:"throw",arg:C}}}e.wrap=u;var f="suspendedStart",y="suspendedYield",p="executing",b="completed",d={};function h(){}function $(){}function m(){}var g={};l(g,i,(function(){return this}));var O=Object.getPrototypeOf,v=O&&O(O(I([])));v&&v!==r&&n.call(v,i)&&(g=v);var S=m.prototype=h.prototype=Object.create(g);function _(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}));}));}function w(e,t){function r(o,i,a,c){var l=s(e[o],e,i);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"===_typeof(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,c);}),(function(e){r("throw",e,a,c);})):t.resolve(f).then((function(e){u.value=e,a(u);}),(function(e){return r("throw",e,a,c)}))}c(l.arg);}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o);}))}return o=o?o.then(i,i):i()};}function P(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method");}return d}var o=s(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t);}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t;}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0);}function I(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return {next:A}}function A(){return {value:t,done:!0}}return $.prototype=m,l(S,"constructor",m),l(m,"constructor",$),$.displayName=l(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return !!t&&(t===$||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,c,"GeneratorFunction")),e.prototype=Object.create(S),e},e.awrap=function(e){return {__await:e}},_(w.prototype),l(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(S),l(S,c,"Generator"),l(S,i,(function(){return this})),l(S,"toString",(function(){return "[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=I,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t);},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else {if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return "break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r);}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}(e.exports);try{regeneratorRuntime=t;}catch(r){"object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t);}}(runtime);var regenerator=runtime.exports;function fixProto(e,t){var r=Object.setPrototypeOf;r?r(e,t):e.__proto__=t;}function fixStack(e,t){void 0===t&&(t=e.constructor);var r=Error.captureStackTrace;r&&r(e,t);}var __extends=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);},e(t,r)};return function(t,r){function n(){this.constructor=t;}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n);}}(),CustomError=function(e){function t(t){var r=this.constructor,n=e.call(this,t)||this;return Object.defineProperty(n,"name",{value:r.name,enumerable:!1,configurable:!0}),fixProto(n,r.prototype),fixStack(n),n}return __extends(t,e),t}(Error),AbortError=function(e){_inherits(r,_wrapNativeSuper(Error));var t=_createSuper(r);function r(){var e;return _classCallCheck(this,r),(e=t.call(this,"Throttled function aborted")).name="AbortError",e}return r}();function pThrottle(e){var t=e.limit,r=e.interval,n=e.strict;if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(r))throw new TypeError("Expected `interval` to be a finite number");var o=new Map,i=0,a=0,c=[],l=n?function(){var e=Date.now();if(c.length<t)return c.push(e),0;var n=c.shift()+r;return e>=n?(c.push(e),0):(c.push(n),n-e)}:function(){var e=Date.now();return e-i>r?(a=1,i=e,0):(a<t?a++:(i+=r,a=1),i-e)};return function(e){var t=function t(){for(var r,n=this,i=arguments.length,a=new Array(i),c=0;c<i;c++)a[c]=arguments[c];return t.isEnabled?new Promise((function(t,i){r=setTimeout((function(){t(e.apply(n,a)),o.delete(r);}),l()),o.set(r,i);})):_asyncToGenerator(regenerator.mark((function t(){return regenerator.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.apply(n,a));case 1:case"end":return t.stop()}}),t)})))()};return t.abort=function(){var e,t=_createForOfIteratorHelper(o.keys());try{for(t.s();!(e=t.n()).done;){var r=e.value;clearTimeout(r),o.get(r)(new AbortError);}}catch(n){t.e(n);}finally{t.f();}o.clear(),c.splice(0,c.length);},t.isEnabled=!0,t}}
/* minified: lib */
var LogLevel,_HANDLER_NAMES;!function(e){e[e.DEBUG=0]="DEBUG",e[e.LOG=1]="LOG",e[e.INFO=2]="INFO",e[e.SUCCESS=3]="SUCCESS",e[e.WARNING=4]="WARNING",e[e.ERROR=5]="ERROR";}(LogLevel||(LogLevel={}));var HANDLER_NAMES=(_defineProperty(_HANDLER_NAMES={},LogLevel.DEBUG,"onDebug"),_defineProperty(_HANDLER_NAMES,LogLevel.LOG,"onLog"),_defineProperty(_HANDLER_NAMES,LogLevel.INFO,"onInfo"),_defineProperty(_HANDLER_NAMES,LogLevel.SUCCESS,"onSuccess"),_defineProperty(_HANDLER_NAMES,LogLevel.WARNING,"onWarn"),_defineProperty(_HANDLER_NAMES,LogLevel.ERROR,"onError"),_HANDLER_NAMES),DEFAULT_OPTIONS={logLevel:LogLevel.INFO,sinks:[]},_configuration=new WeakMap,_fireHandlers=new WeakSet,Logger=function(){function e(t){_classCallCheck(this,e),_classPrivateMethodInitSpec(this,_fireHandlers),_classPrivateFieldInitSpec(this,_configuration,{writable:!0,value:void 0}),_classPrivateFieldSet(this,_configuration,_objectSpread2(_objectSpread2({},DEFAULT_OPTIONS),t));}return _createClass(e,[{key:"debug",value:function(e){_classPrivateMethodGet(this,_fireHandlers,_fireHandlers2).call(this,LogLevel.DEBUG,e);}},{key:"log",value:function(e){_classPrivateMethodGet(this,_fireHandlers,_fireHandlers2).call(this,LogLevel.LOG,e);}},{key:"info",value:function(e){_classPrivateMethodGet(this,_fireHandlers,_fireHandlers2).call(this,LogLevel.INFO,e);}},{key:"success",value:function(e){_classPrivateMethodGet(this,_fireHandlers,_fireHandlers2).call(this,LogLevel.SUCCESS,e);}},{key:"warn",value:function(e,t){_classPrivateMethodGet(this,_fireHandlers,_fireHandlers2).call(this,LogLevel.WARNING,e,t);}},{key:"error",value:function(e,t){_classPrivateMethodGet(this,_fireHandlers,_fireHandlers2).call(this,LogLevel.ERROR,e,t);}},{key:"configure",value:function(e){Object.assign(_classPrivateFieldGet(this,_configuration),e);}},{key:"configuration",get:function(){return _classPrivateFieldGet(this,_configuration)}},{key:"addSink",value:function(e){_classPrivateFieldGet(this,_configuration).sinks.push(e);}}]),e}();function _fireHandlers2(e,t,r){e<_classPrivateFieldGet(this,_configuration).logLevel||_classPrivateFieldGet(this,_configuration).sinks.forEach((function(a){var n=a[HANDLER_NAMES[e]];n&&(r?n.call(a,t,r):n.call(a,t));}));}var LOGGER=new Logger,_scriptName=new WeakMap,_formatMessage=new WeakSet,ConsoleSink=function(){function e(t){_classCallCheck(this,e),_classPrivateMethodInitSpec(this,_formatMessage),_classPrivateFieldInitSpec(this,_scriptName,{writable:!0,value:void 0}),_defineProperty(this,"onSuccess",this.onInfo),_classPrivateFieldSet(this,_scriptName,t);}return _createClass(e,[{key:"onDebug",value:function(e){console.debug(_classPrivateMethodGet(this,_formatMessage,_formatMessage2).call(this,e));}},{key:"onLog",value:function(e){console.log(_classPrivateMethodGet(this,_formatMessage,_formatMessage2).call(this,e));}},{key:"onInfo",value:function(e){console.info(_classPrivateMethodGet(this,_formatMessage,_formatMessage2).call(this,e));}},{key:"onWarn",value:function(e,t){e=_classPrivateMethodGet(this,_formatMessage,_formatMessage2).call(this,e),t?console.warn(e,t):console.warn(e);}},{key:"onError",value:function(e,t){e=_classPrivateMethodGet(this,_formatMessage,_formatMessage2).call(this,e),t?console.error(e,t):console.error(e);}}]),e}();function _formatMessage2(e){return "[".concat(_classPrivateFieldGet(this,_scriptName),"] ").concat(e)}var AssertionError=function(e){_inherits(r,e);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return r}(_wrapNativeSuper(Error));function assert(e,t){if(!e)throw new AssertionError(null!=t?t:"Assertion failed")}function assertDefined(e,t){assert(void 0!==e,null!=t?t:"Assertion failed: Expected value to be defined");}function assertNonNull(e,t){assert(null!==e,null!=t?t:"Assertion failed: Expected value to be non-null");}function assertHasValue(e,t){assert(null!=e,null!=t?t:"Assertion failed: Expected value to be defined and non-null");}function qs(e,t){var r=qsMaybe(e,t);return assertNonNull(r,"Could not find required element"),r}function qsMaybe(e,t){return (null!=t?t:document).querySelector(e)}function qsa(e,t){var r=null!=t?t:document;return _toConsumableArray(r.querySelectorAll(e))}function parseDOM(e,t){var r=(new DOMParser).parseFromString(e,"text/html");if(!qsMaybe("base",r.head)){var a=r.createElement("base");a.href=t,r.head.insertAdjacentElement("beforeend",a);}return r}function safeParseJSON(e,t){try{return JSON.parse(e)}catch(r){if(t)throw new Error(t+": "+r);return}}function getReleaseUrlARs(e){return _getReleaseUrlARs.apply(this,arguments)}function _getReleaseUrlARs(){return (_getReleaseUrlARs=_asyncToGenerator(regenerator.mark((function e(t){var r,a,n;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://musicbrainz.org/ws/2/release/".concat(t,"?inc=url-rels&fmt=json"));case 2:return a=e.sent,e.next=5,a.json();case 5:return n=e.sent,e.abrupt("return",null!==(r=n.relations)&&void 0!==r?r:[]);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function getURLsForRelease(e,t){return _getURLsForRelease.apply(this,arguments)}function _getURLsForRelease(){return (_getURLsForRelease=_asyncToGenerator(regenerator.mark((function e(t,r){var a,n,s,i,o;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(a=null!=r?r:{}).excludeEnded,s=a.excludeDuplicates,e.next=3,getReleaseUrlARs(t);case 3:return i=e.sent,n&&(i=i.filter((function(e){return !e.ended}))),o=i.map((function(e){return e.url.resource})),s&&(o=Array.from(new Set(_toConsumableArray(o)))),e.abrupt("return",o.flatMap((function(e){try{return [new URL(e)]}catch(t){return console.warn("Found malformed URL linked to release: ".concat(e)),[]}})));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function getReleaseIDsForURL(e){return _getReleaseIDsForURL.apply(this,arguments)}function _getReleaseIDsForURL(){return (_getReleaseIDsForURL=_asyncToGenerator(regenerator.mark((function e(t){var r,a,n,s;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://musicbrainz.org/ws/2/url?resource=".concat(encodeURIComponent(t),"&inc=release-rels&fmt=json"));case 2:return n=e.sent,e.next=5,n.json();case 5:return s=e.sent,e.abrupt("return",null!==(r=null===(a=s.relations)||void 0===a?void 0:a.map((function(e){return e.release.id})))&&void 0!==r?r:[]);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ResponseError=function(e){_inherits(r,CustomError);var t=_createSuper(r);function r(e,a){var n;return _classCallCheck(this,r),n=t.call(this,a),_defineProperty(_assertThisInitialized(n),"url",void 0),n.url=e,n}return r}(),HTTPResponseError=function(e){_inherits(r,ResponseError);var t=_createSuper(r);function r(e,a){var n;return _classCallCheck(this,r),a.statusText.trim()?(n=t.call(this,e,"HTTP error ".concat(a.status,": ").concat(a.statusText)),_defineProperty(_assertThisInitialized(n),"statusCode",void 0),_defineProperty(_assertThisInitialized(n),"statusText",void 0),_defineProperty(_assertThisInitialized(n),"response",void 0)):(n=t.call(this,e,"HTTP error ".concat(a.status)),_defineProperty(_assertThisInitialized(n),"statusCode",void 0),_defineProperty(_assertThisInitialized(n),"statusText",void 0),_defineProperty(_assertThisInitialized(n),"response",void 0)),n.response=a,n.statusCode=a.status,n.statusText=a.statusText,_possibleConstructorReturn(n)}return r}(),TimeoutError=function(e){_inherits(r,ResponseError);var t=_createSuper(r);function r(e){return _classCallCheck(this,r),t.call(this,e,"Request timed out")}return r}(),AbortedError=function(e){_inherits(r,ResponseError);var t=_createSuper(r);function r(e){return _classCallCheck(this,r),t.call(this,e,"Request aborted")}return r}(),NetworkError=function(e){_inherits(r,ResponseError);var t=_createSuper(r);function r(e){return _classCallCheck(this,r),t.call(this,e,"Network error")}return r}();function gmxhr(e,t){return _gmxhr.apply(this,arguments)}function _gmxhr(){return (_gmxhr=_asyncToGenerator(regenerator.mark((function e(t,r){return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,a){GM.xmlHttpRequest(_objectSpread2(_objectSpread2({method:"GET",url:t instanceof URL?t.href:t},null!=r?r:{}),{},{onload:function(r){r.status>=400?a(new HTTPResponseError(t,r)):e(r);},onerror:function(){a(new NetworkError(t));},onabort:function(){a(new AbortedError(t));},ontimeout:function(){a(new TimeoutError(t));}}));})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function filterNonNull(e){return e.filter((function(e){return !(null==e)}))}function groupBy(e,t,r){var a,n=new Map,s=_createForOfIteratorHelper(e);try{for(s.s();!(a=s.n()).done;){var i,o=a.value,l=t(o),c=r(o);n.has(l)?null===(i=n.get(l))||void 0===i||i.push(c):n.set(l,[c]);}}catch(u){s.e(u);}finally{s.f();}return n}function hexEncode(e){return _toConsumableArray(new Uint8Array(e)).map((function(e){return e.toString(16).padStart(2,"0")})).join("")}function blobToDigest(e){return new Promise((function(t,r){var a=new FileReader;a.addEventListener("error",r),a.addEventListener("load",_asyncToGenerator(regenerator.mark((function e(){var r,n;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.result,"undefined"==typeof crypto||void 0===(null===(r=crypto.subtle)||void 0===r?void 0:r.digest)){e.next=12;break}return e.t0=t,e.t1=hexEncode,e.next=7,crypto.subtle.digest("SHA-256",n);case 7:e.t2=e.sent,e.t3=(0, e.t1)(e.t2),(0, e.t0)(e.t3),e.next=13;break;case 12:t(hexEncode(n));case 13:case"end":return e.stop()}}),e)})))),a.readAsArrayBuffer(e);}))}var separator="\n–\n",_footer=new WeakMap,_extraInfoLines=new WeakMap,_editNoteTextArea=new WeakMap,_removePreviousFooter=new WeakSet,EditNote=function(){function e(t){_classCallCheck(this,e),_classPrivateMethodInitSpec(this,_removePreviousFooter),_classPrivateFieldInitSpec(this,_footer,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_extraInfoLines,{writable:!0,value:void 0}),_classPrivateFieldInitSpec(this,_editNoteTextArea,{writable:!0,value:void 0}),_classPrivateFieldSet(this,_footer,t),_classPrivateFieldSet(this,_editNoteTextArea,qs("textarea.edit-note"));var r=_classPrivateFieldGet(this,_editNoteTextArea).value.split(separator)[0];_classPrivateFieldSet(this,_extraInfoLines,r?new Set(r.split("\n").map((function(e){return e.trimRight()}))):new Set);}return _createClass(e,[{key:"addExtraInfo",value:function(e){if(!_classPrivateFieldGet(this,_extraInfoLines).has(e)){var t=_classPrivateFieldGet(this,_editNoteTextArea).value.split(separator),r=_toArray(t),a=r[0],n=r.slice(1);a=(a+"\n"+e).trim(),_classPrivateFieldGet(this,_editNoteTextArea).value=[a].concat(_toConsumableArray(n)).join(separator),_classPrivateFieldGet(this,_extraInfoLines).add(e);}}},{key:"addFooter",value:function(){_classPrivateMethodGet(this,_removePreviousFooter,_removePreviousFooter2).call(this);var e=_classPrivateFieldGet(this,_editNoteTextArea).value;_classPrivateFieldGet(this,_editNoteTextArea).value=[e,separator,_classPrivateFieldGet(this,_footer)].join("");}}],[{key:"withFooterFromGMInfo",value:function(){var t=GM.info.script;return new e("".concat(t.name," ").concat(t.version,"\n").concat(t.namespace))}}]),e}();function _removePreviousFooter2(){var e=this,t=_classPrivateFieldGet(this,_editNoteTextArea).value.split(separator).filter((function(t){return t.trim()!==_classPrivateFieldGet(e,_footer)}));_classPrivateFieldGet(this,_editNoteTextArea).value=t.join(separator);}function splitDomain(e){var t=e.split("."),r=-2;return ["org","co","com"].includes(t.at(-2))&&(r=-3),t.slice(0,r).concat([t.slice(r).join(".")])}var _map=new WeakMap,_insertLeaf=new WeakSet,_insertInternal=new WeakSet,_insert=new WeakSet,_retrieveLeaf=new WeakSet,_retrieveInternal=new WeakSet,_retrieve=new WeakSet,DispatchMap=function(){function e(){_classCallCheck(this,e),_classPrivateMethodInitSpec(this,_retrieve),_classPrivateMethodInitSpec(this,_retrieveInternal),_classPrivateMethodInitSpec(this,_retrieveLeaf),_classPrivateMethodInitSpec(this,_insert),_classPrivateMethodInitSpec(this,_insertInternal),_classPrivateMethodInitSpec(this,_insertLeaf),_classPrivateFieldInitSpec(this,_map,{writable:!0,value:new Map});}return _createClass(e,[{key:"set",value:function(e,t){var r=splitDomain(e);if("*"===e||r[0].includes("*")&&"*"!==r[0]||r.slice(1).some((function(e){return e.includes("*")})))throw new Error("Invalid pattern: "+e);return _classPrivateMethodGet(this,_insert,_insert2).call(this,r.slice().reverse(),t),this}},{key:"get",value:function(e){return _classPrivateMethodGet(this,_retrieve,_retrieve2).call(this,splitDomain(e).slice().reverse())}},{key:"_get",value:function(e){return _classPrivateFieldGet(this,_map).get(e)}},{key:"_set",value:function(e,t){return _classPrivateFieldGet(this,_map).set(e,t),this}}]),e}();function _insertLeaf2(e,t){var r=this._get(e);r?(assert(r instanceof DispatchMap&&!_classPrivateFieldGet(r,_map).has(""),"Duplicate leaf!"),r._set("",t)):this._set(e,t);}function _insertInternal2(e,t){var r,a,n=e[0],s=this._get(n);s instanceof DispatchMap?a=s:(a=new DispatchMap,this._set(n,a),void 0!==s&&a._set("",s)),_classPrivateMethodGet(r=a,_insert,_insert2).call(r,e.slice(1),t);}function _insert2(e,t){e.length>1?_classPrivateMethodGet(this,_insertInternal,_insertInternal2).call(this,e,t):(assert(1===e.length,"Empty domain parts?!"),_classPrivateMethodGet(this,_insertLeaf,_insertLeaf2).call(this,e[0],t));}function _retrieveLeaf2(e){var t=this._get(e);if(t instanceof DispatchMap){var r=t._get("");void 0===r&&(r=t._get("*")),t=r;}return t}function _retrieveInternal2(e){var t=this._get(e[0]);if(t instanceof DispatchMap)return _classPrivateMethodGet(t,_retrieve,_retrieve2).call(t,e.slice(1))}function _retrieve2(e){var t;return void 0===(t=1===e.length?_classPrivateMethodGet(this,_retrieveLeaf,_retrieveLeaf2).call(this,e[0]):_classPrivateMethodGet(this,_retrieveInternal,_retrieveInternal2).call(this,e))&&(t=this._get("*")),t}function createPersistentCheckbox(e,t,r){return [function(){var t=document.createElement("input");return t.setAttribute("type","checkbox"),t.setAttribute("id",e),t.addEventListener("change",(function(t){t.currentTarget.checked?localStorage.setItem(e,"delete_to_disable"):localStorage.removeItem(e),r(t);})),t.setAttribute("defaultChecked",!!localStorage.getItem(e)),t}.call(this),function(){var r=document.createElement("label");return r.setAttribute("for",e),appendChildren(r,t),r}.call(this)]}function retryTimes(e,t,r){return _retryTimes.apply(this,arguments)}function _retryTimes(){return (_retryTimes=_asyncToGenerator(regenerator.mark((function e(t,r,a){return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r<=0)){e.next=2;break}return e.abrupt("return",Promise.reject(new TypeError("Invalid number of retry times: "+r)));case 2:return e.abrupt("return",new Promise((function(e,n){function s(){try{e(t());}catch(a){if(--r>0)return;n(a);}clearInterval(i);}var i=setInterval(s,a);s();})));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function cloneIntoPageContext(e){return "undefined"!=typeof cloneInto&&"undefined"!=typeof unsafeWindow?cloneInto(e,unsafeWindow):e}function getFromPageContext(e){return "undefined"!=typeof unsafeWindow?unsafeWindow[e]:window[e]}
var USERSCRIPT_NAME = "mb_enhanced_cover_art_uploads";
// TODO: This originates from mb_caa_dimensions but is also used here. Not sure
// where to put it. It might make sense to put it in the mb_caa_dimensions source
// tree later on, and import it in this source tree where necessary.
function getImageDimensions(url) {
return new Promise(function (resolve, reject) {
var done = false;
function dimensionsLoaded(dimensions) {
// Make sure we don't poll again, it's not necessary.
clearInterval(interval);
if (!done) {
// Prevent resolving twice.
resolve(dimensions);
done = true;
img.src = ''; // Cancel loading the image
}
}
function dimensionsFailed() {
clearInterval(interval);
if (!done) {
done = true;
reject();
}
}
var img = document.createElement('img');
img.addEventListener('load', function () {
dimensionsLoaded({
height: img.naturalHeight,
width: img.naturalWidth
});
});
img.addEventListener('error', dimensionsFailed); // onload and onerror are asynchronous, so this interval should have
// already been set before they are called.
var interval = window.setInterval(function () {
if (img.naturalHeight) {
// naturalHeight will be non-zero as soon as enough of the image
// is loaded to determine its dimensions.
dimensionsLoaded({
height: img.naturalHeight,
width: img.naturalWidth
});
}
}, 50); // Start loading the image
img.src = url;
});
}
function encodeValue(value) {
if (value instanceof URL) return value.href;
if (typeof value === 'string') return value;
return JSON.stringify(value);
}
function decodeSingleKeyValue(key, value, images) {
var _key$match;
var keyName = key.split('.').at(-1);
var imageIdxString = (_key$match = key.match(/x_seed\.image\.(\d+)\./)) === null || _key$match === void 0 ? void 0 : _key$match[1];
if (!imageIdxString || !['url', 'types', 'comment'].includes(keyName)) {
throw new Error("Unsupported seeded key: ".concat(key));
}
var imageIdx = parseInt(imageIdxString);
if (!images[imageIdx]) {
images[imageIdx] = {};
}
if (keyName === 'url') {
images[imageIdx].url = new URL(value);
} else if (keyName === 'types') {
var types = safeParseJSON(value);
if (!Array.isArray(types) || types.some(function (type) {
return typeof type !== 'number';
})) {
throw new Error("Invalid 'types' parameter: ".concat(value));
}
images[imageIdx].types = types;
} else {
images[imageIdx].comment = value;
}
}
var SeedParameters = /*#__PURE__*/function () {
function SeedParameters(images, origin) {
_classCallCheck(this, SeedParameters);
_defineProperty(this, "images", void 0);
_defineProperty(this, "origin", void 0);
this.images = images !== null && images !== void 0 ? images : [];
this.origin = origin;
}
_createClass(SeedParameters, [{
key: "addImage",
value: function addImage(image) {
this.images.push(image);
}
}, {
key: "encode",
value: function encode() {
var seedParams = new URLSearchParams(this.images.flatMap(function (image, index) {
return Object.entries(image).map(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
return ["x_seed.image.".concat(index, ".").concat(key), encodeValue(value)];
});
}));
if (this.origin) {
seedParams.append('x_seed.origin', this.origin);
}
return seedParams;
}
}, {
key: "createSeedURL",
value: function createSeedURL(releaseId) {
return "https://musicbrainz.org/release/".concat(releaseId, "/add-cover-art?").concat(this.encode());
}
}], [{
key: "decode",
value: function decode(seedParams) {
var _seedParams$get;
var images = [];
seedParams.forEach(function (value, key) {
// only image parameters can be decoded to cover art images
if (!key.startsWith('x_seed.image.')) return;
try {
decodeSingleKeyValue(key, value, images);
} catch (err) {
LOGGER.error("Invalid image seeding param ".concat(key, "=").concat(value), err);
}
}); // Sanity checks: Make sure all images have at least a URL, and condense
// the array in case indices are missing.
images = images.filter(function (image, index) {
// URL could be undefined if it either was never given as a param,
// or if it was invalid.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (image.url) {
return true;
} else {
LOGGER.warn("Ignoring seeded image ".concat(index, ": No URL provided"));
return false;
}
});
var origin = (_seedParams$get = seedParams.get('x_seed.origin')) !== null && _seedParams$get !== void 0 ? _seedParams$get : undefined;
return new SeedParameters(images, origin);
}
}]);
return SeedParameters;
}();
var AtisketSeeder = {
supportedDomains: ['atisket.pulsewidth.org.uk'],
supportedRegexes: [/\.uk\/\?.+/],
insertSeedLinks: function insertSeedLinks() {
var _qs$textContent$trim, _qs$textContent, _cachedAnchor$href;
var alreadyInMB = qsMaybe('.already-in-mb-item');
if (alreadyInMB === null) {
return;
}
var mbid = (_qs$textContent$trim = (_qs$textContent = qs('a.mb', alreadyInMB).textContent) === null || _qs$textContent === void 0 ? void 0 : _qs$textContent.trim()) !== null && _qs$textContent$trim !== void 0 ? _qs$textContent$trim : '';
var cachedAnchor = qsMaybe('#submit-button + div > a');
addSeedLinkToCovers(mbid, (_cachedAnchor$href = cachedAnchor === null || cachedAnchor === void 0 ? void 0 : cachedAnchor.href) !== null && _cachedAnchor$href !== void 0 ? _cachedAnchor$href : document.location.href);
}
};
var AtasketSeeder = {
supportedDomains: ['atisket.pulsewidth.org.uk'],
supportedRegexes: [/\.uk\/atasket\.php\?/],
insertSeedLinks: function insertSeedLinks() {
var urlParams = new URLSearchParams(document.location.search);
var mbid = urlParams.get('release_mbid');
var selfId = urlParams.get('self_id');
if (!mbid || !selfId) {
LOGGER.error('Cannot extract IDs! Seeding is disabled :(');
return;
}
var cachedUrl = document.location.origin + '/?cached=' + selfId;
addSeedLinkToCovers(mbid, cachedUrl);
}
};
function addSeedLinkToCovers(mbid, origin) {
qsa('figure.cover').forEach(function (fig) {
addSeedLinkToCover(fig, mbid, origin);
});
}
function addSeedLinkToCover(_x, _x2, _x3) {
return _addSeedLinkToCover.apply(this, arguments);
}
function _addSeedLinkToCover() {
_addSeedLinkToCover = _asyncToGenerator(regenerator.mark(function _callee(fig, mbid, origin) {
var _imageUrl$match, _fig$closest, _qs$insertAdjacentEle;
var imageUrl, ext, imageDimensions, dimensionStr, countryCode, vendorId, vendorCode, releaseUrl, params, seedUrl, dimSpan, seedLink;
return regenerator.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
imageUrl = qs('a.icon', fig).href;
ext = (_imageUrl$match = imageUrl.match(/\.(\w+)$/)) === null || _imageUrl$match === void 0 ? void 0 : _imageUrl$match[1];
_context.next = 4;
return getImageDimensions(imageUrl);
case 4:
imageDimensions = _context.sent;
dimensionStr = ''.concat(imageDimensions.width, 'x').concat(imageDimensions.height);
countryCode = (_fig$closest = fig.closest('div')) === null || _fig$closest === void 0 ? void 0 : _fig$closest.getAttribute('data-matched-country');
vendorId = fig.getAttribute('data-vendor-id');
vendorCode = _toConsumableArray(fig.classList).find(function (klass) {
return [
'spf',
'deez',
'itu'
].includes(klass);
});
if (!(!vendorCode || !vendorId || typeof countryCode !== 'string' || vendorCode === 'itu' && countryCode === '')) {
_context.next = 12;
break;
}
LOGGER.error('Could not extract required data for ' + fig.classList.value);
return _context.abrupt('return');
case 12:
releaseUrl = RELEASE_URL_CONSTRUCTORS[vendorCode](vendorId, countryCode);
params = new SeedParameters([{ url: new URL(releaseUrl) }], origin);
seedUrl = params.createSeedURL(mbid);
dimSpan = function () {
var $$a = document.createElement('span');
setStyles($$a, { display: 'block' });
appendChildren($$a, dimensionStr + (ext ? ' '.concat(ext.toUpperCase()) : ''));
return $$a;
}.call(this);
seedLink = function () {
var $$c = document.createElement('a');
$$c.setAttribute('href', seedUrl);
setStyles($$c, { display: 'block' });
var $$d = document.createTextNode('\n Add to release\n ');
$$c.appendChild($$d);
return $$c;
}.call(this);
(_qs$insertAdjacentEle = qs('figcaption > a', fig).insertAdjacentElement('afterend', dimSpan)) === null || _qs$insertAdjacentEle === void 0 ? void 0 : _qs$insertAdjacentEle.insertAdjacentElement('afterend', seedLink);
case 18:
case 'end':
return _context.stop();
}
}
}, _callee);
}));
return _addSeedLinkToCover.apply(this, arguments);
}
var RELEASE_URL_CONSTRUCTORS = {
itu: function itu(id, country) {
return 'https://music.apple.com/'.concat(country.toLowerCase(), '/album/').concat(id);
},
deez: function deez(id) {
return 'https://www.deezer.com/album/' + id;
},
spf: function spf(id) {
return 'https://open.spotify.com/album/' + id;
}
};
function seederSupportsURL(seeder, url) {
return seeder.supportedDomains.includes(url.hostname.replace(/^www\./, '')) && seeder.supportedRegexes.some(function (rgx) {
return rgx.test(url.href);
});
}
var SEEDER_DISPATCH_MAP = new Map();
function registerSeeder(seeder) {
seeder.supportedDomains.forEach(function (domain) {
if (!SEEDER_DISPATCH_MAP.has(domain)) {
SEEDER_DISPATCH_MAP.set(domain, []);
} // Optional chaining is unnecessary overhead, we just created the entry above
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
SEEDER_DISPATCH_MAP.get(domain).push(seeder);
});
}
function seederFactory(url) {
var _SEEDER_DISPATCH_MAP$;
return (_SEEDER_DISPATCH_MAP$ = SEEDER_DISPATCH_MAP.get(url.hostname.replace(/^www\./, ''))) === null || _SEEDER_DISPATCH_MAP$ === void 0 ? void 0 : _SEEDER_DISPATCH_MAP$.find(function (seeder) {
return seederSupportsURL(seeder, url);
});
}
var CoverArtProvider = /*#__PURE__*/function () {
function CoverArtProvider() {
_classCallCheck(this, CoverArtProvider);
_defineProperty(this, "supportedDomains", void 0);
_defineProperty(this, "name", void 0);
_defineProperty(this, "urlRegex", void 0);
_defineProperty(this, "allowButtons", true);
}
_createClass(CoverArtProvider, [{
key: "postprocessImages",
value:
/**
* Postprocess the fetched images. By default, does nothing, however,
* subclasses can override this to e.g. filter out or merge images after
* they've been fetched.
*/
function postprocessImages(images) {
return images;
}
/**
* Returns a clean version of the given URL.
* This version should be used to match against `urlRegex`.
*/
}, {
key: "cleanUrl",
value: function cleanUrl(url) {
return url.host + url.pathname;
}
/**
* Check whether the provider supports the given URL.
*
* @param {URL} url The provider URL.
* @return {boolean} Whether images can be extracted for this URL.
*/
}, {
key: "supportsUrl",
value: function supportsUrl(url) {
var _this = this;
if (Array.isArray(this.urlRegex)) {
return this.urlRegex.some(function (regex) {
return regex.test(_this.cleanUrl(url));
});
}
return this.urlRegex.test(this.cleanUrl(url));
}
/**
* Extract ID from a release URL.
*/
}, {
key: "extractId",
value: function extractId(url) {
var _this2 = this;
if (!Array.isArray(this.urlRegex)) {
var _this$cleanUrl$match;
return (_this$cleanUrl$match = this.cleanUrl(url).match(this.urlRegex)) === null || _this$cleanUrl$match === void 0 ? void 0 : _this$cleanUrl$match[1];
}
return this.urlRegex.map(function (regex) {
var _this2$cleanUrl$match;
return (_this2$cleanUrl$match = _this2.cleanUrl(url).match(regex)) === null || _this2$cleanUrl$match === void 0 ? void 0 : _this2$cleanUrl$match[1];
}).find(function (id) {
return typeof id !== 'undefined';
});
}
/**
* Check whether a redirect is safe, i.e. both URLs point towards the same
* release.
*/
}, {
key: "isSafeRedirect",
value: function isSafeRedirect(originalUrl, redirectedUrl) {
var id = this.extractId(originalUrl);
return !!id && id === this.extractId(redirectedUrl);
}
}, {
key: "fetchPage",
value: function () {
var _fetchPage = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(url) {
var resp;
return regenerator.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return gmxhr(url);
case 2:
resp = _context.sent;
if (!(resp.finalUrl !== url.href && !this.isSafeRedirect(url, new URL(resp.finalUrl)))) {
_context.next = 5;
break;
}
throw new Error("Refusing to extract images from ".concat(this.name, " provider because the original URL redirected to ").concat(resp.finalUrl, ", which may be a different release. If this redirected URL is correct, please retry with ").concat(resp.finalUrl, " directly."));
case 5:
return _context.abrupt("return", resp.responseText);
case 6:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function fetchPage(_x) {
return _fetchPage.apply(this, arguments);
}
return fetchPage;
}()
}]);
return CoverArtProvider;
}();
var ArtworkTypeIDs;
(function (ArtworkTypeIDs) {
ArtworkTypeIDs[ArtworkTypeIDs["Back"] = 2] = "Back";
ArtworkTypeIDs[ArtworkTypeIDs["Booklet"] = 3] = "Booklet";
ArtworkTypeIDs[ArtworkTypeIDs["Front"] = 1] = "Front";
ArtworkTypeIDs[ArtworkTypeIDs["Liner"] = 12] = "Liner";
ArtworkTypeIDs[ArtworkTypeIDs["Medium"] = 4] = "Medium";
ArtworkTypeIDs[ArtworkTypeIDs["Obi"] = 5] = "Obi";
ArtworkTypeIDs[ArtworkTypeIDs["Other"] = 8] = "Other";
ArtworkTypeIDs[ArtworkTypeIDs["Poster"] = 11] = "Poster";
ArtworkTypeIDs[ArtworkTypeIDs["Raw"] = 14] = "Raw";
ArtworkTypeIDs[ArtworkTypeIDs["Spine"] = 6] = "Spine";
ArtworkTypeIDs[ArtworkTypeIDs["Sticker"] = 10] = "Sticker";
ArtworkTypeIDs[ArtworkTypeIDs["Track"] = 7] = "Track";
ArtworkTypeIDs[ArtworkTypeIDs["Tray"] = 9] = "Tray";
ArtworkTypeIDs[ArtworkTypeIDs["Watermark"] = 13] = "Watermark";
})(ArtworkTypeIDs || (ArtworkTypeIDs = {}));
var HeadMetaPropertyProvider = /*#__PURE__*/function (_CoverArtProvider) {
_inherits(HeadMetaPropertyProvider, _CoverArtProvider);
var _super = _createSuper(HeadMetaPropertyProvider);
function HeadMetaPropertyProvider() {
_classCallCheck(this, HeadMetaPropertyProvider);
return _super.apply(this, arguments);
}
_createClass(HeadMetaPropertyProvider, [{
key: "is404Page",
value: // Providers for which the cover art can be retrieved from the head
// og:image property and maximised using maxurl
/**
* Template method to be used by subclasses to check whether the document
* indicates a missing release. This only needs to be implemented if the
* provider returns success codes for releases which are 404.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function is404Page(_document) {
return false;
}
}, {
key: "findImages",
value: function () {
var _findImages = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(url) {
var respDocument, coverElmt;
return regenerator.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.t0 = parseDOM;
_context2.next = 3;
return this.fetchPage(url);
case 3:
_context2.t1 = _context2.sent;
_context2.t2 = url.href;
respDocument = (0, _context2.t0)(_context2.t1, _context2.t2);
if (!this.is404Page(respDocument)) {
_context2.next = 8;
break;
}
throw new Error(this.name + ' release does not exist');
case 8:
coverElmt = qs('head > meta[property="og:image"]', respDocument);
return _context2.abrupt("return", [{
url: new URL(coverElmt.content),
types: [ArtworkTypeIDs.Front]
}]);
case 10:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function findImages(_x2) {
return _findImages.apply(this, arguments);
}
return findImages;
}()
}]);
return HeadMetaPropertyProvider;
}(CoverArtProvider);
var _groupIdenticalImages = /*#__PURE__*/new WeakSet();
var _urlToDigest = /*#__PURE__*/new WeakSet();
var _createTrackImageComment = /*#__PURE__*/new WeakSet();
var ProviderWithTrackImages = /*#__PURE__*/function (_CoverArtProvider2) {
_inherits(ProviderWithTrackImages, _CoverArtProvider2);
var _super2 = _createSuper(ProviderWithTrackImages);
function ProviderWithTrackImages() {
var _this3;
_classCallCheck(this, ProviderWithTrackImages);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this3 = _super2.call.apply(_super2, [this].concat(args));
_classPrivateMethodInitSpec(_assertThisInitialized(_this3), _createTrackImageComment);
_classPrivateMethodInitSpec(_assertThisInitialized(_this3), _urlToDigest);
_classPrivateMethodInitSpec(_assertThisInitialized(_this3), _groupIdenticalImages);
return _this3;
}
_createClass(ProviderWithTrackImages, [{
key: "imageToThumbnailUrl",
value: function imageToThumbnailUrl(imageUrl) {
// To be overridden by subclass if necessary.
return imageUrl;
}
}, {
key: "mergeTrackImages",
value: function () {
var _mergeTrackImages = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(trackImages, mainUrl, byContent) {
var _this4 = this;
var allTrackImages, groupedImages, mainDigest, tracksWithDigest, groupedThumbnails, _iterator, _step, _trackImages, representativeUrl, results;
return regenerator.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
allTrackImages = filterNonNull(trackImages); // First pass: URL only
groupedImages = _classPrivateMethodGet(this, _groupIdenticalImages, _groupIdenticalImages2).call(this, allTrackImages, function (img) {
return img.url;
}, mainUrl); // Second pass: Thumbnail content
// We do not need to deduplicate by content if there's only one track
// image and there's no main URL to compare to.
if (!(byContent && groupedImages.size && !(groupedImages.size === 1 && !mainUrl))) {
_context4.next = 19;
break;
}
LOGGER.info('Deduplicating track images by content, this may take a while…'); // Compute unique digests of all thumbnail images. We'll use these
// digests in `#groupIdenticalImages` to group by thumbnail content.
if (!mainUrl) {
_context4.next = 10;
break;
}
_context4.next = 7;
return _classPrivateMethodGet(this, _urlToDigest, _urlToDigest2).call(this, mainUrl);
case 7:
_context4.t0 = _context4.sent;
_context4.next = 11;
break;
case 10:
_context4.t0 = '';
case 11:
mainDigest = _context4.t0;
_context4.next = 14;
return Promise.all(_toConsumableArray(groupedImages.entries()).map( /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(_ref) {
var _ref3, coverUrl, trackImages, digest;
return regenerator.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_ref3 = _slicedToArray(_ref, 2), coverUrl = _ref3[0], trackImages = _ref3[1];
_context3.next = 3;
return _classPrivateMethodGet(_this4, _urlToDigest, _urlToDigest2).call(_this4, coverUrl);
case 3:
digest = _context3.sent;
return _context3.abrupt("return", trackImages.map(function (trackImage) {
return _objectSpread2(_objectSpread2({}, trackImage), {}, {
digest: digest
});
}));
case 5:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
return function (_x6) {
return _ref2.apply(this, arguments);
};
}()));
case 14:
tracksWithDigest = _context4.sent;
groupedThumbnails = _classPrivateMethodGet(this, _groupIdenticalImages, _groupIdenticalImages2).call(this, tracksWithDigest.flat(), function (trackWithDigest) {
return trackWithDigest.digest;
}, mainDigest); // The previous `groupedImages` map groups images by URL. Overwrite
// this to group images by thumbnail content. Keys will remain URLs,
// we'll use the URL of the first image in the group. It doesn't
// really matter which URL we use, as we've already asserted that
// the images behind all these URLs in the group are identical.
groupedImages.clear();
_iterator = _createForOfIteratorHelper(groupedThumbnails.values());
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_trackImages = _step.value;
representativeUrl = _trackImages[0].url;
groupedImages.set(representativeUrl, _trackImages);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
case 19:
// Queue one item for each group of track images. We'll create a comment
// to indicate which tracks this image belongs to.
results = [];
groupedImages.forEach(function (trackImages, imgUrl) {
results.push({
url: new URL(imgUrl),
types: [ArtworkTypeIDs.Track],
comment: _classPrivateMethodGet(_this4, _createTrackImageComment, _createTrackImageComment2).call(_this4, trackImages.map(function (trackImage) {
return trackImage.trackNumber;
})) || undefined
});
});
return _context4.abrupt("return", results);
case 22:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function mergeTrackImages(_x3, _x4, _x5) {
return _mergeTrackImages.apply(this, arguments);
}
return mergeTrackImages;
}()
}]);
return ProviderWithTrackImages;
}(CoverArtProvider);
function _groupIdenticalImages2(images, getImageUniqueId, mainUniqueId) {
var uniqueImages = images.filter(function (img) {
return getImageUniqueId(img) !== mainUniqueId;
});
return groupBy(uniqueImages, getImageUniqueId, function (img) {
return img;
});
}
function _urlToDigest2(_x7) {
return _urlToDigest3.apply(this, arguments);
}
function _urlToDigest3() {
_urlToDigest3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(imageUrl) {
var resp;
return regenerator.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return gmxhr(this.imageToThumbnailUrl(imageUrl), {
responseType: 'blob'
});
case 2:
resp = _context5.sent;
return _context5.abrupt("return", blobToDigest(resp.response));
case 4:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
return _urlToDigest3.apply(this, arguments);
}
function _createTrackImageComment2(trackNumbers) {
var definedTrackNumbers = filterNonNull(trackNumbers);
if (!definedTrackNumbers.length) return '';
var prefix = definedTrackNumbers.length === 1 ? 'Track' : 'Tracks';
return "".concat(prefix, " ").concat(definedTrackNumbers.sort().join(', '));
}
function mapJacketType(caption) {
if (!caption) {
return {
type: [ArtworkTypeIDs.Front, ArtworkTypeIDs.Back, ArtworkTypeIDs.Spine],
comment: ''
};
}
var types = [];
var keywords = caption.split(/(?:,|\s|and|&)/i);
var faceKeywords = ['front', 'back', 'spine'];
var _faceKeywords$map = faceKeywords.map(function (faceKw) {
return !!keywords // Case-insensitive .includes()
.find(function (kw) {
return kw.toLowerCase() === faceKw.toLowerCase();
});
}),
_faceKeywords$map2 = _slicedToArray(_faceKeywords$map, 3),
hasFront = _faceKeywords$map2[0],
hasBack = _faceKeywords$map2[1],
hasSpine = _faceKeywords$map2[2];
if (hasFront) types.push(ArtworkTypeIDs.Front);
if (hasBack) types.push(ArtworkTypeIDs.Back); // Assuming if the front and back are included, the spine is as well.
if (hasSpine || hasFront && hasBack) types.push(ArtworkTypeIDs.Spine); // Copy anything other than 'front', 'back', or 'spine' to the comment
var otherKeywords = keywords.filter(function (kw) {
return !faceKeywords.includes(kw.toLowerCase());
});
var comment = otherKeywords.join(' ').trim();
return {
type: types,
comment: comment
};
} // Keys: First word of the VGMdb caption (mostly structured), lower-cased
// Values: Either MappedArtwork or a callable taking the remainder of the caption and returning MappedArtwork
var __CAPTION_TYPE_MAPPING = {
front: ArtworkTypeIDs.Front,
booklet: ArtworkTypeIDs.Booklet,
jacket: mapJacketType,
// DVD jacket
disc: ArtworkTypeIDs.Medium,
cassette: ArtworkTypeIDs.Medium,
vinyl: ArtworkTypeIDs.Medium,
tray: ArtworkTypeIDs.Tray,
back: ArtworkTypeIDs.Back,
obi: ArtworkTypeIDs.Obi,
box: {
type: ArtworkTypeIDs.Other,
comment: 'Box'
},
card: {
type: ArtworkTypeIDs.Other,
comment: 'Card'
},
sticker: ArtworkTypeIDs.Sticker,
slipcase: {
type: ArtworkTypeIDs.Other,
comment: 'Slipcase'
},
digipack: {
type: ArtworkTypeIDs.Other,
comment: 'Digipack'
},
insert: {
type: ArtworkTypeIDs.Other,
comment: 'Insert'
},
// Or poster?
case: {
type: ArtworkTypeIDs.Other,
comment: 'Case'
},
contents: ArtworkTypeIDs.Raw
};
function convertMappingReturnValue(ret) {
if (Object.prototype.hasOwnProperty.call(ret, 'type') && Object.prototype.hasOwnProperty.call(ret, 'comment')) {
var retObj = ret;
return {
types: Array.isArray(retObj.type) ? retObj.type : [retObj.type],
comment: retObj.comment
};
}
var types = ret;
/* istanbul ignore next: No mapper generates this currently */
if (!Array.isArray(types)) {
types = [types];
}
return {
types: types,
comment: ''
};
}
var CAPTION_TYPE_MAPPING = {}; // Convert all definitions to a single signature for easier processing later on
var _loop = function _loop() {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
// Since value is a block-scoped const, the lambda will close over that
// exact value. It wouldn't if it was a var, as `value` would in the end
// only refer to the last value. Babel transpiles this correctly, so this
// is safe.
CAPTION_TYPE_MAPPING[key] = function (caption) {
if (typeof value === 'function') {
// Assume the function sets everything correctly, including the
// comment
return convertMappingReturnValue(value(caption));
}
var retObj = convertMappingReturnValue(value); // Add remainder of the caption to the comment returned by the mapping
if (retObj.comment && caption) retObj.comment += ' ' + caption; // If there's a caption but no comment, set the comment to the caption
else if (caption) retObj.comment = caption; // Otherwise there's a comment set by the mapper but no caption => keep,
// or neither a comment nor a caption => nothing needs to be done.
return retObj;
};
};
for (var _i = 0, _Object$entries = Object.entries(__CAPTION_TYPE_MAPPING); _i < _Object$entries.length; _i++) {
_loop();
}
function convertCaptions(cover) {
var url = new URL(cover.url);
if (!cover.caption) {
return {
url: url
};
}
var _cover$caption$split = cover.caption.split(' '),
_cover$caption$split2 = _toArray(_cover$caption$split),
captionType = _cover$caption$split2[0],
captionRestParts = _cover$caption$split2.slice(1);
var captionRest = captionRestParts.join(' ');
var mapper = CAPTION_TYPE_MAPPING[captionType.toLowerCase()];
if (!mapper) return {
url: url,
comment: cover.caption
};
return _objectSpread2({
url: url
}, mapper(captionRest));
}
var _extractImages = /*#__PURE__*/new WeakSet();
var VGMdbProvider = /*#__PURE__*/function (_CoverArtProvider) {
_inherits(VGMdbProvider, _CoverArtProvider);
var _super = _createSuper(VGMdbProvider);
function VGMdbProvider() {
var _this;
_classCallCheck(this, VGMdbProvider);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _extractImages);
_defineProperty(_assertThisInitialized(_this), "supportedDomains", ['vgmdb.net']);
_defineProperty(_assertThisInitialized(_this), "favicon", 'https://vgmdb.net/favicon.ico');
_defineProperty(_assertThisInitialized(_this), "name", 'VGMdb');
_defineProperty(_assertThisInitialized(_this), "urlRegex", /\/album\/(\d+)(?:\/|$)/);
return _this;
}
_createClass(VGMdbProvider, [{
key: "findImages",
value: function () {
var _findImages = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(url) {
var id, apiUrl, apiResp, metadata;
return regenerator.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
// Using the unofficial API at vgmdb.info
id = this.extractId(url);
assertHasValue(id);
apiUrl = "https://vgmdb.info/album/".concat(id, "?format=json");
_context.next = 5;
return gmxhr(apiUrl);
case 5:
apiResp = _context.sent;
metadata = safeParseJSON(apiResp.responseText, 'Invalid JSON response from vgmdb.info API');