Midi scripts in cubase and OSC

I’m mainly a cubase user but occasionally use Logic Pro as well. I really dig some of the midi script plug-ins people have posted online for logic. Just wondering if it would be possible to assign a button in openstagecontrol and have it work in cubase as well.

Example here is a midi harp glissando script

//-----------------------------------------------------------------------------
// Mod Wheel Harp Glissando
// (c) 2023 Dennis Caunce
// https://www.buymeacoffee.com/dentpuzz
//-----------------------------------------------------------------------------

var lastModWheelValue = -1; // Variable to store the last Mod Wheel value

function HandleMIDI(e) {
if (e instanceof NoteOn && e.velocity > 0) {
var note = e.pitch;
var noteValue = parseInt(note);
heldNotes[noteValue] = e.velocity;

	// Include all versions of this note (12 notes apart)
	for (var i = 0; i <= 108 - noteValue; i += 12) {
		heldNotes[noteValue + i] = e.velocity;
	}
} else if (e instanceof NoteOff) {
	var note = e.pitch;
	var noteValue = parseInt(note);
	delete heldNotes[noteValue];

	// Remove all versions of this note (12 notes apart)
	for (var i = 0; i <= 108 - noteValue; i += 12) {
		delete heldNotes[noteValue + i];
	}
}

if (e instanceof ControlChange) {
	if (e.number == 1) {
		// Map CC1 (Mod Wheel) values (0-127) to MIDI note values (21-108)
		var modWheelValue = Math.round(e.value * 0.85) + 21;

		if (modWheelValue != lastModWheelValue) {
			// Play notes only if the Mod Wheel value has changed
			for (var note in heldNotes) {
				var noteValue = parseInt(note);
				var noteInRange = (noteValue >= Math.min(lastModWheelValue, modWheelValue) &&
								   noteValue <= Math.max(lastModWheelValue, modWheelValue));

				if (!notePlayed[note] && noteInRange) {
					var noteOn = new NoteOn;
					noteOn.pitch = noteValue;
					noteOn.velocity = GetParameter("Note Velocity");
					noteOn.send();
					var noteOff = new NoteOff(noteOn);
					noteOff.sendAfterMilliseconds(GetParameter("Note Length") + 0.1);
					notePlayed[note] = true; // Mark the note as played
				} else if (!noteInRange) {
					notePlayed[note] = false; // Reset notePlayed for notes out of range
				}
			}
			lastModWheelValue = modWheelValue; // Update the last Mod Wheel value
		}
	} else if (e.number == 64) {
		// Pass through CC64 (sustain) messages without modification
		e.send();
	} else if (e.number == 11) {
		// Update the "Note Velocity" parameter with the CC11 value
		SetParameter("Note Velocity", e.value);
	}
}

e.trace(); // Print incoming MIDI messages for debugging

}

var heldNotes = {}; // Object to store held notes and their associated Mod Wheel values
var notePlayed = {}; // Object to track played notes

var PluginParameters = [
{name: "Note Velocity", type: "lin",
minValue: 1, maxValue: 127, numberOfSteps: 126, defaultValue: 80},
{name: "Note Length", type: "lin", unit: "ms",
minValue: 0.0, maxValue: 500.0, numberOfSteps: 100, defaultValue: 100.0}
];

This code can't run in open stage control, you'll need to rewrite it to make in work in a custom module, it's not a small rewrite.