Skip to content

Instantly share code, notes, and snippets.

@skaveesh
Last active October 18, 2023 03:39
Show Gist options
  • Save skaveesh/ab93df4414732e69ad1cb0204dcb20b1 to your computer and use it in GitHub Desktop.
Save skaveesh/ab93df4414732e69ad1cb0204dcb20b1 to your computer and use it in GitHub Desktop.
Diatonic (10H) to Tremolo (20H) Harmonica Convertor [Suzuki Winner Harmonica]
// ==UserScript==
// @name Tremolo converter
// @namespace https://gist.github.com/skaveesh/ab93df4414732e69ad1cb0204dcb20b1
// @version 0.1
// @description try to take over the world!
// @author Samintha Kaveesh
// @match https://www.harptabs.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=harptabs.com
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
const regex = /-?.[0-9][\*\']|\/[0-9]/gi;
const numbers = /-?[0-9]\d*/gi;
var tabs = getElementByXpath("//html/body/center/table/tbody/tr[3]/td[1]/table[1]/tbody/tr[1]/td[2]/center/table[3]/tbody/tr/td[2]");
console.log(tabs.innerText);
tabs.innerHTML = tabs.innerHTML
.replaceAll(regex,"<span style='color: red'>X</span>")
.replace(numbers, function replace(match) {
return '<emx>' + match + '</emx>';
})
.replaceAll("<emx>2</emx>", "3")
.replaceAll("<emx>1</emx>", "1")
.replaceAll("<emx>3</emx>", "5")
.replaceAll("<emx>4</emx>", "7")
.replaceAll("<emx>5</emx>", "9")
.replaceAll("<emx>6</emx>", "11")
.replaceAll("<emx>7</emx>", "13")
.replaceAll("<emx>8</emx>", "15")
.replaceAll("<emx>9</emx>", "17")
.replaceAll("<emx>10</emx>", "19")
.replaceAll("<emx>-1</emx>", "-2")
.replaceAll("<emx>-2</emx>", "-4")
.replaceAll("<emx>-3</emx>", "-6")
.replaceAll("<emx>-4</emx>", "-8")
.replaceAll("<emx>-5</emx>", "-10")
.replaceAll("<emx>-6</emx>", "-12")
.replaceAll("<emx>-7</emx>", "-14")
.replaceAll("<emx>-8</emx>", "-16")
.replaceAll("<emx>-9</emx>", "-18")
.replaceAll("<emx>-10</emx>", "-20");
console.log(tabs.innerText);
})();
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
@skaveesh
Copy link
Author

This script can be installed with Tampermonkey to use in https://www.harptabs.com/ with Diatonic harp tabs with the key of C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment