var CHROME_EXTENSION_ID, DEBUG, DmmGameWeb, FLAG_OPEN_NM_URL_DMM_COJP, MSG_UNSUPPORTED_BROWSER, NMPROGRAM_PAGE_DMMCOJP_INSTALL, NMPROGRAM_PAGE_DMMCOJP_UPDATE, NMPROGRAM_PAGE_DMMCOM_INSTALL, NMPROGRAM_PAGE_DMMCOM_UPDATE, NMPROGRAM_UPDATE, NPAPI_OBJECT_TAG, inputDateFromString, isArguments, isArray, isDate, isElement, isFunction, isNumber, isObject, isRegExp, isString, range, _d, _e, _g, _i, _l, _w, LAUNCHER_RUN_API, OBJECT_TAG_IE,
//CHROME_EXTENSION_ID = "fcelkijhmppopdoehlidginfpajmdgjk";
CHROME_EXTENSION_ID = "aekecocnhcgghjgbihpbgdimpobbkfpe";
CONTENT_LIST = 'http://updater.profire.co.jp/dmm/dl/master/clist.csv';
//CONTENT_LIST = "http://dl.client-netgame.dmm.com/master/clist.csv";
VERIFICATION_CONTENT_LIST = "https://developer.client-netgame.dmm.com/index.php?p=ct-clist-test";
DEBUG = false;
LAUNCHER_RUN_API = "https://netgame-api.dmm.com/api/Auth/getLauncherInfo";
LAUNCHER_RUN_EXE = 'http://updater.profire.co.jp/dmm/dl/master/dmmgameslauncher.exe';
//LAUNCHER_RUN_EXE = "http://dl.client-netgame.dmm.com/master/dmmgameslauncher.exe";
//LAUNCHER_RUN_EXE = 'http://sbx-dl.client-netgame.dmm.com/master/dmmgameslauncher.exe';
MSG_UNSUPPORTED_BROWSER = "対象外のブラウザです。";
NMPROGRAM_UPDATE = "2013-12-05 13:00:00";
NMPROGRAM_PAGE_DMMCOM_INSTALL = 'http://www.dmm.com/netgame/client/-/plugin/=/type=new/';
NMPROGRAM_PAGE_DMMCOJP_INSTALL = 'http://www.dmm.co.jp/netgame/client/-/plugin/=/type=new/';
NMPROGRAM_PAGE_DMMCOM_UPDATE = 'http://www.dmm.com/netgame/client/-/plugin/=/type=update/';
NMPROGRAM_PAGE_DMMCOJP_UPDATE = 'http://www.dmm.co.jp/netgame/client/-/plugin/=/type=update/';
NPAPI_OBJECT_TAG = '';
OBJECT_TAG_IE = ''
OBJECT_TAG_IE_64 = ''
_l = function(msg) {
if (DEBUG === true) {
if (typeof console.log === 'undefined') {
console.info(msg);
} else {
console.log(msg);
}
}
};
_i = function(msg) {
if (DEBUG === true) {
console.info(msg);
}
};
_d = function(msg) {
if (DEBUG === true) {
if (typeof console.debug === 'undefined') {
console.info(msg);
} else {
console.debug(msg);
}
}
};
_w = function(msg) {
if (DEBUG === true) {
console.warn(msg);
}
};
_e = function(msg) {
if (DEBUG === true) {
console.error(msg);
}
};
_g = function(msgs, logMethod) {
var msg, _j, _k, _len, _len1;
if (msgs == null) {
msgs = [];
}
if (logMethod == null) {
logMethod = _l;
}
if (DEBUG === true) {
if (typeof console.group === 'undefined') {
logMethod('-- Start Group Log --');
for (_j = 0, _len = msgs.length; _j < _len; _j++) {
msg = msgs[_j];
logMethod('\t' + msg);
}
logMethod('--- End Group Log ---');
} else {
console.group();
for (_k = 0, _len1 = msgs.length; _k < _len1; _k++) {
msg = msgs[_k];
logMethod(msg);
}
console.groupEnd();
}
}
};
if (typeof String.prototype.startsWith !== 'function') {
String.prototype.startsWith = function(str) {
return this.slice(0, str.length) === str;
};
}
if (typeof String.prototype.endsWith !== 'function') {
String.prototype.endsWith = function(str) {
return this.slice(-str.length) === str;
};
}
if (typeof String.prototype.addCommas !== 'function') {
String.prototype.addCommas = function() {
var rgx, str, x, x1, x2;
str = this;
str += '';
x = str.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
};
}
if (typeof String.prototype.lpad !== 'function') {
String.prototype.lpad = function(padString, length) {
var str;
str = this;
while (str.length < length) {
str = padString + str;
}
return str;
};
}
if (typeof String.prototype.rpad !== 'function') {
String.prototype.rpad = function(padString, length) {
var str;
str = this;
while (str.length < length) {
str = str + padString;
}
return str;
};
}
if (typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
isArguments = function(obj) {
return Object.prototype.toString.call(obj) === '[object Arguments]';
};
isFunction = function(obj) {
return Object.prototype.toString.call(obj) === '[object Function]';
};
isString = function(obj) {
return Object.prototype.toString.call(obj) === '[object String]';
};
isNumber = function(obj) {
return Object.prototype.toString.call(obj) === '[object Number]';
};
isDate = function(obj) {
return Object.prototype.toString.call(obj) === '[object Date]';
};
isRegExp = function(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
isObject = function(obj) {
return obj === Object(obj);
};
isArray = Array.isArray || function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
isElement = function(obj) {
return !!(obj && obj.nodeType === 1);
};
/*
CoffeeScript's implementation of Python's range()
*/
range = function(start, end) {
var _j, _k, _results, _results1;
if (start == null) {
start = null;
}
if (end == null) {
end = null;
}
if (start === null) {
throw new TypeError('range() takes 1 or 2 arguments');
}
if (isNumber(start) && end === null) {
return (function() {
_results = [];
for (var _j = 0; 0 <= start ? _j < start : _j > start; 0 <= start ? _j++ : _j--){ _results.push(_j); }
return _results;
}).apply(this);
} else if (isNumber(start) && end !== null && isNumber(end)) {
return (function() {
_results1 = [];
for (var _k = start; start <= end ? _k < end : _k > end; start <= end ? _k++ : _k--){ _results1.push(_k); }
return _results1;
}).apply(this);
} else {
throw new TypeError('range() integer end argument expected');
}
};
inputDateFromString = function(val) {
var dateArray, pre;
pre = /(\d{4})-(\d{2})-(\d{2})/;
dateArray = pre.exec(val);
return new Date(Number(dateArray[1]), Number(dateArray[2]), Number(dateArray[3]));
};
DmmGameWeb = (function() {
var D_IS_CHROME, D_IS_FIREFOX, D_IS_WINDOWS, D_IS_WINDOWS_8, D_IS_IE, D_IS_IE_64bit, D_IS_OS_64bit, D_IS_OUT, D_IS_EDGE;
D_IS_WINDOWS = false;
D_IS_WINDOWS_8 = false;
D_IS_CHROME = false;
D_IS_FIREFOX = false;
D_IS_IE = false;
D_IS_IE_64bit = false;
D_IS_OS_64bit = false;
D_IS_OUT = false;
D_IS_EDGE = false;
function DmmGameWeb() {
this.analyseUA();
return;
}
DmmGameWeb.isExistExtension = function() {
if (chrome !== void 0 && chrome.runtime !== void 0) {
return true;
}
return false;
};
DmmGameWeb.prototype.resetUAFlag = function() {
D_IS_WINDOWS = false;
D_IS_WINDOWS_8 = false;
D_IS_CHROME = false;
D_IS_FIREFOX = false;
D_IS_IE = false;
D_IS_IE_64bit = false;
D_IS_OS_64bit = false;
D_IS_OUT = false;
D_IS_EDGE = false;
};
/*
UserAgentからWindowsバージョン・Chrome/Firefox判定を行う
*/
DmmGameWeb.prototype.analyseUA = function() {
var ua = navigator.userAgent.toLowerCase();
var ver = navigator.appVersion.toLowerCase();
var name = 'unknown';
this.resetUAFlag();
if (ua.match(/windows/i)) {
D_IS_WINDOWS = true;
if (navigator.userAgent.indexOf("Windows NT 6.2") >= 0 || navigator.userAgent.indexOf("Windows NT 6.3") >= 0) {
D_IS_WINDOWS_8 = true;
}
}
if (ua.indexOf('edge') != -1){
D_IS_EDGE = true;
name = 'edge';
} else if (ua.indexOf('opr') != -1){
D_IS_OUT = true;
name = 'opera';
} else if (ua.indexOf('opera') != -1){
D_IS_OUT = true;
name = 'opera';
} else if (ua.indexOf("msie") != -1){
if (ver.indexOf("msie 6.") != -1){
D_IS_OUT = true;
name = 'ie6';
}else if (ver.indexOf("msie 7.") != -1){
D_IS_IE = true;
name = 'ie7';
}else if (ver.indexOf("msie 8.") != -1){
D_IS_IE = true;
name = 'ie8';
}else if (ver.indexOf("msie 9.") != -1){
D_IS_IE = true;
name = 'ie9';
}else if (ver.indexOf("msie 10.") != -1){
D_IS_IE = true;
name = 'ie10';
}else{
D_IS_OUT = true;
name = 'ie';
}
}else if(ua.indexOf('trident/7') != -1){
D_IS_IE = true;
name = 'ie11';
}else if (ua.indexOf('chrome') != -1){
D_IS_CHROME = true;
name = 'chrome';
}else if (ua.indexOf('safari') != -1) {
D_IS_OUT = true;
name = 'safari';
}else if (ua.indexOf('firefox') != -1){
D_IS_FIREFOX = true;
name = 'firefox';
}
if (D_IS_IE == true) {
//この判定がいかに
if (navigator.userAgent.match(/Win64/i)) {
D_IS_IE_64bit = true;
}
if (navigator.platform=="Win64" || navigator.userAgent.indexOf("Win64") != -1 || navigator.userAgent.indexOf("WOW64") != -1) {
D_IS_OS_64bit = true;
}
}
};
DmmGameWeb.prototype.isWindows = function() {
return D_IS_WINDOWS;
};
DmmGameWeb.prototype.isWindows8 = function() {
return D_IS_WINDOWS_8;
};
DmmGameWeb.prototype.isFirefox = function() {
return D_IS_FIREFOX;
};
DmmGameWeb.prototype.isChrome = function() {
return D_IS_CHROME;
};
DmmGameWeb.prototype.isIe = function() {
return D_IS_IE;
};
DmmGameWeb.prototype.isWin64bit = function() {
return D_IS_IE_64bit;
};
DmmGameWeb.prototype.isWinOs64bit = function() {
return D_IS_OS_64bit;
};
DmmGameWeb.prototype.isOut = function() {
return D_IS_OUT;
};
DmmGameWeb.prototype.isEdge = function() {
return D_IS_EDGE;
};
/*
objectタグをセットする
*/
DmmGameWeb.setNPAPITag = function() {
if ($("#npapiPlugin").size() <= 0) {
$("body").append(NPAPI_OBJECT_TAG);
}
};
/*
Firefox向けobjectタグをセットする
*/
DmmGameWeb.setNPAPITag4Firefox = function() {
$.each(navigator.plugins, function() {
if (this[0].type === "application/x-dmm_trigger") {
DmmGameWeb.setNPAPITag();
}
});
};
/*
NPAPIでのランチャー起動
@param launcherToken onetime_token
@param launcherUid viewer_id
@param redirectUrl リダイレクト先URL
@param contentsListUrl コンテンツリストのURL
@return bool|string npapiから受け取ったメッセージ。 存在しない場合はfalseを返す。
*/
DmmGameWeb.prototype.run4NPAPI = function(gameKey, userid, autologin_token, redirectUrl, contentsListUrl) {
var dmmPlugin, e, npapiPlugin, ret;
ret = false;
if (this.isWindows && (this.isFirefox())) {
_l("Windows版Firefoxです");
npapiPlugin = document.getElementById("npapiPlugin");
try {
//dmmPlugin = npapiPlugin.dmm_trigger();
ret = npapiPlugin.launcherOpen(
LAUNCHER_RUN_EXE,
"/content_list=" + contentsListUrl + " /user_id=" + userid + " /app_key=" + gameKey + " /autologin_token=" + autologin_token);
} catch (_error) {
e = _error;
location.href = redirectUrl;
}
return ret;
}
window.alert(MSG_UNSUPPORTED_BROWSER);
return ret;
};
/*
NMプログラムでのランチャー起動
@param launcherToken onetime_token
@param launcherUid viewer_id
@param flgOpenUrl dmm.comかdmm.co.jpのページを開くか。
FLAG_OPEN_NM_URL_DMM_COMでdmm.comのページ
FLAG_OPEN_NM_URL_DMM_COJPでdmm.co.jpのページ
@param contentsListUrl コンテンツリストのURL
@return false
*/
DmmGameWeb.prototype.runNmhChrome = function(gameKey, userid, autologin_token, redirectUrl, contentsListUrl) {
if (this.isWindows && this.isChrome()) {
_l("Windows版Chromeです");
if (DmmGameWeb.isExistExtension() === true) {
var arg = "/content_list=" + contentsListUrl + " /app_key=" + gameKey + " /user_id=" + userid + " /autologin_token=" + autologin_token;
chrome.runtime.sendMessage(CHROME_EXTENSION_ID, { "URL": LAUNCHER_RUN_EXE, "Arg": arg },
function(response) {
switch (response) {
case 0:
//alert("ランチャーは正常に起動しました。");
break;
case 1:
//alert("ランチャーのダウンロードを行い、正常に起動しました。");
break;
// case 2:
// alert("ランチャーのダウンロードに失敗しました。");
// break;
// case 3:
// alert("ランチャーの起動に失敗しました。");
// break;
// case 4:
default:
location.href = redirectUrl;
break;
}
});
} else {
//this.showInstallModal();
location.href = redirectUrl;
}
return false;
}
return false;
};
/*
ActiveXでのランチャー起動
@param launcherToken onetime_token
@param launcherUid viewer_id
@param flgOpenUrl dmm.comかdmm.co.jpのページを開くか。
FLAG_OPEN_NM_URL_DMM_COMでdmm.comのページ
FLAG_OPEN_NM_URL_DMM_COJPでdmm.co.jpのページ
@param contentsListUrl コンテンツリストのURL
@return false
*/
DmmGameWeb.prototype.runActivX = function(gameKey, userid, autologin_token, redirectUrl, contentsListUrl) {
if (this.isWindows && dgw.isIe()) {
try{
//_l("Windows版IEです");
objIe = document.getElementById("DMMLauncherAx");
objIe.launcherOpen(LAUNCHER_RUN_EXE, "/content_list=" + contentsListUrl + " /user_id=" + userid + " /app_key=" + gameKey + " /autologin_token=" + autologin_token);
} catch (_error) {
location.href = redirectUrl;
}
return false;
}
return false;
};
/*
ランチャー起動
@param launcherToken onetime_token
@param launcherUid viewer_id
@param flgOpenUrl dmm.comかdmm.co.jpのページを開くか。
FLAG_OPEN_NM_URL_DMM_COMでdmm.comのページ
FLAG_OPEN_NM_URL_DMM_COJPでdmm.co.jpのページ
他の値の場合は実行されているページのドメイン情報から一般・R18の判定を行う
@param contentsListUrl コンテンツリストのURL
*/
DmmGameWeb.prototype.run = function(gameKey, userid, autologin_token, pluginUrl, contentsListUrl) {
//対象外OS・ブラウザの場合、エラー
if (this.isOut()) {
window.alert(MSG_UNSUPPORTED_BROWSER);
return;
}
var hostName, ret;
ret = false;
if (this.isWindows && this.isIe()) {
ret = this.runActivX( gameKey, userid, autologin_token, pluginUrl, contentsListUrl);
} else if (this.isWindows && this.isChrome()) {
ret = this.runNmhChrome(gameKey, userid, autologin_token, pluginUrl, contentsListUrl);
} else if (this.isWindows && this.isFirefox()) {
DmmGameWeb.setNPAPITag();
ret = this.run4NPAPI(gameKey, userid, autologin_token, pluginUrl, contentsListUrl);
}
return ret;
};
DmmGameWeb.prototype.runLauncher = function(launcherKey, cryptKey, gameKey, pluginUrl) {
dgw = this;
if (dgw.isOut()) {
window.alert(MSG_UNSUPPORTED_BROWSER);
return;
}
$.ajax({
url : LAUNCHER_RUN_API,
type : 'POST',
dataType : 'jsonp',
timeout :10000,
data : {
launcher_key : launcherKey,
crypt_key : cryptKey
},
jsonpCallback : 'callback',
success : function(data)
{
launcherUid = data.viewer_id;
userid = data.user_id;
launcherToken = data.launcher_token;
resultCode = data.result_code;
autologin_token = data.auto_login_token;
verification_user = data.verification_user;
contentsListUrl = CONTENT_LIST;
if (verification_user == true) {
contentsListUrl = VERIFICATION_CONTENT_LIST;
}
if (resultCode == 0) {
// ランチャー起動
var ret = dgw.run(gameKey, userid, autologin_token, pluginUrl, contentsListUrl);
} else {
//var mes = "error code:" + resultCode;
var mes = "DMMランチャーが起動できません。DMMへの再ログインをお試しください。";
window.alert(mes);
return false;
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.alert('error api');
return false;
}
});
};
DmmGameWeb.prototype.launcherSet = function() {
if (this.isIe()) {
if (this.isWin64bit()) {
$("body").append(OBJECT_TAG_IE_64);
} else {
$("body").append(OBJECT_TAG_IE);
}
}
};
return DmmGameWeb;
})();
/*
//@ sourceMappingURL=index.js.map
*/
//ランチャーのセットアップ
jQuery.event.add(window, "load", function(){
var dgw = new DmmGameWeb();
dgw.launcherSet();
});