Created
August 4, 2015 19:59
-
-
Save nucular/591ca1930601e4ed63d1 to your computer and use it in GitHub Desktop.
IRC colors/formatting hotkeys for qwebirc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Colors for qwebirc | |
// @namespace https://nucular.github.io | |
// @version 0.1 | |
// @description Since qwebirc really fucking sucks | |
// @match https://webchat.freenode.net | |
// @copyright 2015, nucular | |
// @license MIT | |
// ==/UserScript== | |
function main(reload) { | |
var inp = document.getElementsByClassName("keyboard-input")[0]; | |
inp.addEventListener("keydown", function(e) { | |
if (e.ctrlKey) { | |
switch (e.keyCode) { | |
case 75: // Ctrl+K: colours | |
var c = prompt("Enter a colour code in the format foreground,background (,background is optional)\n00 = white\n01 = black\n02 = blue (navy)\n03 = green\n04 = red\n05 = brown (maroon)\n06 = purple\n07 = orange (olive)\n08 = yellow\n09 = light green (lime)\n10 = teal (a green/blue cyan)\n11 = light cyan (cyan / aqua)\n12 = light blue (royal)\n13 = pink (light purple / fuchsia)\n14 = grey\n15 = light grey (silver)") | |
if (c) | |
inp.value += "\x03" + c; | |
return false; | |
break; | |
case 66: // Ctrl+B: bold | |
inp.value += "\x02"; | |
return false; | |
break; | |
case 73: // Ctrl+I: italic | |
inp.value += "\x1D"; | |
return false; | |
break; | |
case 85: // Ctrl+U: underlined (broken due to view-source popup) | |
inp.value += "\x1F"; | |
return false; | |
break; | |
case 82: // Ctrl+R: reset colours | |
inp.value += "\x0F"; | |
return false; | |
break; | |
} | |
} | |
}, true); | |
} | |
function inject() { | |
var func = arguments[0]; | |
var args = Array.prototype.slice.call(arguments, 1); | |
var el = document.createElement("script"); | |
el.innerHTML = "(" + func.toString() + ").apply(window, " + JSON.stringify(args) + ");"; | |
document.body.appendChild(el); | |
} | |
inject(main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment