Skip to content

Commit

Permalink
Small code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Apr 14, 2021
1 parent 86651de commit 39979fa
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions mb-magic-tagger-button.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name MusicBrainz Magic Tagger Button
// @description Automatically enable the green tagger button on MusicBrainz.org depending on whether Picard is running.
// @version 0.5.2
// @version 0.5.3
// @author Philipp Wolfer
// @namespace https://uploadedlobster.com
// @license MIT
Expand Down Expand Up @@ -77,11 +77,7 @@ async function probeTagger (port) {
const response = await makeRequest('GET', `http://${TAGGER_HOST}:${port}`)
debug(response)
const text = response.responseText || ''
if (text.match(/MusicBrainz-Picard/) || text.match(/Nothing to see here/)) {
return true
} else {
return false
}
return text.match(/MusicBrainz-Picard/) || text.match(/Nothing to see here/)
} catch (reason) {
warn(reason)
return false
Expand All @@ -98,9 +94,9 @@ async function detectTaggerPort () {
}

function findTaggerButton () {
const buttons = document.getElementsByClassName('tagger-icon')
if (buttons[0] && buttons[0].href) {
const url = new URL(buttons[0].href)
const button = document.getElementsByClassName('tagger-icon')[0]
if (button && button.href) {
const url = new URL(button.href)
return {
protocol: url.protocol,
host: url.host,
Expand Down

0 comments on commit 39979fa

Please sign in to comment.