Skip to content

Instantly share code, notes, and snippets.

@runofthemill
Forked from byjg/NoVNC_Paste.js
Created November 13, 2018 02:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save runofthemill/4ce484b00a95c1ed7f386131e8a4d769 to your computer and use it in GitHub Desktop.
Save runofthemill/4ce484b00a95c1ed7f386131e8a4d769 to your computer and use it in GitHub Desktop.
How to Paste code to NoVNC.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
window.sendString = function (str) {
f(str.split(""));
function f(t) {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = character.match(/[a-z!@#$%^&*()_+{}:\"<>?~|]/);
if (needs_shift) {
rfb.sendKey(XK_Shift_L,1);
}
rfb.sendKey(code,1);
rfb.sendKey(code,0);
if (needs_shift) {
rfb.sendKey(XK_Shift_L,0);
}
if (t.length > 0) {
setTimeout(function() {f(t);}, 30);
}
}
}
})();
@runofthemill
Copy link
Author

adjusted timeout & reversed uppercase letters to work with Digital Ocean's NoVNC

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