/*
The MIT License (MIT)
Copyright (c) 2014 RePod
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
//The license information above is also available in PSDLE's GitHub repository located here: https://github.com/RePod/psdle
var repod = {};
repod.psdle = {
gamelist: [], gamelist_cur: [], autocomplete_cache: [], lang: {}, id_cache: {}, type_cache: {}, sys_cache: {}, pid_cache:{},
lang_cache: {
"en": {
"def": "us",
"us":{"local":"English","startup":{"apis":"Select which APIs you would like to use, hover for more details. Certain APIs may not be disabled.","wait":"Please wait.","start":"Start"},"columns":{"icon":"Icon","name":"Name","platform":"Platform","size":"Size","date":"Date"},"labels":{"export_view":"Export View","page":"Page"},"categories":{"downloadable_game":"Games","demo":"Demos","add_on":"Add-ons","unlock":"Unlocks","unlock_key":"Unlock Keys","avatar":"Avatars","theme":"Themes","other":"other","other_game_related":"other_game_related","game_content":"game_content","tumbler_index":"tumbler_index","home":"home","ungrouped_game":"ungrouped_game","promo_content":"promo_content","beta":"Betas","application":"Applications","extras":"Extras","unknown":"Unknown"},"strings":{"delimiter":"Enter delimiter:","stringify_error":"Error: Browser does not have JSON.stringify.","yes":"Yes","no":"No","search":"Search by game title","dlQueue":"Queue","dlList":"List","plus":"Toggle visibility of PS+ titles.","queue_all":"All","queue_to":"Download to $SYS$"},"apis":[{"internal_id":"api_entitle","name":"Entitlements","desc":"Cannot be disabled. Accesses purchase information used to create the download list, determine PS+ status, and other things."},{"internal_id":"api_game","name":"Catalog","desc":"Accesses additional game information to determine proper console, fix broken images, and more."},{"internal_id":"api_queue","name":"Download Queue","desc":"Allows adding and removing items from the download queue. Reads download queue information and the amount of activated consoles on the account."},{"internal_id":"api_pstv","name":"PS TV","desc":"Detect PS TV compatible titles. Only supported on \"en-us\" web store (not PSDLE language).","disabled":true}]}
},
"es": {
"def": "mx",
"mx":{"local":"Español","startup":{"wait":"Esperando en la página se cargue."},"columns":{"icon":"Icono","name":"Nombre","platform":"Plataforma","size":"Tamaño","date":"Fecha"},"labels":{"export_view":"Exportar vista","page":"Paje"},"categories":{"downloadable_game":"Juegos","demo":"Población","avatar":"avatares","add_on":"Complementos","unlock":"Descubrir","theme":"Temas","application":"Aplicaciones","unknown":"Desconocido",},"strings":{"delimiter":"Ingrese delimitador:","stringify_error":"Error: Navegador no tiene JSON.stringify.","yes":"Sí","no":"No","search":"Búsqueda por título del juego"}} // Caaz, somebody.
},
"de": {
"def": "de",
"de":{"local":"Deutsch","startup":{"wait":"Seite wird geladen, bitte warten."},"columns":{"icon":"Symbol","name":"Name","platform":"Plattform","size":"Größe","date":"Datum"},"labels":{"export_view":"Exportiere Ansicht","page":"Seite"},"categories":{"downloadable_game":"Spiele","demo":"Demos","add_on":"Erweiterungen","unlock":"Freischaltbares","avatar":"Spielerbilder","theme":"Themen","application":"Anwendungen","unknown":"Unbekannt",},"strings":{"delimiter":"Geben sie ein Trennzeichen ein","stringify_error":"Fehler: Browser fehlt \"JSON.stringify\".","yes":"Ja","no":"Nein","search":"Spiele titel eingeben für direkte suche"}} // Provided by /u/_MrBubbles
},
"fr": {
"def": "fr",
"fr":{"local":"Français","startup":{"apis":"Sélectionner l'API à utiliser; Survoler pour plus de détails. Certaines APIs ne peuvent pas être désactivées.","wait":"Merci de patienter.","start":"Commencer"},"columns":{"icon":"Icône","name":"Nom","platform":"Plate-forme","size":"Taille","date":"Date"},"labels":{"export_view":"Exporter la vue","page":"Page"},"categories":{"downloadable_game":"Jeux","demo":"Démos","add_on":"DLCs","unlock":"Codes de déverouillage","avatar":"Avatars","theme":"Thèmes","application":"Applications","unknown":"Inconnu"},"strings":{"delimiter":"Entrer le délimiteur:","stringify_error":"Erreur: votre navigateur ne supporte pas JSON.stringify.","yes":"Oui","no":"Non","search":"Rechercher par titre de jeu","dlQueue":"Queue","dlList":"Liste","plus":"Afficher/cacher les titres PS+.","queue_all":"Tous","queue_to":"Télécharger sur $SYS$"},"apis":[{"internal_id":"api_entitle","name":"Droits","desc":"Ne peut pas être désactivée. Accède aux informations d'achat afin de créer la liste de téléchargement, et déterminer le statut PS+, ainsi que d'autres choses."},{"internal_id":"api_game","name":"Catalogue","desc":"Accède aux informations supplémentaires des jeux pour déterminer la plate-forme, corriger les liens d'images cassés, et plus."},{"internal_id":"api_queue","name":"Liste de téléchargement","desc":"Permet d'ajouter ou de retirer des articles de la liste de téléchargement. Lit les informations de la liste de téléchargement et le nombre de consoles activées sur le compte."},{"internal_id":"api_pstv","name":"PS TV","desc":"Détecte les titres compatibles PS TV. Ne marche que sur le store \"en-us\" (différent de la langue choisie pour PSDLE).","disabled":true}]} // Provided by @cramoisan
},
"ru": {
"def":"ru",
"ru":{"local":"Русский","startup":{"wait":"Ожидание загрузки страниц..."},"columns":{"icon":"Иконка","name":"Название","platform":"Платформа","size":"Размер","date":"Дата"},"labels":{"export_view":"Export View","page":"Страница"},"categories":{"downloadable_game":"Игры","demo":"Демо-версии","add_on":"Дополенния","unlock":"Разблокировки","avatar":"Аватары","theme":"Темы","application":"Приложения","unknown":"Неизвестно"},"strings":{"delimiter":"Введите разделитель:","stringify_error":"Ошибка: в браузере отсутствует JSON.stringify.","yes":"Да","no":"Нет","search":"Поиск по названию игры"}} //Provided by MorbertDou (issue #2)
},
"ps": {
"def": "ha",
"ha":{"local":"H4ker","startup":{"apis":"import.APIs (hover: man)","wait":"...","start":"make"},"columns":{"icon":"1con","name":"H4ndle","platform":"P|a+f0rm","size":"S1z3","date":"D4t3"},"labels":{"export_view":"D0x","page":"P4g3"},"categories":{"downloadable_game":"W4rez","demo":"Freeware","add_on":"Add-0ns","unlock":"Cracks","avatar":"4va+ar","theme":"Themes","other":"other","beta":"Betas","application":"S0f+w4r3","unknown":"?"},"strings":{"delimiter":"5pli+ by:","yes":"Y","no":"N","search":"grep","queue_all":"wget all","queue_to":"wget $SYS$"}} //Caaz
}
},
determineLanguage: function(e,f) {
e = (e) ? e.split("-") : this.config.language.split("-");
if (f === true) { this.lang = {}; this.lang = this.lang_cache.en.us; }
if (e[0] in this.lang_cache) {
if (e[1] in this.lang_cache[e[0]]) {
if (f === true) { $.extend(true,this.lang,this.lang_cache[e[0]][e[1]]); this.sanitizeLanguage(); }
e = e[0]+"-"+e[1];
} else {
if (f === true) { $.extend(true,this.lang,this.lang_cache[e[0]][this.lang_cache[e[0]].def]); this.sanitizeLanguage(); }
e = e[0]+"-"+this.lang_cache[e[0]].def;
}
} else {
e = "en-us";
}
return e;
},
sanitizeLanguage: function() {
//Send help.
var a = JSON.stringify(this.lang, function(key, value) { if(typeof value === "string") { return value.replace(/'/g, "'"); } return value; });
this.lang = JSON.parse(a);
},
generateLangBox: function(e) {
var temp = "";
return temp;
},
init: function() {
console.log("PSDLE | Init.");
var that = this;
this.config = {
logoBase64: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFQAAAAfCAYAAAEO89r4AAABaUlEQVRoge2XS27CQAyGPSVSUVErdqzpMqveiRvALnu67Gl6D+gFuAKIPgQrs0o1TJSJJ7aJBvnbRXE8f357XoCIGyTiEBFf33+BwgMpyg/eVRNSsENEpAQWMa27agL1e7JWcmCSVSG+tF6jp1D4o/qkqN8un+Bl7JpJUxP5vH38XT2T655CtEf6olKoaFLq3ElK2heRlgq//U/KKVj4rcrvs+Y+h7Z1ow2Vv9eg6A5p53MxhnI2an0vWSmW0HI2EhUTI5vSN4T2Xem0ycZRh4h7AJgOLaQLlf1ega2br3/IQlMW6TA2dYEPc2XToyZUGtbOdMs1lyX0lqeubEpvQqVp9GhsghxPOpvY8yPA1yo+MRtCh7iWfJ/j49rOpEE2QnM55h1U7/Wcox0nb+y9lqY6dzYtmgtmqDBmqDBmqDCDGcq5Ew5xCqViHSqMGSqMGSqMGSpMp6H3unloYR0qjBkqjBkqjBkqzAUtBKxj5lT3GAAAAABJRU5ErkJggg==",
game_page: chihiro.getBaseUrl()+"#!/"+chihiro.getCultureCode()+"/cid=",
game_api: SonyChi_SessionManagerSingleton.getBaseCatalogURL()+"/",
lastsort: "",
lastsort_r: false,
language: chihiro.getCultureCode(),
deep_search: false,
deep_waiting: 0,
deep_current: 0,
last_search: "",
dlQueue: { base: SonyChi_SessionManagerSingleton.getDLQueueBaseURL(), status: SonyChi_SessionManagerSingleton.getDLQueueStatusURL(), status2: SonyChi_SessionManagerSingleton.getDLQueueStatusURL2() },
use_queue: 0, active_consoles: {},
tag_line: " Website - Repository - Submit Bug/Translation",
switch_align: "center", switch_color: "#85C107",
has_plus: false,
check_tv: false,
tv_url: atob("aHR0cHM6Ly9zdG9yZS5zb255ZW50ZXJ0YWlubWVudG5ldHdvcmsuY29tL3N0b3JlL2FwaS9jaGloaXJvLzAwXzA5XzAwMC9jb250YWluZXIvVVMvZW4vMTkvU1RPUkUtTVNGNzcwMDgtUFNUVlZJVEFHQU1FUz9zaXplPTMw")
};
try { if (GM_info) this.config.tag_line += " - Userscript: "+GM_info.script.version+""; } catch (e) { };
this.determineLanguage(this.config.language,true);
this.injectCSS();
SonyChi_SessionManagerSingleton.getUserDevices()
$(document).on('change', "#sub_container > select#lang_select", function() { that.config.language = $(this).val(); that.determineLanguage($(this).val(),true); that.genDisplay(); });
this.genStartup();
},
genStartup: function() {
if ($("#psdle_start").length == 0) {
var that = this, startup = $("
",{id:"psdle_start"}).css({"z-index":"9001","width":"84px","height":"31px","position":"fixed","bottom":"10px","left":"10px","cursor":"pointer","box-shadow":"0px 0px 10px #FFF","background-image":"url('"+repod.psdle.config.logoBase64+"')"}).appendTo("body");
$(document).one("click","#psdle_start",function() { $(this).remove(); that.genDisplay(); });
}
},
genDisplay:function(mode,fake_list) {
var that = this;
if (!$("#muh_games_container").length) { $("body").append(""); }
$(document).off("click",".psdle_btn"); $(document).off("click", "#inject_lang"); $(document).off("click", "#gen_fake"); $(document).off('click',"#psdle_go");
$("#muh_games_container").slideUp('slow', function() {
var a = "
";
if (mode == "progress") {
if (that.config.use_queue) {
var sys = {}, c = SonyChi_SessionManagerSingleton.getUserObject();
if (c.hasActiveVita()) { sys.vita = 1; }
if (c.hasActivePS3()) { sys.ps3 = 1; }
if (c.hasActivePS4()) { sys.ps4 = 1; }
that.config.active_consoles = sys;
}
a += "
"+that.lang.startup.wait+"";
} else {
a += "
"+that.lang.startup.apis+"
";
$.each(that.lang.apis, function(key,con) {
if (con.internal_id == "api_pstv") {
a += (chihiro.getCultureCode() == "en-us")?""+con.name+"":"";
} else {
a += ""+con.name.replace(/'/g, "'")+"";
}
});
a += "
"+that.lang.startup.start+" "+that.generateLangBox()+that.config.tag_line;
a += " Inject Language - Language Template - Generate Fake List";
a +="
";
return temp;
},
totals: function() {
var a = 0; $.each(repod.psdle.gamelist_cur, function(b,c) { a += c.size; });
return "
"+formatFileSizeDisplayStr(a)+"
";
}
}
},
newbox: {
generate: function(e) {
var plus = "", i = (isNaN(e)) ? Number($(e).attr("id").split("_").pop()) : Number(e), game = repod.psdle.gamelist[i], id = (game.index -1);
var dialog = $("");
try { if (game.plus) { plus = $("#psdleplus").clone()[0].outerHTML+" "; } } catch(e) {}
dialog.append("
"+plus+game.name+"
");
if (repod.psdle.config.use_queue) {
var t = "
"+repod.psdle.lang.strings.queue_all+"
";
var temp = game.platform_og.slice(0), i = $.inArray("PSP", temp); if(i != -1) { temp.splice(i, 1); } /* Make sure we don't have PSP */
if (temp.length > 1) {
$.each(temp,function(a,b) {
var c = b.replace(/ps /i,"").toLowerCase(), d = (repod.psdle.config.active_consoles.hasOwnProperty(c)) ? "" : "toggled_off";
t += "
"+b+"
";
});
} else {
var c = temp[0].slice(0).replace(/ps /i,"").toLowerCase(), d = (repod.psdle.config.active_consoles.hasOwnProperty(c)) ? "" : "toggled_off";
t = "