-
Notifications
You must be signed in to change notification settings - Fork 26
/
mb_ALL-RELEASE-GROUPS.user.js
58 lines (58 loc) · 2.73 KB
/
mb_ALL-RELEASE-GROUPS.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
// ==UserScript==
// @name mb. ALL RELEASE GROUPS
// @version 2024.5.16
// @description Artist overview page (discography): Show all release groups by default, then you can filter out bootlegs to show only official release groups (instead of the opposite default)
// @namespace https://github.com/jesus2099/konami-command
// @supportURL https://github.com/jesus2099/konami-command/labels/mb_ALL-RELEASE-GROUPS
// @downloadURL https://github.com/jesus2099/konami-command/raw/master/mb_ALL-RELEASE-GROUPS.user.js
// @author jesus2099
// @contributor Naja Melan’s “Always show all releases on Musicbrainz v1.0” https://web.archive.org/web/20131104205707/userscripts.org/scripts/show/9456
// @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 2019-01-03
// @icon data:image/gif;base64,R0lGODlhEAAQAMIDAAAAAIAAAP8AAP///////////////////yH5BAEKAAQALAAAAAAQABAAAAMuSLrc/jA+QBUFM2iqA2ZAMAiCNpafFZAs64Fr66aqjGbtC4WkHoU+SUVCLBohCQA7
// @grant none
// @include /^https?:\/\//
// @run-at document-start
// ==/UserScript==
"use strict";
var regex_mb_host = "(?:(?:beta|test)\\.)?musicbrainz\\.(?:eu|org)";
document.addEventListener("mousedown", function(event) {
var link = event.target || event.srcElement;
if (link && link.nodeType === Node.ELEMENT_NODE) {
link = link.closest("a[href]:not(.jesus2099-bypass-mb_ALL-RELEASE-GROUPS)");
if (link) {
var href = link.getAttribute("href").trim();
if (href) {
var href_match = href.match(new RegExp("^((?:(?:https?:)?//)?" + regex_mb_host + ")?(/artist/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})(\\?.*)?(#.*)?$"));
if (
href_match
&& (
location.host.match(new RegExp("^" + regex_mb_host + "$")) && href_match[2]
|| href_match[1] && href_match[2]
)
) {
var search = href_match[3] || "";
if (!search.match(/all=/)) {
search = add_search_parameters(search, "all=1");
if (search !== href_match[3]) {
var new_href = (href_match[1] ? href_match[1] : "") + href_match[2] + search + (href_match[4] ? href_match[4] : "");
link.setAttribute("href", new_href);
link.style.setProperty("background-color", "#cfc");
link.style.setProperty("color", "#606");
link.style.setProperty("text-decoration", "line-through");
var tooltip = link.getAttribute("title") || "";
if (tooltip) {
tooltip += "\n";
}
link.setAttribute("title", tooltip + "old: " + href + "\nnew: " + new_href);
}
}
}
}
}
}
});
function add_search_parameters(search, parameters) {
return search + (search.match(/\?/) ? "&" : "?") + parameters;
}