Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions bandcamp_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions batch-add-recording-relationships.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions cd1d_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions deezer_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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 = {
Expand All @@ -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,
Expand Down
26 changes: 13 additions & 13 deletions discogs_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (DEBUG) {

const mbLinks = new MBLinks('DISCOGS_MBLINKS_CACHE', '1');

$(document).ready(function () {
document.addEventListener('DOMContentLoaded', () => {
MBImportStyle();
MBSearchItStyle();

Expand Down Expand Up @@ -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];
}
});
Expand All @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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),
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion encyclopedisque_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+)/)) {
Expand Down
2 changes: 1 addition & 1 deletion fma_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hdtracks_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
Expand Down
2 changes: 1 addition & 1 deletion juno_download_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 8 additions & 10 deletions lib/mblinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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));
});
Expand Down Expand Up @@ -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));
});
}
Expand All @@ -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());
},
);
},
Expand Down Expand Up @@ -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 } : {};
Expand Down
2 changes: 1 addition & 1 deletion loot_importer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions mb_discids_detector.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
});

Expand Down
6 changes: 3 additions & 3 deletions mb_relationship_shortcuts.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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 += `<img src='${relationsIconsURLs[targettype][reltype]}' />(${urls.length})&nbsp;`;
} else {
$.each(urls, function (index, url) {
urls.forEach(url => {
html += `<a href='${url}'><img src='${relationsIconsURLs[targettype][reltype]}' /></a>&nbsp;`;
});
}
Expand Down
Loading