Nico Autologin

ニコニコ動画の自動ログインスクリプトです。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           Nico Autologin
// @description    ニコニコ動画の自動ログインスクリプトです。
// @namespace      http://efcl.info/ + @7coc
// @include        http://www.nicovideo.jp/watch/*
// @include        https://account.nicovideo.jp/login?*
// @grant          GM_getValue
// @grant          GM_setValue
// @grant          GM_getResourceText
// @require        https://greasyfork.org/scripts/1884-gm-config/code/GM_config.js?version=4836
// @version 0.0.1.20150130061238
// ==/UserScript==

//-------------------------------------
// 処理
//-------------------------------------
GM_config.init("ニコニコログイン情報設定", {
	"mail" : {
		"label" : "メールアドレス/電話番号",
		"type" : "text"
	},
	"loginpass" : {
		"label" : "パスワード",
		"type" : "password"
	}
}, {
    save: function() {
        location.reload();
    }
});

// ニコニコ動画ログイン用メールアドレス
var myMailAddress = GM_config.get('mail');
// ニコニコ動画ログイン用パスワード
var myPassword = GM_config.get('loginpass');

var nURL = location.href;
if (nURL.indexOf("http://www.nicovideo.jp/watch/") != -1) {
    var pl = document.getElementById("flvplayer_container");
    if (!pl) {
        var loginA = document.querySelector(".loginButton");
        location.href = loginA.getAttribute("href");
    } else {
        exit;
    }
} else if (nURL.indexOf("https://account.nicovideo.jp/login") != -1) {
    var mailBox = document.getElementById("input__mailtel");
    var passBox = document.getElementById("input__password");
    if (mailBox && passBox && myMailAddress && myPassword) {
        mailBox.value = myMailAddress;
        passBox.value = myPassword;
        if (document.getElementsByClassName("notice error").length == 0) {
         document.querySelector("form").submit();
        } else {GM_config.open();}
    } else {
        GM_config.open()
    }
}