Last active
August 29, 2015 14:07
-
-
Save disjukr/3dc54930625b228d7db5 to your computer and use it in GitHub Desktop.
irctalk 웹클라 유저스크립트. 크롬만 지원.
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 irctalkk | |
// @match https://beta.ircta.lk/* | |
// ==/UserScript== | |
// 스타일은 2초 단위로 다시 설정 | |
window.setInterval(function () { | |
$('.ul-channels li').css('height', 22); | |
}, 2000); | |
$(window).keydown(function (e) { | |
var commandKey = e.ctrlKey || e.metaKey; | |
var handled = true; | |
if ($('#text-input').is(':focus')) | |
return; // 대화내용 입력중일 경우엔 방해하지 않기 | |
switch(e.which) { | |
case 38: // up | |
if (commandKey) | |
$prevActiveChannel().click(); | |
else | |
$prevChannel().click(); | |
break; | |
case 40: // down | |
if (commandKey) | |
$nextActiveChannel().click(); | |
else | |
$nextChannel().click(); | |
break; | |
case 37: // left | |
$lastChannelInPrevServer().click(); | |
break; | |
case 39: // right | |
$firstChannelInNextServer().click(); | |
break; | |
default: | |
handled = false; | |
break; | |
} | |
if (handled) | |
e.preventDefault(); | |
}); | |
function $startChannel() { // 리스트의 첫번째에 있는 채널 | |
return $('.ul-channels li').eq(0); | |
} | |
function $currentChannel() { // 현재 보고있는 채널 | |
return $('.ul-channels li.active'); | |
} | |
function $orStart($channel) { | |
return $channel.length > 0 ? $channel.eq(0) : $startChannel(); | |
} | |
function $orCurrent($channel) { | |
return $channel.length > 0 ? $channel.eq(0) : $orStart($currentChannel()); | |
} | |
function $orFirst($channel) { | |
return $channel.length > 0 ? $channel.eq(0) : $firstChannel(); | |
} | |
function $orLast($channel) { | |
return $channel.length > 0 ? $channel.eq(0) : $lastChannel(); | |
} | |
function $prevChannel() { // 보고있는 채널의 이전 채널 | |
return $orCurrent($currentChannel().prev()); | |
} | |
function $nextChannel() { // 보고있는 채널의 다음 채널 | |
return $orCurrent($currentChannel().next()); | |
} | |
function $prevActiveChannel() { // 보고있는 채널의 이전 채널 중에서 대화 내용이 갱신된 채널 중 보고있는 채널과 가장 가까운 채널 | |
return $orCurrent($currentChannel().prevAll('.new-message').eq(0)); | |
} | |
function $nextActiveChannel() { // 보고있는 채널의 다음 채널 중에서 대화 내용이 갱신된 채널 중 보고있는 채널과 가장 가까운 채널 | |
return $orCurrent($currentChannel().nextAll('.new-message').eq(0)); | |
} | |
function $firstChannel() { // 보고있는 서버의 첫번째 채널 | |
return $orCurrent($currentChannel().siblings().andSelf().first()); | |
} | |
function $lastChannel() { // 보고있는 서버의 마지막 채널 | |
return $orCurrent($currentChannel().siblings().andSelf().last()); | |
} | |
function $lastChannelInPrevServer() { // 보고있는 서버의 이전 서버의 마지막 채널 | |
return $orFirst($currentChannel().closest('.server').prev().find('.ul-channels li').last()); | |
} | |
function $firstChannelInNextServer() { // 보고있는 서버의 다음 서버의 첫번째 채널 | |
return $orLast($currentChannel().closest('.server').next().find('.ul-channels li').first()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment