Userpage RSS link

ユーザー投稿動画ページでRSS linkをつけるだけ

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name           Userpage RSS link
// @namespace      http://efcl.info/
// @description    ユーザー投稿動画ページでRSS linkをつけるだけ
// @include        http://www.nicovideo.jp/user/*/video
// @version 0.0.1.20140518104259
// ==/UserScript==

(function() {
    var links = document.getElementsByTagName("link");
    if (isExistRss(links)) {
        alert("もうRSSあるからこのスクリプトいらないっす!");
        return;
    }
    var link = links[0];
    var alternateLink = document.createElement("link");
    setAttributes(alternateLink, {
        rel : "alternate",
        charset : "utf-8",
        type : "application/rss+xml",
        href : location.href + "?rss=2.0"
    });
    link.parentNode.insertBefore(alternateLink, link);
    function setAttributes(ele, attrs) {
        for (var attr in attrs) {
            ele.setAttribute(attr, attrs[attr]);
        }
    }

    function isExistRss(ele) {
        for (i = 0; i < ele.length; i++) {
            if (ele[i].getAttribute("rel") == "alternate" && /(xml|rss)/.test(ele[i].getAttribute("type"))) {
                return true;
            }
        }

    }
})();