Musicbrainz Artist SAMBL Button

Adds a SAMBL Button to compatible artists

当前为 2024-11-04 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Musicbrainz Artist SAMBL Button
// @description  Adds a SAMBL Button to compatible artists
// @version      2024-11-04
// @author       Lioncat6
// @license      MIT
// @namespace    https://github.com/Lioncat6/MusicBrainz-UserScripts/
// @homepageURL  https://github.com/Lioncat6/MusicBrainz-UserScripts/
// @supportURL   https://github.com/Lioncat6/MusicBrainz-UserScripts/issues
// @match        https://musicbrainz.org/artist/*
// @icon         https://lioncat6.github.io/SAMBL/assets/images/favicon.svg
// @grant        none
// ==/UserScript==

(function () {
	"use strict";
	let artistName = document.getElementsByClassName("artistheader")[0].getElementsByTagName("h1")[0];
	let mbid = document.location.href.split("/").pop();
	let spIcons = document.getElementsByClassName("spotify-favicon");
	if (spIcons) {
		let spids = "";
		for (let icon of spIcons) {
			let spUrl = icon.getElementsByTagName("a")[0].href;
			let spId = spUrl.match(/\/artist\/([^/?]+)/)[1];
			if (spids == "") {
				spids = spId;
			} else {
				spids = spids + "," + spId;
			}
		}
        let htmlToInsert = `<a href="https://lioncat6.github.io/SAMBL/artist/?spid=${spids}&artist_mbid=${mbid}"><img src="https://lioncat6.github.io/SAMBL/assets/images/favicon.svg" alt="SAMBL Icon" style="width: 18px; transform: scale(1.8) translate(6px, 2.5px);"></a>`;
        if (spIcons.length > 1){
            htmlToInsert = `<a href="https://lioncat6.github.io/SAMBL/artist/?spids=${spids}&artist_mbid=${mbid}"><img src="https://lioncat6.github.io/SAMBL/assets/images/favicon.svg" alt="SAMBL Icon" style="width: 18px; transform: scale(1.8) translate(6px, 2.5px);"></a>`;
        }
		artistName.innerHTML = artistName.innerHTML + htmlToInsert;
	}
})();