From 6645a440f6841825f35391ecc58c1c0500a98f1c Mon Sep 17 00:00:00 2001 From: Kai Date: Sun, 10 Apr 2022 02:06:39 +0000 Subject: [PATCH] bandcamp_importer_helper.user.js & mbimportstyle.js: remove jquery --- bandcamp_importer_helper.user.js | 29 +++++++++++++++++------------ lib/mbimportstyle.js | 4 +--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/bandcamp_importer_helper.user.js b/bandcamp_importer_helper.user.js index e5e9892..94cc089 100644 --- a/bandcamp_importer_helper.user.js +++ b/bandcamp_importer_helper.user.js @@ -1,31 +1,36 @@ // ==UserScript== // @name Import Bandcamp releases to MusicBrainz Album Link Helper // @description Add a link to Bandcamp's album canonical URL on pages without /album/, for one to import the release into MusicBrainz -// @version 2018.2.18.1 +// @version 2022.4.10.1 // @namespace http://userscripts.org/users/22504 // @downloadURL https://raw.github.com/murdos/musicbrainz-userscripts/master/bandcamp_importer_helper.user.js // @updateURL https://raw.github.com/murdos/musicbrainz-userscripts/master/bandcamp_importer_helper.user.js // @include http*://*.bandcamp.com/ // @include http*://*.bandcamp.com/releases // @exclude http*://*.bandcamp.com/*/* -// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js // @require lib/logger.js // @icon https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/assets/images/Musicbrainz_import_logo.png // @grant unsafeWindow // ==/UserScript== -// prevent JQuery conflicts, see http://wiki.greasespot.net/@grant -this.$ = this.jQuery = jQuery.noConflict(true); - if (!unsafeWindow) unsafeWindow = window; -$(document).ready(function () { - // Display a link to the correct album bandcamp url (ie. main page or releases page) - let bandcampAlbumData = unsafeWindow.TralbumData; +const ready = function (fn) { + if (document.readyState !== 'loading') { + fn(); + } else { + document.addEventListener('DOMContentLoaded', fn); + } +}; + +ready(function () { + // Display a link to the correct album bandcamp url (i.e. main page or releases page) + const bandcampAlbumData = unsafeWindow.TralbumData; if (bandcampAlbumData && bandcampAlbumData.url) { - let innerHTML = `${'
' + 'Album page (MB import)
`; - $('#name-section').append(innerHTML); + const innerHTML = ` +
+ Album page (MB import) +
`; + document.querySelector('#name-section').insertAdjacentHTML('beforeend', innerHTML); } }); diff --git a/lib/mbimportstyle.js b/lib/mbimportstyle.js index 950bcb9..46a7f77 100644 --- a/lib/mbimportstyle.js +++ b/lib/mbimportstyle.js @@ -1,12 +1,10 @@ function _add_css(css) { - $(``).appendTo('head'); + document.head.insertAdjacentHTML('beforeend', ``); } function MBImportStyle() { let css_import_button = ` .musicbrainz_import button { - -moz-border-radius:5px; - -webkit-border-radius:5px; border-radius:5px; display:inline-block; cursor:pointer;