Players in channel ([^:]+):;
if (match = channelreg.exec(line) ) {
channel = match[1];
}
if (match2 = channel2reg.exec(line) ) {
channel = match2[1];
}
if (channel == 'link') { channel = 'default'; }
// Only dig further if unchanneled
if ((channel == '' || channel == 'default') && line.indexOf('color="blue"') != -1) {
var pmreg = /private to ]*>]*>([^<]+);
var pmreg2 = /]*>]*>(?:)?([^(]+) \(private\):/;
if (match3 = pmreg.exec(line)) {
channel = '>'+match3[1].replace(/ /g, '_');
}
if (match4 = pmreg2.exec(line)) {
channel = '>'+match4[1].replace(/ /g, '_');
}
}
// More random things
if (channel == '' || channel == 'default') {
if (line.indexOf('Click Here') != -1) {
channel = document.ctc_currentchat;
}
else if(line.indexOf('Now listening to channel: ') != -1) {
var m = /Now listening to channel: ([^<]*)INCHANNEL = '+channel+''); }
}
}
else if(line.indexOf('You are now talking in channel: ') != -1) {
var m = /You are now talking in channel: ([^<]*)\.INCHANNEL = '+channel+''); }
}
}
else if(line.indexOf('<') == -1 && document.ctc_lasttextchannel == 'haiku') {
channel = 'haiku';
}
else if(line.indexOf('') == -1 && line.indexOf('') > 0 && document.ctc_lasttextchannel) {
// Perhaps, Gothy
channel = document.ctc_lasttextchannel;
}
else if(line.indexOf('') == 0 || line.indexOf('') == 0) {
channel = document.ctc_inchannel;
}
// MMG tab. Checks for the text that pops up from an MMG
// transaction in a line starting with greenness, then checks
// to make sure the user wants an MMG tab, then if all of these
// are true, tosses it into the MMG tab. Yay MMG tab!
else if (line.indexOf('took your') != -1 &&
line.indexOf('Meat bet, and you') != -1 &&
line.indexOf('') == 0) {
document.ctc_addchat(document.ctc_lasttextchannel,'', true);
}
if(line.indexOf('') == -1 ||
line.lastIndexOf(' line.lastIndexOf('';
}
if(line.indexOf('') != -1 &&
(line.indexOf('') == -1 ||
line.lastIndexOf('') > line.lastIndexOf(''))) {
line += '';
}
if (line != '') {
if (channel == 'default' && document.ctc_getValue('greentoactive')) {
channel = document.ctc_currentchat;
}
if (channel.indexOf('>') != 0 && channel != 'default' && document.ctc_getValue('condensechannels')) {
channel = 'Chat';
}
document.ctc_addchat(channel, line);
}
document.ctc_lasttextchannel = channel;
if (document.ctc_getValue('debug', false)) {document.ctc_addchat('D',line.replace(//, '>') + '---' + channel + '---');}
}
}
document.getElementById("ChatWindow").innerHTML = "";
window.setTimeout(document.ctc_loop, 2500);
}
var helpl = document.createElement('a');
helpl.href = '#';
helpl.appendChild(document.createTextNode('? '));
helpl.addEventListener('click', function () { document.ctc_help(); }, true);
document.getElementById('ctc_tabs').appendChild(helpl);
unsafeWindow.ctc_inputmunge = function () {
foo = document.getElementsByName('graf');
txt = foo[0].value;
if (txt.indexOf('=') == 0) {
var math = /= *([0-9.]*) *([+*/-]) *([0-9.]*)/.exec(txt);
//alert(math);
if (math[1] && math[2] && math[3] &&
math[1] != '' && math[2] != '' && math[3] != '') {
var result = 0;
var a = parseFloat(math[1]);
var b = parseFloat(math[3]);
if (math[2] == '+') { result = a + b; }
else if (math[2] == '-') { result = a - b; }
else if (math[2] == '*') { result = a * b; }
else if (math[2] == '/') { result = a / b; }
document.ctc_addchat(document.ctc_currentchat, math[0].replace(/^=/,'') + ' = ' + result + '');
return false;
}
}
if ((txt.indexOf('/') != 0 || txt.indexOf('/me') == 0 || txt.indexOf('/em') == 0 || txt.match('^/[0-9]')) && document.ctc_currentchat != 'default'
&& document.ctc_currentchat != 'all'
&& document.ctc_currentchat != document.ctc_inchannel
&& txt != '') {
if (document.ctc_currentchat.indexOf('>') == 0) {
foo[0].value = '/msg ' + (document.ctc_currentchat.replace(/ /g,'_').replace(/^>/, '')) + ' ' + foo[0].value;
}
else {
foo[0].value = '/' + (document.ctc_currentchat) + ' ' + foo[0].value;
}
return true;
}
else if (txt.match('^/w(?:ho)? *$') && document.ctc_currentchat != 'default' &&
document.ctc_currentchat.indexOf('>') != 0) {
foo[0].value = '/who ' + (document.ctc_currentchat);
return true;
}
else if (txt == '/cls' || txt == '/clear') {
document.ctc_chats[document.ctc_currentchat] = '';
document.getElementById('ctc_div').innerHTML = '';
return false;
}
else if (txt == '/clsa' || txt == '/clearall') {
for (var c in document.ctc_chats) {
document.ctc_chats[c] = '';
}
document.getElementById('ctc_div').innerHTML = '';
return false;
}
else if (txt.indexOf('/option') == 0) {
document.ctc_showchat('default');
if (txt.indexOf('/options') != 0) {
var match = /option ([a-z]*)/i.exec(txt);
if (match) {
cmd = match[1];
if (CTC_OPTIONS[cmd]) {
window.setTimeout(function() { GM_setValue(cmd, !document.ctc_getValue(cmd));}, 0);
//GM_setValue(cmd, !GM_getValue(cmd, false));
document.ctc_addchat('default', 'Option: '+cmd+' set to '+(!document.ctc_getValue(cmd) ? 'true' : 'false')+'');
document.ctc_addchat('default', CTC_RELOAD);
}
else {
document.ctc_addchat('default', 'Invalid option: '+cmd+'. Type /options for option list');
}
return false;
}
}
document.ctc_addchat('default', ' Options (toggle with /option XXXX)');
for (var cmd in CTC_OPTIONS) {
document.ctc_addchat('default', '/option '+cmd+' ['+(document.ctc_getValue(cmd)?'true':'false')+'] - '+CTC_OPTIONS[cmd]);
}
return false;
}
else if (txt.indexOf('/set') == 0) {
document.ctc_showchat('default');
if (txt.indexOf('/sets') != 0) {
var match = /set ([a-z]*) (.*)/i.exec(txt);
if (match) {
set = match[1];
val = match[2];
if (CTC_SETS[set]) {
window.setTimeout(function() { GM_setValue(set, val);}, 0);
document.ctc_addchat('default', 'Variable: '+set+' set to '+val+'');
document.ctc_addchat('default', CTC_RELOAD);
}
else {
document.ctc_addchat('default', 'Invalid variable: '+set+'. Type /sets for variable list');
}
document.ctc_size();
return false;
}
}
document.ctc_addchat('default', ' Variables (set with /set VAR XXXX)');
for (var cmd in CTC_SETS) {
document.ctc_addchat('default', '/set '+cmd+' ['+document.ctc_get_set(cmd)+'] - '+CTC_SETS[cmd]);
}
return false;
}
else if (txt == '/mark') {
var d = new Date();
var line = '——— ' + (d.getHours()%12) + ':' + (d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()) + ':' + (d.getSeconds() <10 ? '0' + d.getSeconds() : d.getSeconds()) + ' ———';
document.ctc_chats[document.ctc_currentchat] += line;
document.getElementById('ctc_div').innerHTML += line;
dv.scrollTop = dv.scrollHeight - dv.clientHeight;
return false;
}
return true;
}
setTimeout("oldsubmitchat = submitchat; submitchat = function (override) { if (ctc_inputmunge()) { oldsubmitchat(override); } else { foo = document.getElementsByName('graf'); foo[0].value = ''; } };", 500);
document.ctc_keys = function (ev) {
var goto = 0;
var left = 37;
var right = 39;
if (document.ctc_getValue('verticalkeys')) {
left = 38;
right = 40;
}
if (!ev.ctrlKey || (ev.keyCode != left && ev.keyCode != right)) {
return true;
}
var tabs = document.evaluate(
"//div[@id='ctc_tabs']/a[@id]",
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
if (ev.ctrlKey && ev.keyCode == left) {
var last = 0;
for (var i=0; i< tabs.snapshotLength; i++) {
c = tabs.snapshotItem(i).getAttribute('id').replace('ctc_tab_', '');
if (c == document.ctc_currentchat) {
goto = last;
}
last = c;
}
if (!goto) { goto = last; }
}
else if (ev.ctrlKey && ev.keyCode == right) {
var first = 0;
var next = 0;
for (var i=0; i< tabs.snapshotLength; i++) {
c = tabs.snapshotItem(i).getAttribute('id').replace('ctc_tab_', '');
if (!first) { first = c; }
if (next) { goto = c; next = 0; }
if (c == document.ctc_currentchat) {
next = 1;
}
}
if (!goto) { goto = first; }
}
if (goto) {
document.ctc_showchat(goto);
return false;
}
return true;
}
document.ctc_get_graf = function () {
foo = document.getElementsByName('graf');
return foo[0];
}
window.addEventListener('keypress', document.ctc_keys, true);
document.ctc_addchat('default', ''+CTC_HELP.replace(/\n/g, ' ').replace(/Chat/,'Chat') + '
', true);
document.ctc_get_graf().focus();
if (document.ctc_getValue('alltab')) {
document.ctc_addchat('all', 'Welcome to the Almighty All Tab', true);
}
var lastUpdated = parseInt(GM_getValue('lastupdate', 0));
var currentHours = parseInt(new Date().getTime()/3600000);
function GM_get(dest, callback)
{
GM_xmlhttpRequest({
method: 'GET',
url: 'http://' + dest,
onload: function(details) {
if( typeof callback=='function' ){
callback(details.responseText);
}}
});
}
function ver_to_float(str) {return parseFloat(str.replace(/([0-9]*\.)([0-9]*)\.([0-9]*)/, "$1$2$3"))}
// If over 4 hours, check for updates
if ((currentHours - lastUpdated) > 4)
{
GM_get("noblesse-oblige.org/cdmoyer/gm/latest.php", function(txt) {
if (ver_to_float(txt) <= ver_to_float(CTC_VERSION)) {
GM_log("Checked... " + txt + " is not newer than " + CTC_VERSION);
window.setTimeout(function(){GM_setValue('lastupdate', parseInt(new Date().getTime()/3600000));}, 0);
return;
}
document.ctc_addchat('default', 'A new version of tabbed chat is available! Get it!');
});
}
document.ctc_loop();
|