// ==UserScript==
// @name ujj.co.jp Autologin
// @namespace b21eb01455e288d5ae09096907778fbc94aeda85
// @version 0.2
// @description Logs in using chosen OpenID type automatically
// @author /u/AyrA_ch
// @match https://www.ujj.co.jp/opa/apps/login.aspx*
// @match https://ujj.co.jp/opa/apps/login.aspx*
// @match http://www.akatuki-login.ujj.co.jp/game.php*
// @match http://akatuki-login.ujj.co.jp/game.php*
// @grant none
// @external true
// ==/UserScript==
// Changelog
// 0.2 - Implement all login types and allow selection
// 0.1 - Initial Release
//REF: https://redd.it/7qgr2z
(function ($) {
'use strict';
//List of available login types
var providers = {
none: 0,
yahoo: 1,
livedoor: 2,
excite: 3, //DO NOT USE (Disabled on website)
biglobe: 4,
mixi: 5,
google: 6,
twitter: 7,
facebook: 8
};
if (location.href.match(/login\.aspx/)) {
var itemName = "autoLoginType";
var loginTime = 5;
var stopText = "STOP AUTO LOGIN";
localStorage.setItem(itemName, +localStorage.getItem(itemName) || providers.none);
var loginType = +localStorage.getItem(itemName);
if (loginType) {
var d = document.createElement("input");
var timer = window.setInterval(function () {
if (--loginTime < 1) {
d.remove();
login(loginType);
} else {
d.value = stopText + " (" + loginTime + ")";
}
}, 1000);
d.type = "button";
d.value = stopText + " (" + loginTime + ")";
d.style = "background-color:#F99;color:#FFF;padding:5px;display:inline-block;";
d.addEventListener("click", function () {
window.clearInterval(timer);
localStorage.removeItem(itemName);
d.remove();
location.reload();
});
$(".mainbox").appendChild(d);
} else {
var d = document.createElement("div");
var k = Object.keys(providers).filter(function (v) {
return v != "none";
});
d.innerHTML = "<b>Auto Login:</b><br />" + k.map(function (v) {
return '<label><input type="radio" name="autologin" value="' + providers[v] + '" />' + v + '</label> ';
}).join("") + '<br /><input type="button" id="btnSaveAutologin" value="Select"/>';
$(".mainbox").appendChild(d);
$("#btnSaveAutologin").addEventListener("click", function () {
var x = + ($("[name=autologin]:checked") || {}).value;
if (x && x != 0) {
localStorage.setItem(itemName, x);
location.reload();
} else {
alert("Please select a provider first");
}
});
}
} else if (location.href.match(/game\.php/)) {
window.close();
}
})(document.querySelector.bind(document));
/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.
DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/