Auto New Tab

Open new tab, when click specified link.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           Auto New Tab
// @description:en Open new tab, when click specified link.
// @version        0.1
// @namespace      https://twitter.com/foldrr
// @include        *
// @require        http://code.jquery.com/jquery-1.5.min.js
// @description Open new tab, when click specified link.
// ==/UserScript==
(function(){
    var settings = [
        // Google
        {
            url: 'http://www.google.com/search',
            selector: 'h3 a'
        },
        
        // YouTube
        {
            url: 'http://www.youtube.com/results',
            selector: ['.result-item-thumb', 'h3 a']
        },
        
        // ニコニコ動画 キーワード検索
        {
            url: 'http://www.nicovideo.jp/search/',
            selector: ['.uad_thumbfrm p a', '.watch']
        },
        
        // ニコニコ動画 タグ検索
        {
            url: 'http://www.nicovideo.jp/tag/',
            selector: ['.uad_thumbfrm p a', '.watch']
        },
        
        // ニコニコ動画 コミュニティ動画
        {
            url: 'http://com.nicovideo.jp/community/co',
            selector: 'table[summary] a'
        },
        
        // ニコニコ動画 マイリスト
        {
        	url: 'http://www.nicovideo.jp/mylist/',
        	selector: '#SYS_page_items a'
        },
        
        // ニコニコ動画 マイページ マイリスト
        {
            url: 'http://www.nicovideo.jp/my/mylist/',
            selector: ['.mypageThumb', '.mylistVideo a']
        },
        
        // ニコニコ動画 マイページ 視聴履歴
        {
            url: 'http://www.nicovideo.jp/my/history',
            selector: ['.mypageThumb', '.mylistVideo a']
        },
        
        // ニコニコ生放送
        {
            url: 'http://live.nicovideo.jp/watch/',
            selector: '.grid a'
        }
    ];
    
    main();
    
    document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(e){
        main();
    }, false);
    
    function main(){
        $(settings).each(function(){
            if(0 <= location.href.indexOf(this.url)){
                var selectorArray = this.selector instanceof Array ? this.selector : [this.selector];
                var selector = selectorArray.join(", ");
                (function(){
                    var elems = $(selector);
                    if(elems.length == 0){
                        return;
                    }
                    
                    // GM_log("selector = " + selector);
                    // GM_log("elems.length = " + elems.length);
                    elems.attr("target", "_blank");
                })();
                
                return false;
            }
        });
    }
})();