Skip to content

Instantly share code, notes, and snippets.

@mreis1
Created November 25, 2018 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreis1/0cb96074f86a6635abec9d4ccd4d9618 to your computer and use it in GitHub Desktop.
Save mreis1/0cb96074f86a6635abec9d4ccd4d9618 to your computer and use it in GitHub Desktop.
Digital Ocean Console SendString
/*
Open your digital ocean console.
Paste the script below.
Then do: sendString('YOUR_TEXT_TO_SEND_TO_CONSOLE');
*/
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
if (chr) {
rfb.sendKey(chr);
setTimeout(_qStart, sendDelay);
}
};
var _qStop = function() { _q.length = 0; };
var fn = function sendString(str) {
_qStop();
str = str || '';
var chr;
for (var i=0; i < str.length; i++) {
chr = str[i].charCodeAt();
_q.push(chr);
}
_qStart();
};
if (rfb.sendString && true !== force) {
console.warn('rfb.sendString not installed because it already exists. Use force if you\'d like');
}
else {
rfb.sendString = fn;
}
return fn;
})(rfb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment