2014-12-21 22:25:10 +00:00
|
|
|
|
// ==UserScript==
|
|
|
|
|
// @name Musicbrainz UI enhancements
|
|
|
|
|
// @description Various UI enhancements for Musicbrainz
|
2023-04-23 20:33:56 +00:00
|
|
|
|
// @version 2023.4.23.1
|
2014-12-21 22:25:10 +00:00
|
|
|
|
// @downloadURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/mb_ui_enhancements.user.js
|
|
|
|
|
// @updateURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/mb_ui_enhancements.user.js
|
|
|
|
|
// @icon http://wiki.musicbrainz.org/-/images/3/3d/Musicbrainz_logo.png
|
|
|
|
|
// @namespace http://userscripts.org/users/22504
|
|
|
|
|
// @include http*://*musicbrainz.org/*
|
2015-09-15 11:00:36 +00:00
|
|
|
|
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.js
|
2014-12-21 22:25:10 +00:00
|
|
|
|
// @require https://raw.github.com/murdos/mbediting.js/master/mbediting.js
|
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
2015-09-15 11:00:36 +00:00
|
|
|
|
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
|
|
|
|
|
this.$ = this.jQuery = jQuery.noConflict(true);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$(document).ready(function () {
|
2023-04-23 20:33:56 +00:00
|
|
|
|
// Follow the instructions found at https://www.last.fm/api/authentication
|
|
|
|
|
// then paste your API Key between the single quotes in the variable below.
|
|
|
|
|
LASTFM_APIKEY = '';
|
2014-12-21 22:25:10 +00:00
|
|
|
|
|
|
|
|
|
// Highlight table rows
|
|
|
|
|
$('table.tbl tbody tr').hover(
|
2020-04-05 14:01:21 +00:00
|
|
|
|
function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$(this)
|
|
|
|
|
.children('td')
|
2020-04-05 14:01:21 +00:00
|
|
|
|
.each(function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let backgroundColor = $(this).css('backgroundColor');
|
|
|
|
|
if (backgroundColor != 'rgb(255, 255, 0)') $(this).css('backgroundColor', '#ffeea8');
|
|
|
|
|
});
|
2014-12-21 22:25:10 +00:00
|
|
|
|
},
|
2020-04-05 14:01:21 +00:00
|
|
|
|
function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$(this)
|
|
|
|
|
.children('td')
|
2020-04-05 14:01:21 +00:00
|
|
|
|
.each(function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let backgroundColor = $(this).css('backgroundColor');
|
|
|
|
|
if (backgroundColor != 'rgb(255, 255, 0)') $(this).css('backgroundColor', '');
|
|
|
|
|
});
|
2014-12-21 22:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let re;
|
2014-12-21 23:03:22 +00:00
|
|
|
|
|
2023-04-23 20:33:56 +00:00
|
|
|
|
// Top tracks from Last.fm
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/artist/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (LASTFM_APIKEY && window.location.href.match(re)) {
|
|
|
|
|
$('h2.discography').before('<h2 class="toptracks">Top Last.fm recordings</h2><ul class="toptracks" />');
|
|
|
|
|
var mbid = window.location.href.match(re)[1];
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let toptracks = $.getJSON(
|
|
|
|
|
`http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&mbid=${mbid}&api_key=${LASTFM_APIKEY}&format=json`,
|
2020-04-05 14:01:21 +00:00
|
|
|
|
function (data) {
|
|
|
|
|
$.each(data.toptracks.track, function (index, track) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
if (index >= 5) return true;
|
|
|
|
|
let url = track.mbid ? `/recording/${track.mbid}` : track.url;
|
|
|
|
|
$('ul.toptracks').append(`<li><a href="${url}">${track.name}</a></li>`);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-14 11:29:36 +00:00
|
|
|
|
// Fix for http://tickets.musicbrainz.org/browse/MBS-750
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/release/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
if ($('table.medium thead').length == 1) {
|
|
|
|
|
let text = $.trim($('table.medium thead').text());
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (text.match(/ 1$/)) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$('table.medium thead a').text(text.replace(/ 1$/, ''));
|
2014-12-21 22:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-14 11:29:36 +00:00
|
|
|
|
// Better fix for http://tickets.musicbrainz.org/browse/MBS-1943
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp(
|
|
|
|
|
'musicbrainz.org/(artist|release-group|release|recording|work|label)/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})',
|
|
|
|
|
'i'
|
|
|
|
|
);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
|
|
|
|
$("#sidebar h2:contains('Rating')").before($("#sidebar h2:contains('External links')"));
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let pageHasRGLinks = $("#sidebar h2:contains('Release group external links')").length > 0;
|
2014-12-21 22:25:10 +00:00
|
|
|
|
$("#sidebar h2:contains('Rating')").before(
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$("#sidebar h2:contains('External links')")
|
|
|
|
|
.nextAll('ul.external_links')
|
2020-04-05 14:01:21 +00:00
|
|
|
|
.filter(function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
return !pageHasRGLinks || $(this).nextAll("h2:contains('Release group external links')").length > 0;
|
|
|
|
|
})
|
|
|
|
|
);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
$("#sidebar h2:contains('Rating')").before($("#sidebar h2:contains('Release group external links')"));
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$("#sidebar h2:contains('Rating')").before($("#sidebar h2:contains('Release group external links')").nextAll('ul.external_links'));
|
2014-12-21 22:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove the affiliate section
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp(
|
|
|
|
|
'musicbrainz.org/(artist|release-group|release|recording|work|label)/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})',
|
|
|
|
|
'i'
|
|
|
|
|
);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
|
|
|
|
$('#sidebar-affiliates').remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Batch merge -> open in a new tab/windows
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp(
|
|
|
|
|
'musicbrainz.org/artist/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/(recordings|releases|works)',
|
|
|
|
|
'i'
|
|
|
|
|
);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$('form')
|
2020-04-05 14:01:21 +00:00
|
|
|
|
.filter(function () {
|
|
|
|
|
return $(this).prop('action').match('merge_queue');
|
2018-11-20 22:18:49 +00:00
|
|
|
|
})
|
|
|
|
|
.attr('target', '_blank');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Modify link to edits: remove " - <Edit type>" from the link "Edit XXXX - <Edit type>"
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/.*/(open_)?edits', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$('div.edit-description ~ h2').each(function () {
|
|
|
|
|
let parts = $(this).find('a').text().split(' - ');
|
|
|
|
|
$(this).find('a').text(parts[0]);
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$(this).append(` - ${parts[1]}`);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add direct link to cover art tab for Add cover art edits
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/(.*/(open_)?edits|edit/d+)', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$("div.edit-description ~ h2:contains('cover art')").each(function () {
|
|
|
|
|
$editdetails = $(this).parents('.edit-header').siblings('.edit-details');
|
2018-11-20 22:18:49 +00:00
|
|
|
|
mbid = $editdetails
|
|
|
|
|
.find("a[href*='musicbrainz.org/release/']")
|
|
|
|
|
.attr('href')
|
|
|
|
|
.match(/\/release\/(.{36})/)[1];
|
|
|
|
|
$editdetails
|
|
|
|
|
.find('tbody td.edit-cover-art')
|
|
|
|
|
.after(`<tr><th span='2'><a href='/release/${mbid}/cover-art'>See all artworks for this release</a></th></tr>`);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Embed Youtube videos
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/recording/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let $youtube_link = $('#sidebar li.youtube-favicon a');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if ($youtube_link.length > 0) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let youtube_id = $youtube_link.prop('href').match(/http:\/\/www\.youtube\.com\/watch\?v=(.*)/)[1];
|
|
|
|
|
$('table.details').width('60%');
|
|
|
|
|
$("h2:contains('Relationships')").after(
|
|
|
|
|
`<iframe width="360" height="275" frameborder="0" style="float: right;" src="https://www.youtube.com/embed/${youtube_id}?rel=0" allowfullscreen=""></iframe>`
|
|
|
|
|
);
|
2014-12-21 22:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-14 11:29:36 +00:00
|
|
|
|
// When attaching CDTOC, autoselect artist when there's only one result
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/cdtoc/attach.*&filter-artist.query=.*', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
|
|
|
|
$artists = $('ul.radio-list li');
|
|
|
|
|
if ($artists.length == 1) {
|
|
|
|
|
$artists.find('input:radio').attr('checked', true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Highlight Year in ISRCs codes
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/artist/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/recordings', 'i');
|
2014-12-21 22:25:10 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let isrcColNo; // = ($("#content table.tbl thead th:eq(2)").text() == "Artist") ? 3 : 2;
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$('#content table.tbl thead th').each(function (index, th) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
if ($(th).text() == 'ISRCs') {
|
2014-12-25 20:28:46 +00:00
|
|
|
|
isrcColNo = index;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-12-21 22:25:10 +00:00
|
|
|
|
});
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$('#content table.tbl tbody tr').each(function () {
|
2023-03-02 20:47:17 +00:00
|
|
|
|
$(this)
|
|
|
|
|
.find(`td:eq(${isrcColNo})`)
|
|
|
|
|
.find('li')
|
|
|
|
|
.each(function () {
|
|
|
|
|
let newHTML = '';
|
|
|
|
|
var isrc = $(this).text();
|
|
|
|
|
newHTML += `<a href='/isrc/${isrc}'><bdi><code>`;
|
|
|
|
|
newHTML += `${isrc.substring(0, 5)}<b>${isrc.substring(5, 7)}</b>${isrc.substring(7)}`;
|
|
|
|
|
newHTML += '</code></bdi></a>';
|
|
|
|
|
$(this).html(newHTML);
|
|
|
|
|
});
|
2014-12-21 22:25:10 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-25 20:14:06 +00:00
|
|
|
|
// Display ISRCs and recording comment on release tracklisting
|
2018-11-20 22:18:49 +00:00
|
|
|
|
re = new RegExp('musicbrainz.org/release/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})#?$', 'i');
|
2014-12-21 23:03:22 +00:00
|
|
|
|
if (window.location.href.match(re)) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let ISRC_COLUMN_POSITION = 2;
|
2014-12-21 23:03:22 +00:00
|
|
|
|
var mbid = window.location.href.match(re)[1];
|
2015-02-14 12:56:20 +00:00
|
|
|
|
// Get tracks data from webservice
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let wsurl = `/ws/2/release/${mbid}?inc=isrcs+recordings`;
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$.getJSON(wsurl, function (data) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
// Store tracks data from webservice in a hash table
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let tracks = {};
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$.each(data.media, function (index, medium) {
|
|
|
|
|
$.each(medium.tracks, function (i, track) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
tracks[track.id] = track;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// Different behavior depending on the number of mediums
|
2015-06-10 20:46:17 +00:00
|
|
|
|
if ($('table.medium').length <= 10) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
// All mediums are already displayed: handle them now
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$('table.medium').each(function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
handleMedium($(this), tracks);
|
2015-02-14 12:56:20 +00:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Each medium will be handled when it's loaded
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let HANDLED_ATTRIBUTE = 'ui_enh_isrcs_handled';
|
2015-02-14 12:56:20 +00:00
|
|
|
|
$('table.medium').attr(HANDLED_ATTRIBUTE, 'no');
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$('table.medium').bind('DOMNodeInserted', function (event) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
$target = $(event.target);
|
2018-11-20 22:18:49 +00:00
|
|
|
|
if (
|
|
|
|
|
$target.prop('nodeName') == 'TBODY' &&
|
|
|
|
|
$target.parent().attr(HANDLED_ATTRIBUTE) == 'no' &&
|
|
|
|
|
$target.find('tr.subh').length > 0
|
|
|
|
|
) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
$medium = $target.parent();
|
|
|
|
|
$medium.attr(HANDLED_ATTRIBUTE, 'pending');
|
|
|
|
|
handleMedium($medium, tracks);
|
|
|
|
|
$medium.attr(HANDLED_ATTRIBUTE, 'done');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function handleMedium($medium, ws_tracks) {
|
2015-02-14 11:29:36 +00:00
|
|
|
|
// Extend colspan for medium table header
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$medium.find('thead tr').each(function () {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$(this)
|
|
|
|
|
.find('th:eq(0)')
|
2020-04-05 14:01:21 +00:00
|
|
|
|
.attr('colspan', $(this).find('th:eq(0)').attr('colspan') * 1 + 1);
|
2014-12-21 23:03:22 +00:00
|
|
|
|
});
|
2015-02-14 11:29:36 +00:00
|
|
|
|
// Table sub-header
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$medium
|
|
|
|
|
.find(`tbody tr.subh th:nth-last-child(${ISRC_COLUMN_POSITION})`)
|
|
|
|
|
.before("<th style='width: 150px;' class='isrc c'> ISRC </th>");
|
2015-02-14 12:56:20 +00:00
|
|
|
|
|
|
|
|
|
// Handle each track
|
2020-04-05 14:01:21 +00:00
|
|
|
|
$medium.find('tbody tr[id]').each(function (index, medium_track) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
track_mbid = $(medium_track).attr('id');
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let isrcsLinks = '';
|
2020-03-14 00:43:40 +00:00
|
|
|
|
if (Object.prototype.hasOwnProperty.call(ws_tracks, track_mbid)) {
|
2015-02-14 12:56:20 +00:00
|
|
|
|
track = ws_tracks[track_mbid];
|
2018-11-20 22:18:49 +00:00
|
|
|
|
let recording = track.recording;
|
2014-12-25 20:14:06 +00:00
|
|
|
|
// Recording comment
|
2018-11-20 22:18:49 +00:00
|
|
|
|
if (recording.disambiguation != '') {
|
2020-04-05 14:01:21 +00:00
|
|
|
|
let td_title_index = $(`#${track_mbid}`).find('td:eq(1)').hasClass('video') ? 2 : 1;
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$(`#${track_mbid}`)
|
|
|
|
|
.find(`td:eq(${td_title_index}) a:eq(0)`)
|
|
|
|
|
.after(` <span class="comment">(${recording.disambiguation})</span>`);
|
2014-12-25 20:14:06 +00:00
|
|
|
|
}
|
|
|
|
|
// ISRCS
|
|
|
|
|
if (recording.isrcs.length != 0) {
|
2020-04-05 14:01:21 +00:00
|
|
|
|
let links = jQuery.map(recording.isrcs, function (isrc, i) {
|
2018-11-20 22:18:49 +00:00
|
|
|
|
return `<a href='/isrc/${isrc}'>${isrc}</a>`;
|
2014-12-21 23:03:22 +00:00
|
|
|
|
});
|
2018-11-20 22:18:49 +00:00
|
|
|
|
isrcsLinks = links.join(', ');
|
2014-12-21 23:03:22 +00:00
|
|
|
|
}
|
2015-02-14 12:56:20 +00:00
|
|
|
|
}
|
2018-11-20 22:18:49 +00:00
|
|
|
|
$(`#${track_mbid}`)
|
|
|
|
|
.find(`td:nth-last-child(${ISRC_COLUMN_POSITION})`)
|
|
|
|
|
.before(`<td class='isrc c'><small>${isrcsLinks}</small></td>`);
|
2014-12-21 23:03:22 +00:00
|
|
|
|
});
|
2015-02-14 12:56:20 +00:00
|
|
|
|
}
|
2014-12-21 23:03:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 16:30:55 +00:00
|
|
|
|
// Display a-tisket links next to Deezer, Spotify, iTunes and Apple Music links
|
|
|
|
|
re = new RegExp('musicbrainz.org/release/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})', 'i');
|
|
|
|
|
if (window.location.href.match(re)) {
|
|
|
|
|
document.querySelectorAll('div#bottom-credits a').forEach(function (link) {
|
|
|
|
|
if (link.href.match(/deezer.com|(music|itunes).apple.com|spotify.com/)) {
|
2020-09-13 16:05:28 +00:00
|
|
|
|
let id;
|
|
|
|
|
let fragment;
|
2022-12-26 13:13:52 +00:00
|
|
|
|
let country;
|
2020-07-08 16:30:55 +00:00
|
|
|
|
if (link.href.match(/deezer.com/)) {
|
|
|
|
|
id = new URL(link.href).pathname.split('/').slice(-1)[0];
|
|
|
|
|
fragment = 'deez';
|
2022-12-26 13:13:52 +00:00
|
|
|
|
country = 'GB%2CUS%2CIN';
|
2020-07-08 16:30:55 +00:00
|
|
|
|
} else if (link.href.match(/apple.com/)) {
|
|
|
|
|
id = new URL(link.href).pathname.split('/', 5).slice(-1)[0].replace('id', '');
|
|
|
|
|
fragment = 'itu';
|
2022-12-26 13:13:52 +00:00
|
|
|
|
country = new URL(link.href).pathname.split('/',2)[1];
|
2020-07-08 16:30:55 +00:00
|
|
|
|
} else if (link.href.match(/spotify.com/)) {
|
|
|
|
|
id = new URL(link.href).pathname.split('/', 5).slice(-1)[0];
|
|
|
|
|
fragment = 'spf';
|
2022-12-26 13:13:52 +00:00
|
|
|
|
country = 'GB%2CUS%2CIN';
|
2020-07-08 16:30:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 16:05:28 +00:00
|
|
|
|
let next = link.nextElementSibling.nextElementSibling;
|
|
|
|
|
let newlink = document.createElement('a');
|
2022-12-26 13:13:52 +00:00
|
|
|
|
newlink.href = `https://atisket.pulsewidth.org.uk/?preferred_countries=${country}&${fragment}_id=${id}&preferred_vendor=${fragment}`;
|
2020-07-08 16:30:55 +00:00
|
|
|
|
newlink.text = 'a-tisket';
|
|
|
|
|
|
|
|
|
|
next.before(document.createTextNode(' ['));
|
|
|
|
|
next.before(newlink);
|
|
|
|
|
next.before(document.createTextNode(']'));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-14 11:29:36 +00:00
|
|
|
|
// Discogs link rollover
|
2014-12-21 22:25:10 +00:00
|
|
|
|
// TODO...
|
|
|
|
|
|
|
|
|
|
// -------------- End of script ------------------------
|
2015-09-15 11:00:36 +00:00
|
|
|
|
});
|