Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/content/engines/integrations/musicbrainz.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

var Def = window.__servarrEngines.helpers.DefaultEngine;

function getHref(sel, doc) { var a = doc.querySelector(sel); return (a && a.href) || ''; }
function getHref(sel, doc) {
// Fall back to just selecting the link if we don't find it with `:has`, for browser support
var a = doc.querySelector(sel) || doc.querySelector(sel.replace(/:has\([^)]+\)/g, ''));
return (a && a.href) || '';
}

var Artist = Def({
id: 'musicbrainz',
Expand All @@ -14,7 +18,7 @@
insertWhere: 'prepend',
iconStyle: 'width: 26px; margin: 0 5px -4px 0;',
getSearch: function (_el, doc) {
var href = getHref('.artistheader > h1 > a', doc);
var href = getHref('.artistheader > h1 a:has(bdi)', doc);
return href ? href.replace('https://musicbrainz.org', '').replace('/artist/', 'lidarr:') : '';
}
});
Expand All @@ -28,7 +32,7 @@
insertWhere: 'prepend',
iconStyle: 'width: 26px; margin: 0 5px -4px 0;',
getSearch: function (_el, doc) {
var href = getHref('.rgheader > h1 > a', doc);
var href = getHref('.rgheader > h1 a:has(bdi)', doc);
return href ? href.replace('https://musicbrainz.org', '').replace('/release-group/', 'lidarr:') : '';
}
});
Expand All @@ -42,7 +46,7 @@
insertWhere: 'prepend',
iconStyle: 'width: 26px; margin: 0 5px -4px 0;',
getSearch: function (_el, doc) {
var href = getHref('.releaseheader > h1 > a', doc);
var href = getHref('.releaseheader > h1 a:has(bdi)', doc);
return href ? href.replace('https://musicbrainz.org', '').replace('/release/', 'lidarr:') : '';
}
});
Expand Down
Loading