티스토리 뷰

728x90
반응형

SecureShell Profile List 정렬하기

AWS, Azure 등의 클라우드 연결에 Chrome Extension인 ScureShell을 이용하고 있다. 이런 저런 연결을 관리하다가 보면 어느새 Profile 순서가 엉망이다. 리스트에서 찾는것도 지겹고 해서 여러 가지 키워드로 검색을 해 보니 결국 수동으로 정리를 하는 방법뿐이 없었다.

우선 간단하게 Profile id 기준으로 정렬은 다음과 같이 처리하면 된다.

(function(){
    var list = nassh_.prefs_.get('profile-ids');
    list = list.slice(0);
    var out = [];

    var doprofile = function(){
        var id = list.pop();
        console.log(id);

        if(id){
            var p = nassh_.prefs_.getProfile(id);
            out.push({k: id, v: p.prefRecords_.description.currentValue});
            doprofile();
        } else {
            out.sort(function(a,b){
                    if (a.v < b.v) return -1;
                    if (a.v > b.v) return 1;
                    return 0;
            });
            for(var i=0;i<out.length;i++){
                out[i] = out[i].k;
            }
            if(out.length){
                nassh_.prefs_.set('profile-ids', out);
                console.log('done')
            } else {
                console.log('result empty, please refresh the page and try again.');
            }
        }
    };
    doprofile();
})();

위의 스크립트 함수를 Ctrl + Shift + J 를 사용해서 스크립트 콘솔을 열고 붙여넣고 실행하면 된다.


Written by Morris (ccambo@gmail.com - MSFL)

728x90
반응형
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함