-
Notifications
You must be signed in to change notification settings - Fork 27
/
mb_SUPER-MIND-CONTROL-II-X-TURBO.user.js
executable file
·1724 lines (1723 loc) · 103 KB
/
mb_SUPER-MIND-CONTROL-II-X-TURBO.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. SUPER MIND CONTROL Ⅱ X TURBO
// @version 2024.12.6
// @description musicbrainz.org power-ups: RELEASE_CLONER. copy/paste releases / DOUBLE_CLICK_SUBMIT / CONTROL_ENTER_SUBMIT / TRACKLIST_TOOLS. search→replace, track length parser, remove recording relationships, set selected works date / LAST_SEEN_EDIT. handy for subscribed entities / COOL_SEARCH_LINKS / COPY_TOC / ROW_HIGHLIGHTER / SPOT_CAA / SPOT_AC / RECORDING_LENGTH_COLUMN / RELEASE_EVENT_COLUMN / WARN_NEW_WINDOW / SERVER_SWITCH / TAG_TOOLS / USER_STATS / EASY_DATE. paste full dates in one go / STATIC_MENU / SLOW_DOWN_RETRY / CENTER_FLAGS / RATINGS_ON_TOP / HIDE_RATINGS / UNLINK_ENTITY_HEADER / MARK_PENDING_EDIT_MEDIUMS
// @namespace https://github.com/jesus2099/konami-command
// @homepage https://github.com/jesus2099/konami-command/blob/master/mb_SUPER-MIND-CONTROL-II-X-TURBO.md
// @supportURL https://github.com/jesus2099/konami-command/labels/mb_SUPER-MIND-CONTROL-II-X-TURBO
// @downloadURL https://github.com/jesus2099/konami-command/raw/master/mb_SUPER-MIND-CONTROL-II-X-TURBO.user.js
// @author jesus2099
// @licence CC-BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/
// @licence GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @since 2010-09-09; https://web.archive.org/web/20140328200933/userscripts.org/scripts/show/85790 / https://web.archive.org/web/20141011084019/userscripts-mirror.org/scripts/show/85790 / see topic GÓ GÓ AMÍGO
// @icon data:image/gif;base64,R0lGODlhEAAQAKEDAP+/3/9/vwAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh/glqZXN1czIwOTkAIfkEAQACAwAsAAAAABAAEAAAAkCcL5nHlgFiWE3AiMFkNnvBed42CCJgmlsnplhyonIEZ8ElQY8U66X+oZF2ogkIYcFpKI6b4uls3pyKqfGJzRYAACH5BAEIAAMALAgABQAFAAMAAAIFhI8ioAUAIfkEAQgAAwAsCAAGAAUAAgAAAgSEDHgFADs=
// @require https://github.com/jesus2099/konami-command/raw/bcceaa5f3da43e9ee805cba2eccda07f602d3f0c/lib/MB-JUNK-SHOP.js?version=2024.8.26
// @require https://github.com/jesus2099/konami-command/raw/7e350a72575bc729e9aa58af6796dadc2eca685d/lib/SUPER.js?version=2024.12.3
// @grant none
// @match *://*.musicbrainz.org/*
// @exclude *://blog.musicbrainz.org/*
// @exclude *://bugs.musicbrainz.org/*
// @exclude *://chatlogs.musicbrainz.org/*
// @exclude *://forums.musicbrainz.org/*
// @exclude *://geordi.musicbrainz.org/*
// @exclude *://musicbrainz.org/ws/*
// @exclude *://tickets.musicbrainz.org/*
// @exclude *://wiki.musicbrainz.org/*
// @run-at document-end
// ==/UserScript==
"use strict";
let userjs = {
id: "jesus2099userjs85790", // have to keep this for legacy saved settings
name: GM_info.script.name.substr(4).replace(/\s/g, "\u00a0"),
icon: createTag("img", {a: {src: GM_info.script.icon}, s: {verticalAlign: "middle", margin: "-8px 0"}})
};
var debugBuffer = "";
var DEBUG = false;
var pageType = location.pathname.match(/(area(?!.+(artists|labels|releases|places|aliases|edits))|artist(?!.+(releases|recordings|works|relationships|aliases|edits))|artists|event|labels|releases|recordings|report|series|track|works|aliases|cdtoc|collection(?!s|.+edits)|collections|edit(?!s|\/subscribed)|edits|votes|edit\/subscribed|isrc|label(?!.+edits)|place(?!.+(aliases|edits))|ratings|recording(?!s|.+edits)|relationships|release[-_]group(?!.+edits)|release(?!s|-group|.+edits)|search(?!\/edits)|tracklist|tag|url|work(?!s))/);
if (pageType) {
pageType = pageType[1].replace(/edit\/subscribed|votes/, "edits").replace(/_/, "-");
} else {
pageType = "other";
}
debug("Page type: " + pageType);
var MBS = location.protocol + "//" + location.host;
var lang = document.querySelector("html[lang]");
lang = lang && lang.getAttribute("lang") || "en-GB";
var sidebar = document.getElementById("sidebar");
var stre_GUID = "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}";
var re_GUID = new RegExp(stre_GUID);
var re_date = {
YYYY: "([0-2]\\d{3})",
YY: "(\\d{2})",
MM: "(0(?:1|2|3|4|5|6|7|8|9)|10|11|12)",
M: "(1|2|3|4|5|6|7|8|9|10|11|12)",
DD: "(0(?: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)",
D: "(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)",
};
re_date.ISO = "(" + re_date.YYYY + "(?:[-‐‑‒–—−/.] ?" + re_date.MM + "(?:[-‐‑‒–—−/.] ?" + re_date.DD + ")?)?)";
var account = document.querySelector("div.header ul.menu li.account");
if (account) {
var a = account.querySelector("a[href^='/user/']");
account = {
item: account,
name: unescape(a.getAttribute("href").match(/[^/]+$/)),
pathname: a.getAttribute("href"),
menu: account.querySelector("ul")
};
}
// ==========================================================================
// ## CONFIGURATORZ ##
// find this script settings in MB "About" menu
// ==========================================================================
var j2superturbo = {
menu: {
expl: " (you can find this in “%editing%” menu)",
addItem: function(item) {
item.addEventListener("click", function(event) { this.parentNode.parentNode.style.removeProperty("left"); });
j2superturbo.menu.lastItem = addAfter(createTag("li", {a: {class: "jesus2099"}, s: {textShadow: "0 0 8px purple"}}, item), j2superturbo.menu.getLastItem());
},
getLastItem: function() {
if (j2superturbo.menu.lastItem) return j2superturbo.menu.lastItem;
else {
var head, MBmenu = document.querySelector("div.header ul.menu li.editing > ul") || document.querySelector("div.header ul.menu li.about > ul");
if (MBmenu && (head = MBmenu.parentNode.querySelector("span.menu-header"))) {
j2superturbo.menu.expl = j2superturbo.menu.expl.replace(/%editing%/, head.textContent);
j2superturbo.menu.lastItem = MBmenu.appendChild(createTag("li", {a: {class: "jesus2099 separator"}}));
head.style.setProperty("text-shadow", "0 0 8px purple");
return j2superturbo.menu.lastItem;
} else if (document.querySelector("div.header ul.menu")) bug({message: "Can’t add menu", report: true});
}
}
},
addCSSRule: function(CSSRule) {
if (j2superturbo.css !== null) {
j2superturbo.css.insertRule(CSSRule, j2superturbo.css.cssRules.length);
} else {
debug("Style is ignored because of CSP restricted page (" + location.pathname + "):\n" + CSSRule);
}
}
};
j2superturbo.css = document.createElement("style");
j2superturbo.css.setAttribute("type", "text/css");
// Pages like /account/* and /admin/* prohibit inline css:
// Content-Security-Policy: style-src 'self' staticbrainz.org;
// Missing 'unsafe-inline'
document.head.appendChild(j2superturbo.css);
// sheet is null if <style> was (appended but) not applied
j2superturbo.css = j2superturbo.css.sheet;
var j2sets = {}, j2docs = {}, j2defs = {}, j2setsclean = [];
j2setting();
j2superturbo.menu.addItem(createTag("a", {a: {title: "Settings:\n" + GM_info.script.description.replace(/^[^:]+: /, "").replace(/ \/ /g, "\n")}, e: {click: function(event) {
var j2setsdiv = document.getElementById(userjs.id + "j2sets");
if (!j2setsdiv) {
j2setting();
if (j2sets) {
j2setsdiv = document.body.insertBefore(createTag("div", {a: {id: userjs.id + "j2sets"}, s: {backgroundColor: "silver", border: "2px outset white", padding: "1em"}}, [
createTag("p", {s: {textAlign: "right", margin: "0px"}}, [
createTag("a", {a: {href: GM_info.script.homepage, target: "_blank"}}, "HELP"),
" | ",
createTag("a", {a: {href: GM_info.script.supportURL, target: "_blank"}}, "known issues"),
" | ",
createTag("a", {e: {click: function(event) { if (confirm("RESET ALL YOUR SETTINGS TO DEFAULT?")) { localStorage.removeItem(userjs.id + "settings"); location.reload(); } }}}, "RESET"),
" | ",
createTag("a", {e: {click: function(event) { removeNode(document.getElementById(userjs.id + "j2sets")); }}}, "CLOSE"),
]),
createTag("h4", {s: {textShadow: "0 0 8px white", fontSize: "1.5em", marginTop: "0px"}}, [
"██ ",
createTag("a", {a: {href: GM_info.script.namespace, target: "_blank"}}, userjs.name),
" (" + GM_info.script.version + ")"
]),
createTag("p", {}, [
"All settings are instantly saved but require a ",
createTag("a", {e: {click: function() {
location.reload();
}}}, "PAGE RELOAD"),
" to see the effect."
])
]), document.getElementById("page"));
var alphakeys = [];
for (let s in j2sets) if (Object.prototype.hasOwnProperty.call(j2sets, s)) {
if (j2setsclean.indexOf(s) < 0) {
delete j2sets[s];
} else if (!s.match(/!/)) {
alphakeys.push(s);
}
}
alphakeys.sort();
var table = j2setsdiv.appendChild(createTag("table", {a: {border: "2", cellpadding: "4", cellspacing: "1"}}));
table.appendChild(createTag("thead", {}, [createTag("th", {}, "setting"), createTag("th", {}, "default setting"), createTag("th", {}, "description")]));
table = table.appendChild(document.createElement("tbody"));
for (let a = 0; a < alphakeys.length; a++) {
var tr = table.appendChild(document.createElement("tr"));
tr.appendChild(createTag("th", {s: {backgroundColor: "#ccc", textAlign: "left", paddingLeft: alphakeys[a].match(/[a-z]/) ? "2em" : "inherit"}}, j2settinput(alphakeys[a])));
tr.appendChild(createTag("td", {s: {opacity: ".666", textAlign: "center"}}, typeof j2defs[alphakeys[a]] == "boolean" ? (j2defs[alphakeys[a]] ? "☑" : "☐") : j2defs[alphakeys[a]]));
tr.appendChild(createTag("td", {s: {marginBottom: ".4em"}}, j2docit(j2docs[alphakeys[a]]).concat([" — ", createTag("a", {a: {href: GM_info.script.homepage + "#" + alphakeys[a].toLowerCase(), target: "_blank"}}, "more help…")])));
}
}
}
j2setsdiv.scrollIntoView();
}}}, [userjs.icon.cloneNode(false), " " + userjs.name + " (" + GM_info.script.version + ")"]));
function bug(error) {
var title = "", alrt = userjs.name + " (" + GM_info.script.version + ")" + " ERROR";
if (error.module) {
title = " in “" + error.module + "” module";
alrt += title;
}
if (error.message) {
title = error.message + title;
alrt += "\n\n" + error.message;
}
if (error.report && title) {
if (confirm(alrt + "\n\nDo you want to report the bug?\n(requires github account)\n(will open in a NEW WINDOW)")) {
open("https://github.com/jesus2099/konami-command/issues/new?title=" + encodeURIComponent(title) + "&body=" + encodeURIComponent("Hello,\nI am using that awesome *" + userjs.name + "* (**" + GM_info.script.version + "**).\nI got an error while I was on [" + (document.title ? document.title : "that page") + "](" + location.href + "):\n\n " + error.message.replace(/\n/g, "\n ")));
}
} else {
alert(alrt);
}
}
function j2setting(setting, val, def, doc) {
if (setting == null) {
j2sets = localStorage.getItem(userjs.id + "settings");
if (j2sets) { j2sets = JSON.parse(j2sets); } else { j2sets = {}; }
} else {
if (doc) {
j2docs[setting] = doc;
}
if (def) {
j2defs[setting] = val;
j2setsclean.push(setting);
}
if (val != null && (!def || j2sets[setting] == null)) {
j2sets[setting] = val;
localStorage.setItem(userjs.id + "settings", JSON.stringify(j2sets));
} else if (setting) {
return j2sets[setting];
}
}
}
function j2settinput(setting) {
var val = j2setting(setting);
var rnd = (Math.random() + "").substring(2);
var lbl = createTag("label", {a: {"for": userjs.id + enttype + setting + rnd}, s: {whiteSpace: "nowrap", textShadow: "1px 1px 2px #999"}}, createTag("input", {a: {type: "checkbox", id: userjs.id + enttype + setting + rnd, class: setting}, e: {change: function(event) {
j2setting(this.className, this.getAttribute("type") == "checkbox" ? this.checked : this.value);
}}}));
var inp = lbl.querySelector("input");
switch (typeof val) {
case "boolean":
addAfter(document.createTextNode(setting), inp);
inp.setAttribute("type", "checkbox");
inp.checked = val;
break;
default:
lbl.insertBefore(document.createTextNode("\u00a0_\u00a0 " + setting), inp);
inp.setAttribute("type", "text");
inp.setAttribute("value", val);
inp.style.setProperty("margin-left", "4px");
inp.addEventListener("keypress", function(event) { if (event.key == "Enter") { this.blur(); removeNode(getParent(this, "div")); } }, false);
break;
}
return lbl;
}
function j2docit(txt) {
var jira = txt.match(/\b(MBS-\d+)\b/);
if (jira) {
var arr = txt.split(jira[1]);
arr.splice(1, 0, createTag("a", {a: {href: "http://tickets.musicbrainz.org/browse/" + jira[1].toUpperCase(), target: "_blank", title: "Opens in new window"}}, jira[1]));
return arr;
} else return [txt];
}
// ==================================================================== LINK+
// ## RELEASE_CLONER ##
// todo : add debugged clone release-AR module
// ==========================================================================
j2setting("RELEASE_CLONER", true, true, "one-click duplicate release(s)" + j2superturbo.menu.expl);
j2setting("RELEASE_CLONER_release_event", false, true, "clones release event(s), package, catalogue number(s), etc. (not advised as those usually change for each edition)");
j2setting("RELEASE_CLONER_additional_information", false, true, "clones annotation and disambiguation (usually change for each edition)");
j2setting("RELEASE_CLONER_external_links", false, true, "(EXPERIMENTAL) clones URL relations (not advised as those usually change for each edition)");
j2setting("RELEASE_CLONER_tracktimes", false, true, "clones track times (mastering sometimes change for some edition)");
if (j2sets.RELEASE_CLONER && account) {
var rcwhere = location.pathname.match(new RegExp("^/((release(?!-group)|release-group|label)/" + stre_GUID + ")|artist/" + stre_GUID + "/(releases)$"));
if (
rcwhere && (rcwhere = rcwhere[2] ? rcwhere[2] : rcwhere[3])
) {
if (account) {
debug("RELEASE_CLONER");
j2superturbo.menu.addItem(createTag("a", {a: {title: userjs.name + "\nshift+click to open new tab / ctrl+click for background tab" + (rcwhere != "release" ? "\nno need to select if there is only one release on this page" : "")}, e: {click: function(clickEvent) {
var crmbids = [];
if (rcwhere == "release") {
crmbids.push("" + location.pathname.match(re_GUID));
} else {
var checkrels = document.querySelectorAll("table.tbl > tbody input[type='checkbox'][name='add-to-merge']");
for (let crmbid, cr = 0; cr < checkrels.length; cr++) {
if ((checkrels[cr].checked || checkrels.length == 1) && (crmbid = getParent(checkrels[cr], "tr")) && (crmbid = crmbid.querySelector("a[href*='/release/']").getAttribute("href").match(re_GUID))) {
crmbids.push("" + crmbid);
}
}
}
if (crmbids.length > 0) {
if (confirm("This will (you can change the settings):\n\n* " + (j2sets.RELEASE_CLONER_release_event ? "" : "NOT ") + "copy release events\n* " + (j2sets.RELEASE_CLONER_additional_information ? "" : "NOT ") + "copy additional information\n* " + (j2sets.RELEASE_CLONER_external_links ? "" : "NOT ") + "copy external links\n* " + (j2sets.RELEASE_CLONER_tracktimes ? "" : "NOT ") + "copy track times")) {
for (let crr = crmbids.length - 1; crr >= 0; crr--) {
var xhr_release_cloner = new XMLHttpRequest();
xhr_release_cloner.onload = function(event) {
var release = JSON.parse(this.responseText);
var reled = {
form: createTag("form", {a: {action: "/release/add", method: "post", target: formTarget(crr, clickEvent)}, s: {display: "none"}}),
add: function(data, requestParameter, required) {
if (data) {
// console.log(requestParameter + " = " + data);
reled.form.appendChild(createTag("textarea", {a: {name: requestParameter}}, data));
} else if (required) {
return false;
}
return true;
}
};
var ok = true;
ok &= reled.add(release.title, "name", true);
ok &= reled.add(release["release-group"].id, "release_group");
if (j2sets.RELEASE_CLONER_additional_information) {
ok &= reled.add(release.disambiguation, "comment");
ok &= reled.add(release.annotation, "annotation");
}
if (j2sets.RELEASE_CLONER_release_event) {
ok &= reled.add(release.barcode, "barcode");
/* ws:release-event-list */
if (release["release-events"]) for (let resi = 0; resi < release["release-events"].length && ok; resi++) {
var date = release["release-events"][resi].date;
if (date) {
var datex;
if ((datex = date.match(/^(\d{4})/))) ok &= reled.add(datex[1], "events." + resi + ".date.year");
if ((datex = date.match(/^.{4}-(\d{2})/))) ok &= reled.add(datex[1], "events." + resi + ".date.month");
if ((datex = date.match(/^.{4}-.{2}-(\d{2})$/))) ok &= reled.add(datex[1], "events." + resi + ".date.day");
if (release["release-events"][resi].area && release["release-events"][resi].area["iso-3166-1-codes"] && release["release-events"][resi].area["iso-3166-1-codes"].length > 0) ok &= reled.add(release["release-events"][resi].area["iso-3166-1-codes"][0], "events." + resi + ".country");
}
}
/* ws:release-event-list */
ok &= reled.add(release.status, "status");
ok &= reled.add(release.packaging, "packaging");
/* ws:label-info-list */
for (let resi = 0; resi < release["label-info"].length && ok; resi++) {
if (release["label-info"][resi].label) ok &= reled.add(release["label-info"][resi].label.id, "labels." + resi + ".mbid");
ok &= reled.add(release["label-info"][resi]["catalog-number"], "labels." + resi + ".catalog_number");
}
/* ws:label-info-list */
}
ok &= reled.add(release["text-representation"].language, "language");
ok &= reled.add(release["text-representation"].script, "script");
/* ws:artist-credit */
for (let resi = 0; resi < release["artist-credit"].length && ok; resi++) {
ok &= reled.add(release["artist-credit"][resi].artist.id, "artist_credit.names." + resi + ".mbid");
ok &= reled.add(release["artist-credit"][resi].name, "artist_credit.names." + resi + ".name");
ok &= reled.add(release["artist-credit"][resi].joinphrase, "artist_credit.names." + resi + ".join_phrase");
}
/* ws:artist-credit */
/* ws:medium-list */
for (let resi = 0; resi < release.media.length && ok; resi++) {
ok &= reled.add(release.media[resi].format, "mediums." + resi + ".format");
ok &= reled.add(release.media[resi].title, "mediums." + resi + ".name");
for (let tr = 0; tr < release.media[resi].tracks.length; tr++) {
ok &= reled.add(release.media[resi].tracks[tr].title, "mediums." + resi + ".track." + tr + ".name");
ok &= reled.add(release.media[resi].tracks[tr].number, "mediums." + resi + ".track." + tr + ".number");
ok &= reled.add(release.media[resi].tracks[tr].recording.id, "mediums." + resi + ".track." + tr + ".recording");
/* ws:artist-credit */
for (let aci = 0; aci < release.media[resi].tracks[tr]["artist-credit"].length && ok; aci++) {
ok &= reled.add(release.media[resi].tracks[tr]["artist-credit"][aci].artist.id, "mediums." + resi + ".track." + tr + ".artist_credit.names." + aci + ".mbid");
ok &= reled.add(release.media[resi].tracks[tr]["artist-credit"][aci].name, "mediums." + resi + ".track." + tr + ".artist_credit.names." + aci + ".name");
ok &= reled.add(release.media[resi].tracks[tr]["artist-credit"][aci].joinphrase, "mediums." + resi + ".track." + tr + ".artist_credit.names." + aci + ".join_phrase");
}
/* ws:artist-credit */
if (j2sets.RELEASE_CLONER_tracktimes) ok &= reled.add(release.media[resi].tracks[tr].length, "mediums." + resi + ".track." + tr + ".length");
}
}
/* ws:medium-list */
if (j2sets.RELEASE_CLONER_external_links) {
/* ws:url-rels */
var linkTypes = {
"unknown29unknown29unknown29unknown29": 29, // notes
"unknown72unknown72unknown72unknown72": 72, // production
"unknown73unknown73unknown73unknown73": 73, // get
"98e08c20-8402-4163-8970-53504bb6a1e4": 74, // buy download
"9896ecd0-6d29-482d-a21e-bd5d1b5e3425": 75, // download
"4a78823c-1c53-4176-a5f3-58026c76f2bc": 76, // discogs
"4f2e710d-166c-480c-a293-2e2c8d658d87": 77, // ASIN
"2476be45-3090-43b3-a948-a8f972b4065c": 78, // cover art
"3ee51e05-a06a-415e-b40c-b3f740dedfd7": 79, // buy mail
"c74dee45-3c85-41e9-a804-92ab1c654446": 82, // other db
"7387c5a2-9abe-4515-b667-9eb5ed4dd4ce": 83, // IMDb
"08445ccf-7b99-4438-9f9a-fb9ac18099ee": 85, // stream
"6af0134a-df6a-425a-96e2-895f9cd342ba": 86, // VGMdb
"823656dd-0309-4247-b282-b92d287d59c5": 288, // discography
"004bd0c3-8a45-4309-ba52-fa99f3aa3d50": 301, // licence
"0e555925-1b7d-475c-9b25-b9c349dcc3f3": 308, // 2ndhandsong
"2d24d075-9943-4c4d-a659-8ce52e6e6b57": 729, // notes
"90ff18ad-3e9d-4472-a3d1-71d4df7e8484": 755, // allmusic
"63b84620-ba52-4630-9bfe-8ad3b5504dff": 850, // bookbrainz
};
for (let resi = 0; resi < release.relations.length && ok; resi++) {
if (release.relations[resi].url) {
ok &= reled.add(linkTypes[release.relations[resi]["type-id"]], "urls." + resi + ".link_type");
ok &= reled.add(release.relations[resi].url.resource, "urls." + resi + ".url");
}
}
/* ws:url-rels */
}
ok &= reled.add("\n —\n" + MBS + "/release/" + crmbids[crr] + " cloned using " + userjs.name + "’s '''RELEASE_CLONER''' (" + GM_info.script.version + ")", "edit_note");
/* fin */
if (ok) document.body.appendChild(reled.form).submit();
else sendEvent(this, "error");
};
xhr_release_cloner.onerror = function(event) {
if (confirm("RELEASE_CLONER ERROR MY GOD\nDo you want to report this error? (in a new window)")) {
open("https://github.com/jesus2099/konami-command/issues/new?title=RELEASE_CLONER+xhr_release_cloner+error&body=" + encodeURIComponent("Hello,\nI am using *" + userjs.name + "* version **" + GM_info.script.version + "**.\nI got an error while cloning [this release](" + MBS + "/release/) on [that page](" + location.href + ").\n"));
}
};
xhr_release_cloner.open("get", MBS + "/ws/2/release/" + crmbids[crr] + "?inc=artists+labels+recordings+release-groups+media+artist-credits+annotation+url-rels&fmt=json", false);
xhr_release_cloner.send(null);
}
}
} else {
alert("Please select at least one release.");
}
}}}, [userjs.icon.cloneNode(false), " Clone " + (rcwhere == "release" ? "release" : "selected releases") + " ", createTag("small", {s: {color: "grey"}}, "← RELEASE_CLONER™")]));
}
}
}
function formTarget(releaseIndex, event) {
var target = "_self";
if (event.ctrlKey || releaseIndex > 0) {
target = userjs.id + (new Date().getTime());
try {
open("", target).blur();
} catch (error) {}
self.focus();
} else if (event.shiftKey) {
target = "_blank";
}
return target;
}
// ================================================================= DISPLAY+
// ## USER_STATS ##
// ==========================================================================
j2setting("USER_STATS", true, true, "adds convenient edit stats to user page (percentage of yes/no voted edits) and cool links like edit note searches");
if (j2sets.USER_STATS && location.pathname.match(/^\/user\/[^/]+$/)) {
var stats = document.querySelectorAll("table.statistics > tbody");
var editor = {
pathname: location.pathname.substr(location.pathname.lastIndexOf("/") + 1)
};
if (!isEncoded(editor.pathname)) {
// Opera 12 alone is surprisingly decoding location.pathname
editor.pathname = encodeURIComponent(editor.pathname);
}
editor.name = decodeURIComponent(editor.pathname);
if (stats.length >= 3) {
debug("USER_STATS");
// Edits
var cell_acceptedEdits = getParent(stats[0].querySelector("a[href$='/edits/accepted']"), "td");
var cell_voteddownEdits = getParent(stats[0].querySelector("a[href$='/edits/rejected']"), "td");
var cell_appliedEdits = getParent(stats[0].querySelector("a[href$='/edits/applied']"), "td");
var nb_acceptedEdits = readStat(cell_acceptedEdits);
var nb_voteddownEdits = readStat(cell_voteddownEdits);
var nb_totalNonAuto = nb_acceptedEdits + nb_voteddownEdits;
writeStat(cell_acceptedEdits, nb_acceptedEdits, nb_totalNonAuto);
cell_acceptedEdits.style.setProperty("font-weight", "bold");
writeStat(cell_voteddownEdits, nb_voteddownEdits, nb_totalNonAuto);
cell_voteddownEdits.style.setProperty("font-weight", "bold");
cell_appliedEdits.parentNode.replaceChild(createTag("th", null, createTag("a", {a: {href: "/statistics/editors", title: "See top editors"}, s: {cursor: "help"}}, cell_appliedEdits.parentNode.firstChild.textContent)), cell_appliedEdits.previousSibling);
// Votes
editor.id = stats[0].querySelector("a[href^='/search/edits?']").getAttribute("href").match(/conditions\.0\.args\.0=(\d+)/)[1];
var voteSearch = MBS + "/search/edits?conditions.0.field=voter&conditions.0.operator=%3D&conditions.0.name=%editorName%&conditions.0.voter_id=%editorID%&conditions.0.args=%vote%";
voteSearch = voteSearch.replace(/%editorName%/, editor.pathname);
voteSearch = voteSearch.replace(/%editorID%/, editor.id);
for (let i = 0; i < stats[1].rows.length; i++) {
var vote = stats[1].rows[i].cells[2];
vote.replaceChild(createTag("a", {a: {href: voteSearch.replace(/%vote%/, {0: 1 /* Yes */, 1: 0 /* No */, 2: -1 /* Abstain */, 3: 2 /* Approve */}[i])}}, [vote.firstChild.cloneNode(true)]), vote.firstChild);
}
var yes = readStat(stats[1].rows[0].cells[2]);
var no = readStat(stats[1].rows[1].cells[2]);
var abstain = readStat(stats[1].rows[2].cells[2]);
var approve = stats[1].rows.length > 3 ? readStat(stats[1].rows[3].cells[2]) : 0;
if (approve > 0) {
// Move Approve before Yes votes to include it in effective votes and leave Abstain last
stats[1].insertBefore(stats[1].removeChild(stats[1].rows[3]), stats[1].rows[0]);
}
stats[1].insertBefore(
createTag("tr", null, [
createTag("th", null, createTag("a", {a: {href: "/statistics/editors", title: "See top voters"}, s: {cursor: "help"}}, "Total effective votes")),
createTag("th", {a: {colspan: "2"}}, (0 + yes + no + approve).toLocaleString(lang) + " (" + percentage(yes + no + approve, yes + no + abstain + approve) + ")")
]),
stats[1].rows[stats[1].rows.length > 3 ? 3 : 2]
);
// Edit notes
if (account && account.pathname !== "/user/" + editor.pathname) {
var myEditNotes = "/search/edits?conditions.0.field=editor&conditions.0.operator=%3D&conditions.0.name=%editorName%&conditions.0.args.0=%editorID%&conditions.1.field=edit_note_author&conditions.1.operator=me";
var theirEditNotes = "/search/edits?conditions.0.field=editor&conditions.0.operator=me&conditions.1.field=edit_note_author&conditions.1.operator=%3D&conditions.1.name=%editorName%&conditions.1.args.0=%editorID%";
var ourEditNotes = "/search/edits?conditions.0.field=editor&conditions.0.operator=not_me&conditions.1.field=editor&conditions.1.operator=%21%3D&conditions.1.name=%editorName%&conditions.1.args.0=%editorID%&conditions.2.field=edit_note_author&conditions.2.operator=me&conditions.3.field=edit_note_author&conditions.3.operator=%3D&conditions.3.name=%editorName%&conditions.3.args.0=%editorID%";
stats[0].parentNode.previousSibling.parentNode.insertBefore(createTag("h2", {a: {title: userjs.name + " (USER_STATS)"}}, "Edit Notes"), stats[0].parentNode.previousSibling);
stats[0].parentNode.previousSibling.parentNode.insertBefore(createTag("ul", {a: {title: userjs.name + " (USER_STATS)"}}, [
createTag("li", {}, createTag("a", {a: {href: myEditNotes.replace(/%editorID%/, editor.id).replace(/%editorName%/, editor.pathname)}}, [createTag("b", {}, "Edits by " + editor.name), " (with my comments)"])),
createTag("li", {}, createTag("a", {a: {href: theirEditNotes.replace(/%editorID%/, editor.id).replace(/%editorName%/, editor.pathname)}}, [createTag("b", {}, "Comments by " + editor.name), " (on my edits)"])),
createTag("li", {}, createTag("a", {a: {href: ourEditNotes.replace(/%editorID%/g, editor.id).replace(/%editorName%/g, editor.pathname)}}, "Other edits with comments by both me and " + editor.name))
]), stats[0].parentNode.previousSibling);
}
// Added entities
var addedEntities = 0;
var maxAddedEntities = 0;
for (let i = 0; i < stats[2].rows.length; i++) {
var added = readStat(stats[2].rows[i].cells[1]);
maxAddedEntities = Math.max(maxAddedEntities, added);
addedEntities += added;
}
stats[2].appendChild(
createTag("tr", null, [
createTag("th", null, "Total"),
createTag("td", null, addedEntities.toLocaleString(lang))
])
);
for (let i = 0; i < stats[2].rows.length - 1; i++) {
writeStat(stats[2].rows[i].cells[1], readStat(stats[2].rows[i].cells[1]), addedEntities, maxAddedEntities);
}
}
}
function isEncoded(string) {
// a mix of http://stackoverflow.com/a/30209048/2236179 and http://stackoverflow.com/a/8267593/2236179
if (typeof string != "string") return false;
var result;
try {
result = decodeURIComponent(string);
} catch (error) {
result = unescape(string);
}
return result != string;
}
function readStat(statsCell) {
// fallback to 0 for very rare cases when a new entity type is not yet cached
return parseInt(statsCell.textContent.split("(")[0].replace(/\D/g, ""), 10) || 0;
}
function writeStat(statsCell, stat, total, max) {
var a = statsCell.getElementsByTagName("a")[0];
a.replaceChild(document.createTextNode(percentage(stat, total)), a.firstChild);
if (max !== 0) {
statsCell.style.setProperty("background-color", "rgb(255, 255, " + (255 - Math.floor(stat / max * 255)) + ")");
if (stat === max) {
statsCell.style.setProperty("font-weight", "bold");
}
}
if (parseInt(a.firstChild.textContent, 10) >= 25) {
a.style.setProperty("background-color", "#ff6");
getParent(statsCell, "tr").querySelector("th").style.setProperty("background-color", "#ff6");
}
}
function percentage(p, c) {
return (c == 0 ? 0 : Math.round(10000 * p / c / 100)) + "%";
}
// =============================================================== KEYBOARD+
// ## EASY_DATE ## basic paste-a-date!-like (https://web.archive.org/web/20131112023543/userscripts.org/scripts/show/121217)
// =========================================================================
j2setting("EASY_DATE", false, true, "You can paste full date in the YYYY field, it will split it\nascending D.M.YYYY or descending YYYY.M.D,\nalmost any format except american (MBS-1197)\n\nYou can freely type date, without tabulating, across year-month-date\n(with only digits 20241231, or with separators 2024.12/31)\n\nPress “c” to copy current date into the other (begin→end or end→begin)\nPress “d” to delete dates");
if (j2sets.EASY_DATE && !location.pathname.match(/^\/account\/edit/)) {
document.addEventListener("focusin", function(event) {
if (event.target.matches("input.partial-date-year, input.partial-date-month, input.partial-date-day")) {
if (!event.target.closest("table.relationship-details, fieldset").querySelector(".jesus2099easydate")) {
var doc = createTag("pre", {a: {class: "jesus2099easydate"}}, "EASY_DATE®\n----------\n\n" + j2docs.EASY_DATE);
if (event.target.closest("fieldset")) {
event.target.closest("fieldset").appendChild(createTag("div", {a: {class: "row"}}, doc));
} else {
event.target.closest("table.relationship-details").appendChild(createTag("tfoot", {}, createTag("tr", {}, createTag("td", {a: {colspan: "2"}}, doc))));
}
}
event.target.select();
}
});
document.addEventListener("paste", function(event) {
if (event.target.matches("input.partial-date-year, input.partial-date-month, input.partial-date-day")) {
var date = event.clipboardData.getData("text/plain").trim();
// fullwidth to halfwidth
date = date.replace(/[0-9]/g, function(d) {
return String.fromCharCode(d.charCodeAt(0) - "0".charCodeAt(0) + "0".charCodeAt(0));
});
// remove non-digit prefix and suffix
date = date.replace(/^\D+|\D+$/, "");
if (!date.match(/\D/)) {
date = date.match(new RegExp("^" + re_date.YYYY + "(?:" + re_date.MM + "(?:" + re_date.DD + ")?)?$"));
} else {
date = date.match(new RegExp("^(?:" + re_date.YYYY + "\\D+" + re_date.MM + "(?:\\D+" + re_date.DD + ")?|(?:" + re_date.DD + "\\D+)" + re_date.MM + "\\D+" + re_date.YYYY + "|" + re_date.YYYY + "\\D+" + re_date.M + "(?:\\D+" + re_date.D + ")?|(?:" + re_date.D + "\\D+)?" + re_date.M + "\\D+" + re_date.YYYY + "|" + re_date.YY + "\\D+" + re_date.M + "(?:\\D+" + re_date.D + ")?|(?:" + re_date.D + "\\D+)?" + re_date.M + "\\D+" + re_date.YY + ")$"));
}
if (date) {
date = {
year: date[1] || date[6] || date[7] || date[12] || date[13] || date[18],
month: date[2] || date[5] || date[8] || date[11] || date[14] || date[17],
day: date[3] || date[4] || date[9] || date[10] || date[15] || date[16]
};
for (var i in date) if (Object.prototype.hasOwnProperty.call(date, i) && date[i]) {
if (i == "year" && date[i].length == 2) {
// YY to YYYY
date[i] = EASY_DATE_YY_to_YYYY(date[i]) + date[i];
} else if (date[i].length == 1) {
date[i] = "0" + date[i];
}
var input = event.target.closest(".partial-date").querySelector("input.partial-date-" + i);
input.focus();
forceValue(input, date[i]);
input.style.setProperty("background-color", "#cfc");
}
if (event.target.matches("input:not([name^='edit-'])[name*='.begin_date.'], input:not([name^='edit-'])[name*='.end_date.']")) {
EASY_DATE_cloneDate(event.target);
}
stop(event);
} else {
if (!date.match(/^\d\d\d\d$/)) event.target.style.setProperty("background-color", "#fcc");
stop(event);
}
}
});
document.addEventListener("keydown", function(event) {
if (event.target.matches("input.partial-date-year, input.partial-date-month, input.partial-date-day")) {
if (!event.altKey && !event.ctrlKey && !event.metaKey && event.key) {
if (event.key.match(/^(c|d)$/)) {
var is_date_span = event.target.matches("input[name*='.begin_date.'], input[name*='.end_date.']");
switch (event.key) {
case "c":
if (is_date_span) {
EASY_DATE_cloneDate(event.target, true);
}
break;
case "d":
EASY_DATE_deleteDates(event.target, is_date_span);
break;
}
return stop(event);
} else if (event.key.match(/[0-90-9\-/.]/) && event.target.matches("input.partial-date-year, input.partial-date-month")) {
var separator_mode = event.key == "-" || event.key == "/" || event.key == ".";
var full_digit_mode = event.target.selectionStart === event.target.selectionEnd && event.target.value.length === event.target.getAttribute("placeholder").length && event.key.match(/[0-90-9]/);
if (separator_mode || full_digit_mode) {
var next_field = event.target.parentNode.querySelector("input.partial-date-" + (event.target.matches("input.partial-date-year") ? "month" : "day"));
next_field.focus();
next_field.select();
if (full_digit_mode) {
forceValue(next_field, event.key);
}
return stop(event);
}
}
}
}
});
}
function EASY_DATE_YY_to_YYYY(yy) {
// 94 means 1994 but 19 means 2019
return (parseInt(yy, 10) > 28 ? "19" : "20") + yy;
}
function EASY_DATE_cloneDate(current, hotkey) {
var date_elements = ["year", "month", "day"];
var copied_date = "";
for (let p = 0; p < date_elements.length; p++) {
var date_parts = current.closest("table.relationship-details > tbody, fieldset").querySelectorAll("input.partial-date-" + date_elements[p]);
var downwards = (current.parentNode == date_parts[0].parentNode);
if (!hotkey && !downwards) {
return;
}
date_parts[downwards ? 1 : 0].focus();
forceValue(date_parts[downwards ? 1 : 0], date_parts[downwards ? 0 : 1].value);
date_parts[downwards ? 1 : 0].style.setProperty("background-color", "#cfc");
copied_date += date_parts[downwards ? 0 : 1].value;
}
if (copied_date === "") {
EASY_DATE_uncheckEnded(current);
}
}
function EASY_DATE_deleteDates(current, is_date_span) {
var date_elements = ["year", "month", "day"];
for (let p = 0; p < date_elements.length; p++) {
var date_parts = current.closest(is_date_span ? "table.relationship-details > tbody, fieldset" : "span.partial-date").querySelectorAll("input.partial-date-" + date_elements[p]);
for (let i = 0; i < date_parts.length; i++) {
date_parts[i].focus();
forceValue(date_parts[i], "");
date_parts[i].style.removeProperty("background-color");
}
}
if (is_date_span) {
EASY_DATE_uncheckEnded(current);
}
}
function EASY_DATE_uncheckEnded(current) {
var endedCheckbox = current.closest("table.relationship-details > tbody, fieldset").querySelector("input[name$='period.ended'][type='checkbox']");
if (endedCheckbox && endedCheckbox.checked) {
endedCheckbox.focus();
endedCheckbox.click();
}
}
// ================================================================= DISPLAY+
// ## SPOT_AC ##
// ==========================================================================
j2setting("SPOT_AC", true, true, "name variations (Artist Credit, track name ≠ recording name, etc.) stand out");
j2setting("SPOT_AC_css", "border-bottom: 2px dashed maroon;", true, "CSS syntax (on “.name-variation” - and on “.name-variation” of recording page)");
if (j2sets.SPOT_AC) {
j2superturbo.addCSSRule(".name-variation, .artist-credit-variation { " + j2sets.SPOT_AC_css + " }");
}
// ================================================================= DISPLAY+
// ## SPOT_CAA ##
// ==========================================================================
j2setting("SPOT_CAA", true, true, "cover art archive’s images stand out from other images. Allows spotting incorrectly padded CAA uploads and looks cool altogether. Now also supports event art archive (EAA) and zabe40 Entity Images userscript PR #16");
j2setting("SPOT_CAA_css", "box-shadow: 0 0 8px black;", true, "CSS syntax (on “a.artwork-image > img”)");
if (j2sets.SPOT_CAA) {
j2superturbo.addCSSRule("img[src*='//coverartarchive.org/'], img[src*='//eventartarchive.org/'], #sidebar .picture > img, img[src*='//archive.org/download/mbid-'], img.uploader-preview-image { " + j2sets.SPOT_CAA_css + " }");
}
// ================================================================= DISPLAY+
// ## WARN_NEW_WINDOW ##
// ==========================================================================
j2setting("WARN_NEW_WINDOW", true, true, "links that open in a new window will be marked with an icon");
if (j2sets.WARN_NEW_WINDOW) {
j2superturbo.addCSSRule("a[target='_blank'] { padding-right: 16px; background: no-repeat 99% url(data:image/gif;base64,R0lGODlhCwAKAPcAAOAaGv///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAALAAoAAAgpAAUIFACgoEEAAwkeLJgQYUODBBMqZOhwIEOBFTFWXAhRYkOJGTlmDAgAOw==); }");
}
// ================================================================= DISPLAY+
// ## CENTER_FLAGS ##
// ==========================================================================
j2setting("CENTER_FLAGS", true, true, "vertically center flags");
if (j2sets.CENTER_FLAGS) {
j2superturbo.addCSSRule(".flag { background-origin: padding-box; background-position: 0% 84%; }");
}
// ================================================================= DISPLAY-
// ## HIDE_RATINGS ##
// ==========================================================================
j2setting("HIDE_RATINGS", false, true, "hide those cute little stars and everything related to ratings in MB");
if (j2sets.HIDE_RATINGS) {
j2superturbo.addCSSRule("div#content table.tbl > * > tr > th.rating, div#content table.tbl > tbody > tr > td.rating, div#sidebar > h2.rating, div#sidebar > h2.rating + p, div#page > div.tabs > ul.tabs > li:not(.sel) > a[href$='/ratings'], div.header ul.menu li.data a[href$='/ratings'] { display: none; }");
// work around for missing rating classes (artist, collection)
var ratingIndex = document.querySelector("div#content table.tbl > tbody > tr > td:not(.rating) > span.inline-rating");
if (ratingIndex) {
debug("HIDE_RATINGS");
j2superturbo.addCSSRule("div#content table.tbl > * > tr > *:nth-child(" + (ratingIndex.parentNode.cellIndex + 1) + ") { display: none; }");
}
}
// ================================================================= DISPLAY+
// ## RATINGS_ON_TOP ##
// ==========================================================================
j2setting("RATINGS_ON_TOP", false, true, "show (5 stars) ratings at the top of the sidebar");
j2setting("RATINGS_ON_TOP_below_image", true, true, "place the ratings just below the entity image (instead of topmost)");
if (j2sets.RATINGS_ON_TOP && sidebar && !j2sets.HIDE_RATINGS) {
var ratings = sidebar.querySelector("h2.rating");
if (ratings) {
ratings = [ratings, getSibling(ratings, "p")];
var where;
if (j2sets.RATINGS_ON_TOP_below_image) where = sidebar.querySelector("div.cover-art + *, div.picture + *");
if (!where) where = sidebar.firstChild;
if (ratings[1] && where) for (let r = 0; r < ratings.length; r++) {
debug("RATINGS_ON_TOP");
sidebar.insertBefore(sidebar.removeChild(ratings[r]), where);
}
}
}
// ================================================================= DISPLAY+
// ## ROW_HIGHLIGHTER ##
// evolution of brianfreud’s original idea
// MusicBrainz row highlighter https://web.archive.org/web/20131104205654/userscripts.org/scripts/show/118008
// ==========================================================================
j2setting("ROW_HIGHLIGHTER", true, true, "highlights rows in various MB tables");
j2setting("ROW_HIGHLIGHTER_colour", "#f9f3", true, "use any CSS colour code or name (yellow, #fcf, #ffccff, #f9f3, #ff99ff33, hsl(…), rgb(…), rgba(…), etc.)");
if (j2sets.ROW_HIGHLIGHTER && j2sets.ROW_HIGHLIGHTER_colour.match(/^(#[0-9a-f]{3,4}|#[0-9a-f]{6}|#[0-9a-f]{8}|[a-z-]+|(hsl|rgb)a?\([^)]+\))$/i)) {
j2superturbo.addCSSRule(
"div#content table.tbl > tbody > tr:hover > td,"
+ "div#page.fullwidth > table.tbl > tbody > tr:hover > td,"
+ "div#release-editor > div#tracklist tr:hover > td,"
+ "div#release-editor > div#tracklist tr:hover > td input {"
+ "background-image: linear-gradient(" + j2sets.ROW_HIGHLIGHTER_colour + ", " + j2sets.ROW_HIGHLIGHTER_colour + ");"
+ "}"
);
}
// =================================================================== MOUSE+
// ## Common form submission function ##
// ==========================================================================
function parentFormSubmit(input, event) {
var form = getParent(input, "form") || document.querySelector("div#release-editor");
if (form) {
var submitbutt = form.querySelector("div#release-editor button.positive[data-click='submitEdits'], div.buttons > button[type='submit'], span.buttons > button[type='submit']");
if (submitbutt) {
submitbutt.style.setProperty("background-color", "yellow");
if (submitbutt.getAttribute("disabled")) alert("This form is not (yet) submitable. Maybe you haven’t changed anything yet.");
else sendEvent(submitbutt, (event.shiftKey ? "shift+" : "") + "click");
} else {
form.submit();
}
}
}
// =================================================================== MOUSE+
// ## DOUBLE_CLICK_SUBMIT ##
// ==========================================================================
j2setting("DOUBLE_CLICK_SUBMIT", true, true, "makes the “radio buttons” and “multi-selects” submit forms on double-click (MBS-3229)");
if (j2sets.DOUBLE_CLICK_SUBMIT && location.pathname.match(/^\/(cdtoc\/|cdstub\/|edit\/|release\/(add(\?release-group=)?|[^/]+\/edit-cover-art\/)|release-group\/[^/]+\/edit|search|.+\/merge)/)) {
document.body.addEventListener("dblclick", function(event) {
if (
event.target.tagName
&& !getParent(event.target, "div", "edit-list") // mb_POWER-VOTE has its own DOUBLE_CLICK_SUBMIT
&& (
event.target.tagName == "INPUT"
&& event.target.getAttribute("type") == "radio"
||
event.target.tagName == "LABEL"
&& event.target.querySelector("input[type='radio']")
||
event.target.tagName == "OPTION"
&& event.target.parentNode.tagName == "SELECT"
&& event.target.parentNode.getAttribute("multiple") != null
)
) {
debug("DOUBLE_CLICK_SUBMIT");
parentFormSubmit(event.target, event);
}
});
}
// ================================================================ KEYBOARD+
// ## CONTROL_ENTER_SUBMIT ##
// ==========================================================================
j2setting("CONTROL_ENTER_SUBMIT", true, true, "hit CTRL+ENTER keys when you’re in a text area to submit the current form");
if (j2sets.CONTROL_ENTER_SUBMIT) {
document.body.addEventListener("keydown", function(event) {
if (
event.ctrlKey && event.key == "Enter"
&& event.target.matches("textarea")
&& !event.target.matches("#release-editor #annotation")
) {
debug("CONTROL_ENTER_SUBMIT");
parentFormSubmit(event.target, event);
}
});
}
// ================================================================ REMEMBER+
// ## LAST_SEEN_EDIT ##
// ==========================================================================
j2setting("LAST_SEEN_EDIT", false, true, "it shows you what edits you have already seen (reviewed) on entities edit histories, yeah man. only saves states when looking at all edits (not only open) of entity");
if (j2sets.LAST_SEEN_EDIT && account) {
debug("LAST_SEEN_EDIT");
var what = (location.pathname).match(new RegExp("^/(?:(user)/([^/]+)/edits(?:/(open))?|([^/]+)/(" + stre_GUID + ")/(?:(open)_)?edits)"));
if (what) {
var isOpenEdits = typeof (what[3] || what[6]) != "undefined";
var which = what[2] || what[5];
what = what[1] || what[4];
var lastseenedits = localStorage.getItem(userjs.id + "lastseenedits-" + what);
var upd = false;
if (lastseenedits) { lastseenedits = JSON.parse(lastseenedits); } else { lastseenedits = {}; }
var now = new Date();
if (lastseenedits[which]) {
if (lastseenedits[which][2] > lastseenedits[which][0] && new Date(lastseenedits[which][1]) < new Date(now - 1000 * 60 * 30 /* 30minutes */)) {
lastseenedits[which][0] = lastseenedits[which][2];
lastseenedits[which][1] = now.getTime();
upd = true;
}
} else {
lastseenedits[which] = [0, now.getTime(), 0]; // [0:edit,1:when,2:next]
}
var edits = document.querySelectorAll("div.edit-header > h2 > a[href*='/edit/']");
for (let ed = 0; ed < edits.length; ed++) {
var editn = parseInt(edits[ed].getAttribute("href").match(/\d+$/), 10);
var editlist = getParent(edits[ed], "div", "edit-list");
if (!isOpenEdits && ed == 0 && editn > lastseenedits[which][0] && editn > lastseenedits[which][2]) {
lastseenedits[which][2] = editn;
upd = true;
}
if (editn <= lastseenedits[which][0]) {
editlist.setAttribute("title", "SEEN EDIT");
if (editn == lastseenedits[which][0]) {
editlist.parentNode.insertBefore(createTag("hr", {a: {title: "Edits below are already seen"}, s: {height: "0px", border: "none", "border-top": "4px dashed red"}}), editlist);
if (ed > 0) { getSibling(editlist, "div", "edit-list", true).scrollIntoView(); }
}
} else {
editlist.style.setProperty("background-color", "#ffc");
editlist.setAttribute("title", "NEW EDIT");
}
}
if (upd && !isOpenEdits) {
localStorage.setItem(userjs.id + "lastseenedits-" + what, JSON.stringify(lastseenedits));
}
}
}
// ==================================================================== LINK+
// ## COOL_SEARCH_LINKS ##
// ==========================================================================
j2setting("COOL_SEARCH_LINKS", true, true, "additional “refine this search” links excluding own and/or unvoted and/or cancelled/failed edits as well as quick switch between all edits / open_edits");
if (j2sets.COOL_SEARCH_LINKS && account && !location.pathname.match(/^\/search\/edits/)) {
debug("COOL_SEARCH_LINKS");
var baseURL = location.pathname.match(new RegExp("^/([^/]+)/(" + stre_GUID + ")"));
var is_edit_search = location.pathname.match(/((open_)?edits|edits\/(accepted|applied|autoedits|cancelled|failed|open|rejected))\/?$/);
if (baseURL && !is_edit_search) {
// Entity page
var entityType = baseURL[1].replace(/-/, "_");
var entityName = document.querySelector("div#content h1 a");
var entityID = document.querySelector("div#sidebar a[href^='/" + entityType + "/merge_queue?add-to-merge=']");
var entityEdits = document.querySelector("div#sidebar a[href$='" + baseURL[0] + "/edits']");
if (entityID && entityEdits && entityType && entityName && entityType != "collection") {
// TODO: Allow collections with missing MBS-3922 feature “Edit search: Filter edits by collections” https://tickets.metabrainz.org/browse/MBS-3922
entityID = entityID.getAttribute("href").match(/add-to-merge=(\d+)/)[1];
entityName = entityName.textContent;
// refine
var refine_sidebar = "/search/edits?conditions.0.operator=%3D&conditions.0.field=" + entityType + "&conditions.0.name=" + encodeURIComponent(entityName) + "&conditions.0.args.0=" + entityID + "&order=desc&combinator=and&negation=0";
addAfter(createTag("span", {}, [" (", createTag("a", {a: {title: "Another cool search link from " + userjs.name, href: refine_sidebar + "&form_only=yes"}, s: {background: "#ff6"}}, "refine"), ")"]), entityEdits);
entityEdits.setAttribute("title", "Includes child/related entity edits");
var refineEntity = entitySpecificEdits(entityType, refine_sidebar, "pure+cover+relationship");
if (refineEntity) {
// pure entity edits
entityEdits.parentNode.appendChild(createTag("ul", {a: {title: userjs.name}, s: {border: "2px solid purple"}},
createTag("li", {}, [createTag("a", {a: {title: "No child/related entity (VERY SLOW)", href: refineEntity}}, "Only this " + entityType.replace(/_/, "\u00a0") + " edits"), " (SLOW)",
createTag("ul", {s: {paddingLeft: "10px"}}, [
createTag("li", {a: {id: userjs.id + "-pure+cover"}, s: {background: "#ff6"}}, createTag("a", {a: {href: entitySpecificEdits(entityType, refine_sidebar, "pure+cover")}, s: {fontWeight: "bold"}}, "Pure " + entityType.replace(/_/, "\u00a0") + " edits")),
createTag("li", {}, [createTag("span", {}, [createTag("a", {a: {class: userjs.id + "-rels", href: entitySpecificEdits(entityType, refine_sidebar, "relationship")}}, "Relationship edits"), " (SLOW)"]),
createTag("ul", {s: {paddingLeft: "10px"}}, [
createTag("li", {s: {background: "#ff6", textDecoration: "initial"}}, createTag("a", {a: {class: userjs.id + "-post-ngs-rels", href: entitySpecificEdits(entityType, refine_sidebar, "post-ngs-relationship")}, title: "Edits since 2011-05-17"}, "Post‐NGS")),
createTag("li", {s: {background: "#ff6", textDecoration: "initial"}}, createTag("a", {a: {class: userjs.id + "-pre-ngs-rels", href: entitySpecificEdits(entityType, refine_sidebar, "pre-ngs-relationship")}, title: "Edits before 2011-05-17"}, "Pre‐NGS"))
])
]),
])
])
));
if (entityType == "release") {
refineEntity = entitySpecificEdits(entityType, refine_sidebar, "cover");
if (refineEntity) {
document.getElementById(userjs.id + "-pure+cover").appendChild(createTag("fragment", {}, [
" (",
createTag("a", {a: {title: "No art edits", href: entitySpecificEdits(entityType, refine_sidebar, "pure")}}, "no"),
"/",
createTag("a", {a: {title: "Only art edits", href: refineEntity}}, "art"),
")"
]));
}
}
// Check if there are pre‐NGS relationship edits
var xhr_cool_search_links = new XMLHttpRequest();
xhr_cool_search_links.addEventListener("load", function(event) {
if (this.status == 200) {
var foundEdits = this.responseText.match(/<strong>([^<]*)<\/strong><\/p><\/div><div id="edits">/);
if (foundEdits) {
// Edits found
document.querySelector("li > a." + userjs.id + "-pre-ngs-rels").parentNode.appendChild(document.createTextNode(" (" + foundEdits[1].toLowerCase() + ")"));
} else {
// No edits found
var all_relationships = sidebar.querySelector("a." + userjs.id + "-rels");
all_relationships.setAttribute("href", sidebar.querySelector("a." + userjs.id + "-post-ngs-rels").getAttribute("href"));
all_relationships.closest("li").removeChild(all_relationships.closest("li").querySelector("ul"));
all_relationships.parentNode.removeChild(all_relationships.parentNode.lastChild);
}
}
});
xhr_cool_search_links.open("get", refine_sidebar + "&conditions.1.field=type&conditions.1.operator=%3D&conditions.1.args=233&conditions.1.args=234&conditions.1.args=235", true);
xhr_cool_search_links.send(null);
}
}
} else {
var searchHelp = document.querySelector("table.search-help > tbody");
if (searchHelp && is_edit_search) {
var refines = document.createElement("td");
var refine_search;
var notme = "&conditions.2099.field=editor&conditions.2099.operator=%21%3D&conditions.2099.name=%myName%&conditions.2099.args.0=%myID%";
var novote = "&conditions.2098.field=voter&conditions.2098.operator=%3D&conditions.2098.name=%myName%&conditions.2098.voter_id=%myID%&conditions.2098.args=no";
var onlyEffective = "&conditions.2097.field=status&conditions.2097.operator=%3D&conditions.2097.args=1&conditions.2097.args=2";
if (
(refine_search = document.querySelector("table.search-help td > a[href^='" + MBS + "/search/edits?'][href*='&conditions.']")) &&
(refine_search = refine_search.getAttribute("href").replace(/&?form_only=yes/, ""))
) {
if (location.pathname.match(/\bedits$/)) {
// No need for effective edit filter in /user/xxx/edits/(accepted|applied|autoedits|cancelled|failed|open|rejected)
refines.appendChild(document.createTextNode(" | "));
refines.appendChild(createTag("a", {a: {href: refine_search + onlyEffective}}, "Effective edits (open or applied)"));
}
if (location.href.indexOf(account.pathname) < 0 && typeof __MB__ !== "undefined") {
var myID = __MB__.$c.user.id;
if (myID) {
if (myID != localStorage.getItem(userjs.id + "me-userid")) localStorage.setItem(userjs.id + "me-userid", myID);
if (!location.pathname.match(/^\/user\//)) {
refines.appendChild(document.createTextNode(" | "));
refines.appendChild(createTag("a", {a: {href: refine_search + notme.replace(/%myID%/g, myID).replace(/%myName%/g, escape(account.name))}}, "Exclude my own edits"));
}
if (!location.pathname.match(/\/edits\/autoedits/)) {
novote = notme + novote;
refines.appendChild(document.createTextNode(" | "));
refines.appendChild(createTag("a", {a: {href: refine_search + novote.replace(/%myID%/g, myID).replace(/%myName%/g, escape(account.name))}}, "Edits I have not voted"));
}
}
}
}
if (refines.childElementCount > 0) {
refines.removeChild(refines.firstChild);
searchHelp.insertBefore(createTag("tr", {a: {title: userjs.name}, s: {"text-shadow": "0 0 8px purple"}}, [createTag("th", {}, "Cool links: "), refines]), searchHelp.lastChild);
}
}
}
}
function entitySpecificEdits(entityType, refine, searchMode) {
var editTypes = [];
var linkTypes = [];
if (searchMode.match(/pure/)) {
switch (entityType) {
case "artist":
/* Add artist */ editTypes.push("1");
/* Add artist alias */ editTypes.push("6");
/* Add artist annotation */ editTypes.push("5");
/* Change artist quality (historic) */ editTypes.push("252");
/* Edit artist */ editTypes.push("2");
/* Edit artist alias */ editTypes.push("8");
/* Edit artist credit */ editTypes.push("9");
/* Edit URL */ editTypes.push("101");
/* Merge artists */ editTypes.push("4");
/* Remove artist */ editTypes.push("3");
/* Remove artist alias */ editTypes.push("7");
break;
case "label":
/* Add label */ editTypes.push("10");
/* Add label alias */ editTypes.push("16");
/* Add label annotation */ editTypes.push("15");
/* Edit label */ editTypes.push("11");
/* Edit label alias */ editTypes.push("18");
/* Edit URL */ editTypes.push("101");
/* Merge labels */ editTypes.push("14");
/* Remove label */ editTypes.push("13");
/* Remove label alias */ editTypes.push("17,262");
break;
case "recording":
/* Add disc ID */ editTypes.push("55,232");
/* Add ISRCs */ editTypes.push("76");
/* Add medium */ editTypes.push("51");
/* Add recording alias */ editTypes.push("711");
/* Add recording annotation */ editTypes.push("75");
/* Add release (historic) */ editTypes.push("216");
/* Add standalone recording */ editTypes.push("71");
/* Add track (historic) */ editTypes.push("207,218");
/* Edit medium */ editTypes.push("52");
/* Edit recording */ editTypes.push("72,204,245");
/* Edit recording alias */ editTypes.push("713");
/* Edit track (historic) */ editTypes.push("205,210");
/* Merge recordings */ editTypes.push("74");
/* Move disc ID */ editTypes.push("56,221");
/* Remove disc ID */ editTypes.push("54,220");
/* Remove ISRC */ editTypes.push("78");
/* Remove medium */ editTypes.push("53");
/* Remove recording */ editTypes.push("73");
/* Remove recording alias */ editTypes.push("712");
/* Remove release */ editTypes.push("212,310");
/* Remove releases (historic) */ editTypes.push("224");
/* Remove track */ editTypes.push("211");
/* Set track lengths */ editTypes.push("58,253");
break;
case "release":
/* Add disc ID */ editTypes.push("55,232");