From b68b43015cf66452e3d6d290ee76cc04a244ca84 Mon Sep 17 00:00:00 2001 From: asanvicentec Date: Thu, 27 Jun 2024 20:15:56 +0200 Subject: [PATCH] further documentation --- README.md | 7 +++++++ src/scripts/content.ts | 7 +++++-- src/scripts/utils.ts | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 77e632d..dadd90b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # UltimateNotation Convert notes to Solfège representation on [Freetar](https://freetar.de/) site. This extension was originally meant to be used on the original Ultimate Guitar, but HTML is way harder to edit there, also Freetar removes a lot of UG bloat. + +## Disclaimer +This extension has been tested, but it may not cover all use cases, if you happen to use it and find an error, please let me now. + +# For developers +When viewing changes on-the-fly when developing, you can run `npm run start` and load the uncompressed extension +by pointing to the dist folder in `chrome://extensions/` diff --git a/src/scripts/content.ts b/src/scripts/content.ts index 91cee0b..5b20a2c 100644 --- a/src/scripts/content.ts +++ b/src/scripts/content.ts @@ -14,15 +14,18 @@ if (tab) { tab.childNodes.forEach((item, index) => { if (item.nodeName.toLowerCase() === "span") { - const score = item.firstChild!.textContent; + const note = item.firstChild!.textContent; let spacesToRemove = item.firstChild!.textContent.substring(1).length; - item.firstChild!.textContent = solfegeDictionary[score[0].toLowerCase()] + item.firstChild!.textContent.substring(1) + // Conversion + item.firstChild!.textContent = solfegeDictionary[note[0].toLowerCase()] + item.firstChild!.textContent.substring(1) if (item.lastChild!.classList.contains("chord-bass")) { item.lastChild!.textContent = solfegeDictionary[item.lastChild!.textContent.toLowerCase()] + item.lastChild!.textContent.substring(1) spacesToRemove += -Math.abs(item.lastChild!.textContent!.length) + 1; } + + // Remove spaces if (tab.childNodes[index + 1].nodeName === "#text") { spacesToRemove += -Math.abs(item.firstChild!.textContent!.length) + 1; diff --git a/src/scripts/utils.ts b/src/scripts/utils.ts index 554c545..08ea778 100644 --- a/src/scripts/utils.ts +++ b/src/scripts/utils.ts @@ -1,5 +1,4 @@ //#region Copy to clipboard -// Helped by: https://stackoverflow.com/a/30810322 export async function copyTextToClipboard(text: string) { await navigator.clipboard.writeText(text).then(function () { console.log("Copied successfully!");