Iāve bashed my head against a wall with Gemini⦠It very quickly got the following script right, which checks for artist backlinks (for instance on VA albums):
// ==UserScript==
// @name RateYourMusic to MusicBrainz Linker
// @namespace https://musicbrainz.org/user/yourusername
// @version 1.0
// @description Adds links from RateYourMusic to MusicBrainz entities.
// @author Gemini
// @license MIT
// @match https://rateyourmusic.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
// @require https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/lib/mblinks.js
// @require https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/lib/mbimportstyle.js
// @grant none
// ==/UserScript==
// Prevent JQuery conflicts
this.$ = this.jQuery = jQuery.noConflict(true);
$(document).ready(function() {
MBSearchItStyle();
const mblinks = new MBLinks('RYM_MBLINKS_CACHE');
/**
* Cleans up a Rate Your Music URL to its canonical form.
* @param {string} url - The URL to clean.
* @returns {string} The cleaned URL.
*/
function cleanUrl(url) {
return url.replace(/^(https:\/\/rateyourmusic\.com\/(?:artist|release|label)\/[^/]+).*/, '$1');
}
/**
* Maps Rate Your Music URL paths to MusicBrainz entity types.
* @param {string} path - The path segment from a RYM URL.
* @returns {string|null} The corresponding MusicBrainz entity type or null.
*/
function getMbTypeFromPath(path) {
const typeMap = {
'artist': 'artist',
'release': 'release',
'label': 'label',
};
return typeMap[path] || null;
}
/**
* Gathers all relevant entity links from a given context, groups them by type, and processes them in batches.
* @param {Node} context - The DOM node to search within for links.
*/
function addLinksToPage(context) {
const $context = $(context || document);
const canonicalPathRegex = /^\/(?:artist|release|label)\/.+/;
const urlsToProcess = {};
// Main entity on the page
if (!context || context === document) {
const pageUrl = cleanUrl(window.location.href);
const path = pageUrl.split('/')[3];
const pageType = getMbTypeFromPath(path);
if (pageType) {
if (!urlsToProcess[pageType]) {
urlsToProcess[pageType] = [];
}
urlsToProcess[pageType].push({
url: pageUrl,
mb_type: pageType,
insert_func: function(link) {
const $mbLink = $(link).css({
'margin-left': '8px',
'vertical-align': 'middle',
});
// Target the main page title for link insertion
const $titleElement = $('h1.artist_name_hdr, h1.release_title_hdr, h1.label_title_hdr').first();
if ($titleElement.length) {
$titleElement.append($mbLink);
}
}
});
}
}
// Other entity links within the context (e.g., links in lists or tracklists)
$context.find('a[href*="/artist/"], a[href*="/release/"], a[href*="/label/"]').each(function() {
const $anchor = $(this);
if ($anchor.data('mblinks-added')) {
return;
}
$anchor.data('mblinks-added', true);
const urlObject = new URL($anchor.attr('href'), window.location.href);
if (!canonicalPathRegex.test(urlObject.pathname)) {
return;
}
const url = cleanUrl(urlObject.href);
const path = url.split('/')[3];
const type = getMbTypeFromPath(path);
if (type) {
if (!urlsToProcess[type]) {
urlsToProcess[type] = [];
}
urlsToProcess[type].push({
url: url,
mb_type: type,
insert_func: function(link) {
const $mbLink = $(link).css({
'margin-left': '4px',
'vertical-align': 'middle',
});
// Insert the link after the anchor element
$anchor.after($mbLink);
}
});
}
});
// Process each group of URLs with the correct entity type
for (const type in urlsToProcess) {
if (urlsToProcess.hasOwnProperty(type)) {
mblinks.searchAndDisplayMbLinks(urlsToProcess[type]);
}
}
}
// Initial run on page load
addLinksToPage();
// Observe for dynamically loaded content, as RYM pages can load content asynchronously
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes.length) {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
addLinksToPage(node);
}
});
}
});
});
const targetNode = document.body;
if (targetNode) {
observer.observe(targetNode, {
childList: true,
subtree: true,
});
}
});
But we are at something like v70 trying to get something to work for RYM artist pages/releases (to match to MB release groups)!
I recently got side tracked arguing with Gemini about why it keeps adding āFinalā to the script names when it knows damn well itās doubtful that v71 is suddenly going to work* 
Maybe you are better at giving prompts @chaban? Teach me your waysā¦
I am also curious, what did you mean by āuploaded an example artist pageā? And āpointed it at the murdos repoā? I have been feeding it URLās but Iām unclear how much it scrapes/takes from them
*this is a joke btw peeps, Iām aware that LLM doesnāt āknowā anything