diff --git a/bandcamp_importer.user.js b/bandcamp_importer.user.js
index e7a62d6..3d45cfb 100644
--- a/bandcamp_importer.user.js
+++ b/bandcamp_importer.user.js
@@ -120,7 +120,7 @@ const BandcampImport = {
}
let tracks_streamable = 0;
- $.each(bandcampAlbumData.trackinfo, function (index, bctrack) {
+ bandcampAlbumData.trackinfo.forEach(bctrack => {
let title = bctrack.title;
let artist = [];
if (various_artists) {
@@ -355,7 +355,7 @@ const collectDiscographyReleaseLinks = ({ linksMatcher, hostname, insertionLocat
return urls_data;
};
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
/* keep the following line as first, it is required to skip
* pages which aren't actually a bandcamp page, since we support
* bandcamp pages under third-party domains.
diff --git a/batch-add-recording-relationships.user.js b/batch-add-recording-relationships.user.js
index 8d90d6c..06d0c6c 100644
--- a/batch-add-recording-relationships.user.js
+++ b/batch-add-recording-relationships.user.js
@@ -524,8 +524,8 @@ function batch_recording_rels(gm_info) {
TOTAL_PAGES = Math.ceil((re_match ? parseInt(re_match[1], 10) : 1) / 2);
}
- let NAME_FILTER = $.trim($('#id-filter\\.name').val());
- let ARTIST_FILTER = $.trim($('#id-filter\\.artist_credit_id').find('option:selected').text());
+ let NAME_FILTER = $('#id-filter\\.name').val().trim();
+ let ARTIST_FILTER = $('#id-filter\\.artist_credit_id').find('option:selected').text().trim();
if (NAME_FILTER || ARTIST_FILTER) {
get_filtered_page(0);
@@ -1096,7 +1096,7 @@ function batch_recording_rels(gm_info) {
let $button = $(this).attr('disabled', true).css('color', '#EAEAEA');
- $.each($rows, function (i, row) {
+ $rows.forEach(row => {
let $row = $(row);
let $title_cell = rowTitleCell($row);
let title = $title_cell.find(TITLE_SELECTOR).text();
@@ -1163,7 +1163,7 @@ function batch_recording_rels(gm_info) {
$button.attr('disabled', false).css('color', '#565656');
}
- $.each($rows, function (i, row) {
+ $rows.forEach(row => {
let $row = $(row);
let mbid = $row.data('suggested_work_mbid');
let title = $row.data('suggested_work_title');
diff --git a/cd1d_importer.user.js b/cd1d_importer.user.js
index 3686f6f..46886f3 100644
--- a/cd1d_importer.user.js
+++ b/cd1d_importer.user.js
@@ -225,13 +225,13 @@ const CD1DImporter = {
.get();
// Tracks
- $.each(this.getTracks(format.id), function () {
+ this.getTracks(format.id).forEach(tracks => {
let thisdisc = {
tracks: [],
format: release.format,
};
release.discs.push(thisdisc);
- $.each(this, function (ntrack, track) {
+ tracks.forEach(track => {
thisdisc.tracks.push({
title: track.title,
duration: track.duration,
@@ -260,7 +260,7 @@ const CD1DImporter = {
},
};
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
MBImportStyle();
/* CD1D uses same page with hidden tabs for all formats */
let formats = CD1DImporter.getFormats();
diff --git a/deezer_importer.user.js b/deezer_importer.user.js
index 6e52286..0d56352 100644
--- a/deezer_importer.user.js
+++ b/deezer_importer.user.js
@@ -18,7 +18,7 @@
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
this.$ = this.jQuery = jQuery.noConflict(true);
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
let gmXHR;
if (typeof GM_xmlhttpRequest != 'undefined') {
@@ -76,7 +76,7 @@ function parseDeezerRelease(releaseUrl, data) {
discs: [],
};
- $.each(data.contributors, function (index, artist) {
+ data.contributors.forEach(artist => {
if (artist.role != 'Main') return true;
let ac = {
@@ -97,7 +97,7 @@ function parseDeezerRelease(releaseUrl, data) {
tracks: [],
};
- $.each(data.tracks.data, function (index, track) {
+ data.tracks.data.forEach(track => {
let t = {
number: index + 1,
title: track.title_short,
diff --git a/discogs_importer.user.js b/discogs_importer.user.js
index b1bb7b2..98d2446 100644
--- a/discogs_importer.user.js
+++ b/discogs_importer.user.js
@@ -35,7 +35,7 @@ if (DEBUG) {
const mbLinks = new MBLinks('DISCOGS_MBLINKS_CACHE', '1');
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
MBImportStyle();
MBSearchItStyle();
@@ -203,12 +203,12 @@ function insertMBLinks(current_page_key) {
// ['discogs_type 1', 'discogs_type 2']
// [['discogs_type 1', 'mb type 1'], 'discogs_type 2']
// etc.
- if (!$.isArray(types)) {
+ if (!Array.isArray(types)) {
// just one string
types = [types];
}
- $.each(types, function (idx, val) {
- if (!$.isArray(val)) {
+ types.forEach((val, idx) => {
+ if (!Array.isArray(val)) {
types[idx] = [val, undefined];
}
});
@@ -220,7 +220,7 @@ function insertMBLinks(current_page_key) {
magnifyLinks(node);
debug_color(this, ++add_mblinks_counter, selector);
const that = this;
- $.each(types, function (idx, val) {
+ types.forEach(val => {
const discogs_type = val[0];
const mb_type = val[1];
searchAndDisplayMbLinkInSection($(that), discogs_type, mb_type, nosearch);
@@ -309,7 +309,7 @@ function magnifyLinks(rootNode) {
let elem = elems[i];
// Ignore empty links
- if (!elem.href || $.trim(elem.textContent) === '' || elem.textContent.substring(4, 0) === 'http') continue;
+ if (!elem.href || elem.textContent.trim() === '' || elem.textContent.substring(4, 0) === 'http') continue;
if (!elem.hasAttribute('mlink')) {
elem.setAttribute('mlink', getDiscogsLinkKey(elem.href));
}
@@ -528,7 +528,7 @@ function parseDiscogsRelease(discogsRelease) {
// Release artist credit
release.artist_credit = [];
- $.each(discogsRelease.artists, function (index, artist) {
+ discogsRelease.artists.forEach(artist => {
let ac = {
artist_name: artistNoNum(artist.name),
credited_name: artist.anv != '' ? artist.anv : artistNoNum(artist.name),
@@ -564,7 +564,7 @@ function parseDiscogsRelease(discogsRelease) {
// Release labels
release.labels = [];
if (discogsRelease.labels) {
- $.each(discogsRelease.labels, function (index, label) {
+ discogsRelease.labels.forEach(label => {
const labelInfo = {
name: label.name,
catno: label.catno === 'none' ? '[none]' : label.catno,
@@ -591,7 +591,7 @@ function parseDiscogsRelease(discogsRelease) {
}
if (discogsRelease.formats[i].descriptions) {
- $.each(discogsRelease.formats[i].descriptions, function (index, desc) {
+ discogsRelease.formats[i].descriptions.forEach(desc => {
if (!(discogs_format in ['Box Set'])) {
// Release format: special handling of Vinyl and Shellac 7", 10" and 12"
if (desc.match(/7"|10"|12"/) && discogs_format.concat(desc) in MediaTypes)
@@ -656,7 +656,7 @@ function parseDiscogsRelease(discogsRelease) {
// Barcode
if (discogsRelease.identifiers) {
- $.each(discogsRelease.identifiers, function (index, identifier) {
+ discogsRelease.identifiers.forEach(identifier => {
if (identifier.type === 'Barcode' && identifier.value !== null) {
release.barcode = identifier.value.replace(/ /g, '');
return false;
@@ -668,7 +668,7 @@ function parseDiscogsRelease(discogsRelease) {
let heading = '';
let releaseNumber = 1;
let lastPosition = 0;
- $.each(discogsRelease.tracklist, function (index, discogsTrack) {
+ discogsRelease.tracklist.forEach(discogsTrack => {
if (discogsTrack.type_ === 'heading') {
heading = discogsTrack.title;
return;
@@ -685,7 +685,7 @@ function parseDiscogsRelease(discogsRelease) {
// Track artist credit
track.artist_credit = [];
if (discogsTrack.artists) {
- $.each(discogsTrack.artists, function (index, artist) {
+ discogsTrack.artists.forEach(artist => {
const ac = {
artist_name: artistNoNum(artist.name),
credited_name: artist.anv !== '' ? artist.anv : artistNoNum(artist.name),
@@ -706,7 +706,7 @@ function parseDiscogsRelease(discogsRelease) {
// Append titles of sub-tracks to main track title
const subtrack_titles = [];
let subtrack_total_duration = 0;
- $.each(discogsTrack.sub_tracks, function (subtrack_index, subtrack) {
+ discogsTrack.sub_tracks.forEach(subtrack => {
if (subtrack.type_ !== 'track') {
return;
}
diff --git a/encyclopedisque_importer.user.js b/encyclopedisque_importer.user.js
index 2f8a8d9..1f202df 100644
--- a/encyclopedisque_importer.user.js
+++ b/encyclopedisque_importer.user.js
@@ -17,7 +17,7 @@
const mbLinks = new MBLinks('ENCYLOPEDISQUE_MBLINKS_CACHE');
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
MBImportStyle();
if (window.location.href.match(/encyclopedisque\.fr\/disque\/(\d+)/)) {
diff --git a/fma_importer.user.js b/fma_importer.user.js
index 09c7b0a..74cceff 100644
--- a/fma_importer.user.js
+++ b/fma_importer.user.js
@@ -48,7 +48,7 @@ const release_attributes = {}; // albumid, total_pages, artist_name, label
const album_api_array = []; // album information [0]
const tracks_api_array = []; // track information [0,1,2,..] one element for each pagination in FMA tracks API
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
// if we have something on local storage place that
if (localStorage.getItem('FMA_API_KEY')) {
FMA_API = localStorage.getItem('FMA_API_KEY'); // -> YOURAPIKEY
diff --git a/hdtracks_importer.user.js b/hdtracks_importer.user.js
index 9722b8c..d007ecd 100644
--- a/hdtracks_importer.user.js
+++ b/hdtracks_importer.user.js
@@ -18,7 +18,7 @@
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
this.$ = this.jQuery = jQuery.noConflict(true);
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
MBImportStyle();
window.addEventListener('hashchange', parsePage); // HDtracks is a single page app (SPA)
});
diff --git a/juno_download_importer.user.js b/juno_download_importer.user.js
index 21fa545..df7bd9a 100644
--- a/juno_download_importer.user.js
+++ b/juno_download_importer.user.js
@@ -17,7 +17,7 @@
// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant
this.$ = this.jQuery = jQuery.noConflict(true);
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
MBImportStyle();
let releaseUrl = window.location.href.replace('/?.*$/', '').replace(/#.*$/, '');
let release = retrieveReleaseInfo(releaseUrl);
diff --git a/lib/mblinks.js b/lib/mblinks.js
index 50e8d7a..865d9d2 100644
--- a/lib/mblinks.js
+++ b/lib/mblinks.js
@@ -2,7 +2,7 @@
// The main method is searchAndDisplayMbLink()
// Example:
-// $(document).ready(function () {
+// document.addEventListener('DOMContentLoaded', () => {
//
// var mblinks = new MBLinks('EXAMPLE_MBLINKS_CACHE', 7*24*60); // force refresh of cached links once a week
//
@@ -213,7 +213,7 @@ const MBLinks = function (user_cache_key, version, expiration) {
this.clearCacheExpired = function () {
let new_cache = {};
let that = this;
- $.each(this.cache, function (key) {
+ this.cache.forEach(key => {
if (that.is_cached(key)) {
new_cache[key] = that.cache[key];
}
@@ -280,7 +280,7 @@ const MBLinks = function (user_cache_key, version, expiration) {
if (!key) key = url;
if (this.is_cached(key)) {
- $.each(mblinks.cache[key].urls, function (idx, cacheEntry) {
+ mblinks.cache[key].urls.forEach(cacheEntry => {
const mb_url = typeof cacheEntry === 'string' ? cacheEntry : cacheEntry.url;
insert_func(mblinks.createMusicBrainzLink(mb_url, _type));
});
@@ -319,13 +319,13 @@ const MBLinks = function (user_cache_key, version, expiration) {
timestamp: new Date().getTime(),
urls: [],
};
- $.each(data['relations'], function (idx, relation) {
+ data['relations'].forEach(relation => {
if (ctx._type in relation) {
let mb_url = `${mbl.mb_server}/${ctx.mb_type}/${relation[ctx._type]['id']}`;
- if ($.inArray(mb_url, mbl.cache[ctx.key].urls) == -1) {
+ if (!mbl.cache[ctx.key].urls.includes(mb_url)) {
// prevent dupes
mbl.cache[ctx.key].urls.push(mb_url);
- $.each(ctx.handlers, function (i, handler) {
+ ctx.handlers.forEach(handler => {
handler(mbl.createMusicBrainzLink(mb_url, ctx._type));
});
}
@@ -335,9 +335,7 @@ const MBLinks = function (user_cache_key, version, expiration) {
}
},
function () {
- $.each(ctx.completionHandlers, function (i, fn) {
- fn();
- });
+ ctx.completionHandlers.forEach(fn => fn());
},
);
},
@@ -370,7 +368,7 @@ const MBLinks = function (user_cache_key, version, expiration) {
if (this.is_cached(key)) {
// Handle cached results immediately
const data_type = data.mb_type.replace('-', '_');
- $.each(mblinks.cache[key].urls, function (idx, cacheEntry) {
+ mblinks.cache[key].urls.forEach(cacheEntry => {
const mb_url = typeof cacheEntry === 'string' ? cacheEntry : cacheEntry.url;
const ended = typeof cacheEntry === 'string' ? false : cacheEntry.ended;
const options = data_type === 'release' ? { ended } : {};
diff --git a/loot_importer.user.js b/loot_importer.user.js
index 5320dcf..8b40c2a 100644
--- a/loot_importer.user.js
+++ b/loot_importer.user.js
@@ -34,7 +34,7 @@ if (DEBUG) {
* - http://www.loot.co.za/product/bette-midler-a-gift-of-love/mhgm-3483-g060 *** NOT WORKING *** extra tab
*/
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
LOGGER.info('Document Ready & Loot Userscript executing');
let LootRelease = ParseLootPage();
insertMBSection(LootRelease);
diff --git a/mb_discids_detector.user.js b/mb_discids_detector.user.js
index 5e511ed..f1fa391 100644
--- a/mb_discids_detector.user.js
+++ b/mb_discids_detector.user.js
@@ -26,7 +26,7 @@ LOGGER.setLevel('info');
const CHECK_IMAGE =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/gD+AP7rGNSCAAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAQAAAAEABcxq3DAAADKklEQVQ4y32TS2hcZRiGn/8/Z87MNNc2zczEmptO0jSXagJtXCjWhhSEXpCI4EYENy6KG8FFBYtgEbzQ4k5QqNp2VyMtJVGpRU0tGDNoQxvrmCbkMslkSJrJXM6cOef8v4ukQqX4wbP5eL/327wv/M/Em+qNeFO9ASDEwzUPrM+fP8dqOhXqeGJ/f21ddCAYCsfRyFLJvru2mvnh9mTil8am1uJLQ8ceNOhoa+XC8HfMJm81x1q63glV179oBMLVhpQYEiQKzy0VNtZWLs9OT53s6X3qrxPHX+bSyNVNgyujV8lvrDXG2vZ/7oWig64nAY0hwZCCgIRwUGBJRSGbvp6cHH91R33078ODTyNOnXqPxcRl88ibX5wuBJuP5x2BVhop2PwuBA01kn2tJo4HtxfL5DIzZ7+/8MHrOx7tcMQ3I9dwnWKvF+kfTdlVEc/10f59A0HAgMEui90xgxvTLn8u+9SYhXUnNX60smr7z7Jx3wG8UOSZhUI4spJTrGwo0lssZxVSQlOdZGrJYyzpks4qlvLBWhWMHOgb7Mfsq4PfXOvx+bwgk/WxSwrfUwRNQSgAh7oCFB3N1xNllrMK04A5V7PLMOOvCSFMgFzJl6u2Jl8Gx9XkCppSWdEWNWiPGZy9XmIs6WJKKHuasq+p3qlkOwhz9B54dnbOkorOR0yG9gZJ3fP5cNTm4J4Akws+FyfKOK5GCFAatm/T4ObmB7RWxt74k9hrC0LVtLwwmw2FwyY8323hK2iLGnz2U4lMTiHvR04IGiqLxbrS7x/np3NJozoEmcTFTLTz2U7bivTcXNSsFxWHeyyGE2XGZ7x/j7WGyhA0W3e/LU58eiY1N+0IgLc++or1VLLb6hz6MmPGe/M2NFTBzIpH3lYoX6MQhC1NkzV/p2Jp5JX6eP+vn7wxsJnEXXUVnL6T59K7J/u2tR96365oey7nVQTKnsDzNFr5hETBq3ZmbrB47cS5M2+PdTbHmJpL89+OGbv3dLc81n/kWLih+yDhnTGtEcpeXXHSUz/OJ64M3/ojMS3BUw9rI2BsIUxBsLYyEJYC1nNuqawpARrwtwDgHxTwbTT5CxY9AAAALnpUWHRjcmVhdGUtZGF0ZQAAeNozMjCw0DWw0DUyCTEwsDIyszIw0jUwtTIwAABB3gURQfNnBAAAAC56VFh0bW9kaWZ5LWRhdGUAAHjaMzIwsNA1sNA1MggxNLMyNLYyNtM1MLUyMAAAQgUFF56jVzIAAAAASUVORK5CYII%3D';
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
if (window.location.host.match(/orpheus\.network|redacted\.sh|passtheheadphones\.me|lztr\.(us|me)|mutracker\.org|notwhat\.cd/)) {
LOGGER.info('Gazelle site detected');
gazellePageHandler();
@@ -201,7 +201,7 @@ function computeAttachURL(mb_toc_numbers, artistName, releaseName) {
function analyze_log_files(log_files) {
let discs = [];
- $.each(log_files, function (i, log_file) {
+ log_files.forEach(log_file => {
const discsInLog = MBDiscid.log_input_to_entries($(log_file).text());
for (const disc of discsInLog) {
discs.push(disc);
@@ -278,7 +278,7 @@ const MBDiscid = (function () {
this.log_input_to_entries = function (text) {
let discs = [];
var entries = [];
- $.each(text.split('\n'), function (index, value) {
+ text.split('\n').forEach(value => {
let m = toc_entry_matcher.exec(value);
if (m) {
// New disc
@@ -360,7 +360,7 @@ const MBDiscid = (function () {
(parseInt(entries[entries.length - 1][5], 10) - parseInt(entries[0][4], 10) + 1) / this.SECTORS_PER_SECOND,
);
let checksum = 0;
- $.each(entries, function (index, entry) {
+ entries.forEach(entry => {
checksum += sum_of_digits(Math.floor((parseInt(entry[4], 10) + PREGAP) / SECTORS_PER_SECOND));
});
diff --git a/mb_relationship_shortcuts.user.js b/mb_relationship_shortcuts.user.js
index 6353047..b042bc5 100644
--- a/mb_relationship_shortcuts.user.js
+++ b/mb_relationship_shortcuts.user.js
@@ -134,7 +134,7 @@ this.$ = this.jQuery = jQuery.noConflict(true);
if (!unsafeWindow) unsafeWindow = window;
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
// Get pageType (label or artist)
let parent = {};
let child = {};
@@ -278,12 +278,12 @@ $(document).ready(function () {
}
});
- $.each(relations, function (reltype, urls) {
+ Object.entries(relations).forEach(([reltype, urls]) => {
let html = '';
if (urls.length < -1) {
html += `(${urls.length}) `;
} else {
- $.each(urls, function (index, url) {
+ urls.forEach(url => {
html += `
`;
});
}
diff --git a/mb_ui_enhancements.user.js b/mb_ui_enhancements.user.js
index 2f1b4a6..d54b3e8 100644
--- a/mb_ui_enhancements.user.js
+++ b/mb_ui_enhancements.user.js
@@ -53,7 +53,7 @@ function setGoogleSearchMenu() {
}
setGoogleSearchMenu();
-$(document).ready(function () {
+document.addEventListener('DOMContentLoaded', () => {
// Follow the instructions found at https://www.last.fm/api/authentication
// then paste your API Key between the single quotes in the variable below.
const LASTFM_APIKEY = '';
@@ -78,7 +78,7 @@ $(document).ready(function () {
$.getJSON(
`https://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&mbid=${mbid}&api_key=${LASTFM_APIKEY}&format=json`,
function (data) {
- $.each(data.toptracks.track, function (index, track) {
+ data.toptracks.track.forEach(track => {
if (index >= 5) return true;
let url = track.mbid ? `/recording/${track.mbid}` : track.url;
$('ul.toptracks').append(`