From d2b2fdf9bb14fdb3c0dfc8dd5b18cd050a414067 Mon Sep 17 00:00:00 2001 From: David Logie Date: Sat, 20 May 2023 15:03:10 +0100 Subject: [PATCH] prettify everything. --- bandcamp-no-custom-styles.user.js | 6 +- bandcamp-volume-slider.user.js | 41 ++++---- bleep-show-cat-no.user.js | 8 +- cue-trumps.user.js | 16 ++- discogs-highlight-master-release.user.js | 23 +++-- musicbrainz-atisket.user.js | 36 ++++--- request-presets.user.js | 122 ++++++++++++++++------- tmdb-copy-as-directory.user.js | 22 ++-- youtube-rss.user.js | 26 ++--- 9 files changed, 188 insertions(+), 112 deletions(-) diff --git a/bandcamp-no-custom-styles.user.js b/bandcamp-no-custom-styles.user.js index 9972516..a152e37 100644 --- a/bandcamp-no-custom-styles.user.js +++ b/bandcamp-no-custom-styles.user.js @@ -11,7 +11,7 @@ // @run-at document-body // ==/UserScript== (function () { - 'use strict'; - document.querySelector('style#custom-design-rules-style').remove(); - document.querySelector('body').classList.remove('invertIconography'); + "use strict"; + document.querySelector("style#custom-design-rules-style").remove(); + document.querySelector("body").classList.remove("invertIconography"); })(); diff --git a/bandcamp-volume-slider.user.js b/bandcamp-volume-slider.user.js index 75678da..6ccdf90 100644 --- a/bandcamp-volume-slider.user.js +++ b/bandcamp-volume-slider.user.js @@ -14,7 +14,7 @@ // ==/UserScript== (function () { - 'use strict'; + "use strict"; GM_addStyle(` input[type=range] { -webkit-appearance: none; @@ -53,46 +53,51 @@ input[type=range]::-moz-range-track { font-weight:bold; } `); - let audioTag = document.getElementsByTagName('audio')[0]; + let audioTag = document.getElementsByTagName("audio")[0]; let properties = { - type: 'range', + type: "range", min: 0, max: 1, step: 0.01, - value: parseFloat(GM_getValue('volume', '0.5')), - id: 'VolumeSlider', + value: parseFloat(GM_getValue("volume", "0.5")), + id: "VolumeSlider", }; - let volumeControl = document.createElement('input'); + let volumeControl = document.createElement("input"); for (let prop in properties) { volumeControl[prop] = properties[prop]; } - let elem = document.getElementById('VolumeSlider'); + let elem = document.getElementById("VolumeSlider"); if (elem) { - elem.parentNode.replaceChild(volumeControl, document.getElementById('VolumeSlider')); + elem.parentNode.replaceChild( + volumeControl, + document.getElementById("VolumeSlider") + ); elem.volume = volumeControl.value; } else { - let genRow = document.createElement('tr'); - let volHold = document.createElement('td'); - let label = document.createElement('td'); + let genRow = document.createElement("tr"); + let volHold = document.createElement("td"); + let label = document.createElement("td"); - label.innerText = 'Volume: '; - label.className = 'VolumeSliderLabel'; + label.innerText = "Volume: "; + label.className = "VolumeSliderLabel"; volHold.appendChild(volumeControl); genRow.appendChild(label); genRow.appendChild(volHold); - document.getElementById('trackInfoInner').children[0].children[0].children[0].appendChild(genRow); + document + .getElementById("trackInfoInner") + .children[0].children[0].children[0].appendChild(genRow); audioTag.volume = properties.value; } - volumeControl.addEventListener('input', function () { + volumeControl.addEventListener("input", function () { audioTag.volume = volumeControl.value; - GM_setValue('volume', volumeControl.value); + GM_setValue("volume", volumeControl.value); }); - volumeControl.addEventListener('change', function () { + volumeControl.addEventListener("change", function () { audioTag.volume = volumeControl.value; - GM_setValue('volume', volumeControl.value); + GM_setValue("volume", volumeControl.value); }); })(); diff --git a/bleep-show-cat-no.user.js b/bleep-show-cat-no.user.js index 3cd142b..d49378b 100644 --- a/bleep-show-cat-no.user.js +++ b/bleep-show-cat-no.user.js @@ -11,9 +11,11 @@ // ==/UserScript== (function () { - 'use strict'; - const label = document.querySelector('div.product-info dd.label'); - const catno = document.querySelector('div.product-info dd.catalogue-number'); + "use strict"; + const label = document.querySelector("div.product-info dd.label"); + const catno = document.querySelector( + "div.product-info dd.catalogue-number" + ); console.log(label); console.log(catno); if (label == null || catno == null) { diff --git a/cue-trumps.user.js b/cue-trumps.user.js index 9b65842..749054d 100644 --- a/cue-trumps.user.js +++ b/cue-trumps.user.js @@ -12,18 +12,24 @@ // ==/UserScript== (function () { - 'use strict'; + "use strict"; if (!/(artists|torrents).php\?id/.test(window.location)) { return; } - let torrents = document.querySelectorAll('div.torrent_info'); + let torrents = document.querySelectorAll("div.torrent_info"); if (torrents.length == 0) { - torrents = document.querySelectorAll('tr.torrent_row td:first-child > a'); + torrents = document.querySelectorAll( + "tr.torrent_row td:first-child > a" + ); } torrents.forEach(torrent => { const text = torrent.innerText; - if (text.includes('Log (100%)') && !text.includes('Cue') && !text.includes('Trumpable')) { - torrent.querySelector('strong').innerText += ' [TRUMPABLE!]'; + if ( + text.includes("Log (100%)") && + !text.includes("Cue") && + !text.includes("Trumpable") + ) { + torrent.querySelector("strong").innerText += " [TRUMPABLE!]"; } }); })(); diff --git a/discogs-highlight-master-release.user.js b/discogs-highlight-master-release.user.js index 8adf298..d3e40b1 100644 --- a/discogs-highlight-master-release.user.js +++ b/discogs-highlight-master-release.user.js @@ -11,14 +11,17 @@ // ==/UserScript== (function () { - 'use strict'; - document.querySelectorAll('li.card[data-object-type="master release"]').forEach(function (elem) { - const div = document.createElement('div'); - div.style.cssText = 'position: absolute; width 100%; top: 124px; left: 0;'; - const span = document.createElement('span'); - span.innerHTML = 'master release'; - span.style.cssText = `position: absolute; width: 144px; padding: 0.3em; text-align:center; font-size: 0.8em; background-color: #e8e7e9; background-image: url("data:image/svg+xml,%3Csvg width='12' height='24' viewBox='0 0 12 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d0cfd1' fill-opacity='0.4'%3E%3Cpath d='M2 0h2v12H2V0zm1 20c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM9 8c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm-1 4h2v12H8V12z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");`; - div.appendChild(span); - elem.appendChild(div); - }); + "use strict"; + document + .querySelectorAll('li.card[data-object-type="master release"]') + .forEach(function (elem) { + const div = document.createElement("div"); + div.style.cssText = + "position: absolute; width 100%; top: 124px; left: 0;"; + const span = document.createElement("span"); + span.innerHTML = "master release"; + span.style.cssText = `position: absolute; width: 144px; padding: 0.3em; text-align:center; font-size: 0.8em; background-color: #e8e7e9; background-image: url("data:image/svg+xml,%3Csvg width='12' height='24' viewBox='0 0 12 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d0cfd1' fill-opacity='0.4'%3E%3Cpath d='M2 0h2v12H2V0zm1 20c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM9 8c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm-1 4h2v12H8V12z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");`; + div.appendChild(span); + elem.appendChild(div); + }); })(); diff --git a/musicbrainz-atisket.user.js b/musicbrainz-atisket.user.js index 670fbc2..ca00293 100644 --- a/musicbrainz-atisket.user.js +++ b/musicbrainz-atisket.user.js @@ -10,39 +10,47 @@ // @match *://musicbrainz.org/* // ==/UserScript== -const atiskets = ['https://atisket.pulsewidth.org.uk']; +const atiskets = ["https://atisket.pulsewidth.org.uk"]; (function () { - const 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'); + const 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)) { return; } - document.querySelectorAll('div#bottom-credits a').forEach(function (link) { - if (link.href.match(/deezer.com|(music|itunes).apple.com|spotify.com/)) { + document.querySelectorAll("div#bottom-credits a").forEach(function (link) { + if ( + link.href.match(/deezer.com|(music|itunes).apple.com|spotify.com/) + ) { let id; let fragment; if (link.href.match(/deezer.com/)) { - id = new URL(link.href).pathname.split('/').slice(-1)[0]; - fragment = 'deez'; + id = new URL(link.href).pathname.split("/").slice(-1)[0]; + fragment = "deez"; } else if (link.href.match(/apple.com/)) { - id = new URL(link.href).pathname.split('/', 5).slice(-1)[0].replace('id', ''); - fragment = 'itu'; + id = new URL(link.href).pathname + .split("/", 5) + .slice(-1)[0] + .replace("id", ""); + fragment = "itu"; } else if (link.href.match(/spotify.com/)) { - id = new URL(link.href).pathname.split('/', 5).slice(-1)[0]; - fragment = 'spf'; + id = new URL(link.href).pathname.split("/", 5).slice(-1)[0]; + fragment = "spf"; } let sibling = link.nextElementSibling; while (sibling) { - if (sibling.matches('br')) { + if (sibling.matches("br")) { for (const i in atiskets) { const url = atiskets[i]; - const newlink = document.createElement('a'); + const newlink = document.createElement("a"); newlink.href = `${url}/?${fragment}_id=${id}`; - newlink.text = 'a-tisket'; - sibling.before(' [', newlink, ']'); + newlink.text = "a-tisket"; + sibling.before(" [", newlink, "]"); } break; } diff --git a/request-presets.user.js b/request-presets.user.js index c632c5c..658e206 100644 --- a/request-presets.user.js +++ b/request-presets.user.js @@ -11,54 +11,106 @@ // @run-at document-idle // ==/UserScript== -const logElement = 'minlogscore'; +const logElement = "minlogscore"; const boxes = { cd: { - 'orpheus.network': ['format_1', 'bitrate_0', 'media_0', 'needlog', 'needcksum', 'needcue'], - 'redacted.ch': ['format_1', 'bitrate_8', 'media_0', 'needlog', 'needcue', 'needchecksum'], + "orpheus.network": [ + "format_1", + "bitrate_0", + "media_0", + "needlog", + "needcksum", + "needcue", + ], + "redacted.ch": [ + "format_1", + "bitrate_8", + "media_0", + "needlog", + "needcue", + "needchecksum", + ], }, web: { - 'orpheus.network': ['format_1', 'bitrate_0', 'media_1'], - 'redacted.ch': ['format_1', 'bitrate_8', 'media_7'], + "orpheus.network": ["format_1", "bitrate_0", "media_1"], + "redacted.ch": ["format_1", "bitrate_8", "media_7"], }, web24: { - 'orpheus.network': ['format_1', 'bitrate_0', 'bitrate_1', 'media_1'], - 'redacted.ch': ['format_1', 'bitrate_8', 'bitrate_9', 'media_7'], + "orpheus.network": ["format_1", "bitrate_0", "bitrate_1", "media_1"], + "redacted.ch": ["format_1", "bitrate_8", "bitrate_9", "media_7"], }, cdweb: { - 'orpheus.network': ['format_1', 'bitrate_0', 'media_0', 'media_1', 'needlog', 'needcksum', 'needcue'], - 'redacted.ch': ['format_1', 'bitrate_8', 'media_0', 'media_7', 'needlog', 'needcue', 'needchecksum'], + "orpheus.network": [ + "format_1", + "bitrate_0", + "media_0", + "media_1", + "needlog", + "needcksum", + "needcue", + ], + "redacted.ch": [ + "format_1", + "bitrate_8", + "media_0", + "media_7", + "needlog", + "needcue", + "needchecksum", + ], }, cdweb24bit: { - 'orpheus.network': ['format_1', 'bitrate_0', 'bitrate_1', 'media_0', 'media_1', 'needlog', 'needcksum', 'needcue'], - 'redacted.ch': ['format_1', 'bitrate_8', 'bitrate_9', 'media_0', 'media_7', 'needlog', 'needcue', 'needchecksum'], + "orpheus.network": [ + "format_1", + "bitrate_0", + "bitrate_1", + "media_0", + "media_1", + "needlog", + "needcksum", + "needcue", + ], + "redacted.ch": [ + "format_1", + "bitrate_8", + "bitrate_9", + "media_0", + "media_7", + "needlog", + "needcue", + "needchecksum", + ], }, }; function clear() { - const elements = ['formats_tr', 'bitrates_tr', 'media_tr', 'logcue_tr']; + const elements = ["formats_tr", "bitrates_tr", "media_tr", "logcue_tr"]; elements.forEach(function (elem) { - document.querySelectorAll(`tr#${elem} input[type=checkbox]`).forEach(function (box) { - box.checked = false; - }); + document + .querySelectorAll(`tr#${elem} input[type=checkbox]`) + .forEach(function (box) { + box.checked = false; + }); }); - document.querySelector(`input#${logElement}`).value = ''; + document.querySelector(`input#${logElement}`).value = ""; } function createButton(text, key) { - const button = document.createElement('input'); - button.type = 'button'; + const button = document.createElement("input"); + button.type = "button"; button.value = text; - button.style = 'margin-right: 10px'; + button.style = "margin-right: 10px"; button.onclick = function () { clear(); if (!key) { return; } boxes[key][window.location.hostname].forEach(function (box) { - document.querySelectorAll(`input#${box}[type=checkbox]`).forEach(function (box) { - box.click(); - }); + document + .querySelectorAll(`input#${box}[type=checkbox]`) + .forEach(function (box) { + box.click(); + }); }); document.querySelector(`input#${logElement}`).value = 100; }; @@ -66,26 +118,26 @@ function createButton(text, key) { } (function () { - 'use strict'; + "use strict"; - const tr = document.querySelector('tr#releasetypes_tr'); + const tr = document.querySelector("tr#releasetypes_tr"); if (!tr) { return; } - const mftr = document.createElement('tr'); - const mftdl = document.createElement('td'); - mftdl.className = 'label'; - mftdl.innerText = 'Presets'; + const mftr = document.createElement("tr"); + const mftdl = document.createElement("td"); + mftdl.className = "label"; + mftdl.innerText = "Presets"; mftr.appendChild(mftdl); - const mftdr = document.createElement('td'); + const mftdr = document.createElement("td"); - mftdr.appendChild(createButton('CD', 'cd')); - mftdr.appendChild(createButton('WEB', 'web')); - mftdr.appendChild(createButton('WEB24', 'web24')); - mftdr.appendChild(createButton('CD+WEB', 'cdweb')); - mftdr.appendChild(createButton('CD+WEB24', 'cdweb24bit')); - mftdr.appendChild(createButton('clear', null)); + mftdr.appendChild(createButton("CD", "cd")); + mftdr.appendChild(createButton("WEB", "web")); + mftdr.appendChild(createButton("WEB24", "web24")); + mftdr.appendChild(createButton("CD+WEB", "cdweb")); + mftdr.appendChild(createButton("CD+WEB24", "cdweb24bit")); + mftdr.appendChild(createButton("clear", null)); mftr.appendChild(mftdr); tr.after(mftr); diff --git a/tmdb-copy-as-directory.user.js b/tmdb-copy-as-directory.user.js index cb4ef7d..39dd6cb 100644 --- a/tmdb-copy-as-directory.user.js +++ b/tmdb-copy-as-directory.user.js @@ -10,39 +10,39 @@ // ==/UserScript== function clean(s) { - s = s.replace(/[|<>:/\\*?"]/g, '_'); - s = s.replace(/&/g, '&'); + s = s.replace(/[|<>:/\\*?"]/g, "_"); + s = s.replace(/&/g, "&"); return s; } (function () { - let title = document.querySelector('div.title h2 a'); + let title = document.querySelector("div.title h2 a"); if (!title) { return; } title = clean(title.innerHTML); - const year = document.querySelector('div.title h2 span.release_date'); + const year = document.querySelector("div.title h2 span.release_date"); if (!year) { return; } - const where = document.querySelector('div.facts'); + const where = document.querySelector("div.facts"); if (!where) { return; } - const span = document.createElement('span'); - const a = document.createElement('a'); - a.href = '#'; - a.text = 'Copy as Directory'; + const span = document.createElement("span"); + const a = document.createElement("a"); + a.href = "#"; + a.text = "Copy as Directory"; span.appendChild(a); where.appendChild(span); - a.addEventListener('click', function (event) { + a.addEventListener("click", function (event) { GM_setClipboard(`${title} ${year.innerHTML}`); const txt = a.text; - a.text = 'Copied!'; + a.text = "Copied!"; setTimeout(function () { a.text = txt; }, 3000); diff --git a/youtube-rss.user.js b/youtube-rss.user.js index 25f772d..a5c576d 100644 --- a/youtube-rss.user.js +++ b/youtube-rss.user.js @@ -12,8 +12,8 @@ // ==/UserScript== (function () { - 'use strict'; - const base_url = 'http://www.youtube.com/feeds/videos.xml?channel_id='; + "use strict"; + const base_url = "http://www.youtube.com/feeds/videos.xml?channel_id="; let channel; let url = document.querySelector('meta[itemprop="channelId"]'); if (url) { @@ -26,18 +26,18 @@ channel = urls[0].content.split(/channel\//); } window.setTimeout(function () { - const sub = document.getElementById('subscribe-button'); - const rss = document.createElement('a'); - rss.id = 'rss-button'; + const sub = document.getElementById("subscribe-button"); + const rss = document.createElement("a"); + rss.id = "rss-button"; rss.href = base_url + channel; - rss.innerHTML = 'RSS'; - rss.style.backgroundColor = '#fd9b12'; - rss.style.padding = '10px 16px'; - rss.style.color = '#ffffff'; - rss.style.fontSize = '14px'; - rss.style.fontWeight = 'bold'; - rss.style.textDecoration = 'none'; - rss.style.marginRight = '5px'; + rss.innerHTML = "RSS"; + rss.style.backgroundColor = "#fd9b12"; + rss.style.padding = "10px 16px"; + rss.style.color = "#ffffff"; + rss.style.fontSize = "14px"; + rss.style.fontWeight = "bold"; + rss.style.textDecoration = "none"; + rss.style.marginRight = "5px"; sub.parentNode.insertBefore(rss, sub); }, 1000); })(); -- knotmirror 0.0.1