Merge pull request #9 from MillenniumEarl/deepsource-transform-5bd5050a
Format code with prettierpull/10/head
commit
0014627d48
|
@ -308,8 +308,7 @@ module.exports.logout = function () {
|
||||||
|
|
||||||
// Gracefully close shared browser
|
// Gracefully close shared browser
|
||||||
if (!shared.isolation && _browser !== null) {
|
if (!shared.isolation && _browser !== null) {
|
||||||
_browser.close()
|
_browser.close().then(() => (_browser = null));
|
||||||
.then(() => _browser = null);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
|
@ -1,43 +1,37 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
class GameDownload {
|
class GameDownload {
|
||||||
constructor() {
|
constructor() {
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
* Platform that hosts game files
|
|
||||||
* @type String
|
|
||||||
*/
|
|
||||||
this.hosting = "";
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
* Link to game files
|
|
||||||
* @type String
|
|
||||||
*/
|
|
||||||
this.link = null;
|
|
||||||
/**
|
|
||||||
* @public
|
|
||||||
* Operating systems supported by the game version indicated in this class.
|
|
||||||
* Can be *WINDOWS/LINUX/MACOS*
|
|
||||||
* @type String[]
|
|
||||||
*/
|
|
||||||
this.supportedOS = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
* Download the game data in the indicated path
|
* Platform that hosts game files
|
||||||
* @param {string} path Save path
|
* @type String
|
||||||
*/
|
*/
|
||||||
download(path){
|
this.hosting = "";
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* Link to game files
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
this.link = null;
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* Operating systems supported by the game version indicated in this class.
|
||||||
|
* Can be *WINDOWS/LINUX/MACOS*
|
||||||
|
* @type String[]
|
||||||
|
*/
|
||||||
|
this.supportedOS = [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* @public
|
||||||
|
* Download the game data in the indicated path
|
||||||
|
* @param {string} path Save path
|
||||||
|
*/
|
||||||
|
download(path) {}
|
||||||
}
|
}
|
||||||
module.exports = GameDownload;
|
module.exports = GameDownload;
|
||||||
|
|
||||||
function downloadMEGA(url){
|
function downloadMEGA(url) {}
|
||||||
|
|
||||||
}
|
function downloadNOPY(url) {}
|
||||||
|
|
||||||
function downloadNOPY(url){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const UNKNOWN = 'Unknown';
|
const UNKNOWN = "Unknown";
|
||||||
|
|
||||||
class GameInfo {
|
class GameInfo {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -71,8 +71,8 @@ class GameInfo {
|
||||||
*/
|
*/
|
||||||
this.gameDir = UNKNOWN;
|
this.gameDir = UNKNOWN;
|
||||||
/**
|
/**
|
||||||
* Information on game file download links,
|
* Information on game file download links,
|
||||||
* including information on hosting platforms
|
* including information on hosting platforms
|
||||||
* and operating system supported by the specific link
|
* and operating system supported by the specific link
|
||||||
* @type GameDownload[]
|
* @type GameDownload[]
|
||||||
*/
|
*/
|
||||||
|
@ -97,8 +97,8 @@ class GameInfo {
|
||||||
lastPlayed: this.lastPlayed,
|
lastPlayed: this.lastPlayed,
|
||||||
isMod: this.isMod,
|
isMod: this.isMod,
|
||||||
gameDir: this.gameDir,
|
gameDir: this.gameDir,
|
||||||
downloadInfo: this.downloadInfo
|
downloadInfo: this.downloadInfo,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,4 +110,4 @@ class GameInfo {
|
||||||
return Object.assign(new GameInfo(), json);
|
return Object.assign(new GameInfo(), json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = GameInfo;
|
module.exports = GameInfo;
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing the data of the user currently connected to the F95Zone platform.
|
* Class containing the data of the user currently connected to the F95Zone platform.
|
||||||
*/
|
*/
|
||||||
class UserData {
|
class UserData {
|
||||||
constructor() {
|
constructor() {
|
||||||
/**
|
/**
|
||||||
* User username.
|
* User username.
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.username = "";
|
this.username = "";
|
||||||
/**
|
/**
|
||||||
* Path to the user's profile picture.
|
* Path to the user's profile picture.
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.avatarSrc = null;
|
this.avatarSrc = null;
|
||||||
/**
|
/**
|
||||||
* List of followed thread URLs.
|
* List of followed thread URLs.
|
||||||
* @type URL[]
|
* @type URL[]
|
||||||
*/
|
*/
|
||||||
this.watchedThreads = [];
|
this.watchedThreads = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserData;
|
module.exports = UserData;
|
||||||
|
|
|
@ -1,159 +1,159 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
// Core modules
|
// Core modules
|
||||||
const { join } = require('path');
|
const { join } = require("path");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing variables shared between modules.
|
* Class containing variables shared between modules.
|
||||||
*/
|
*/
|
||||||
class Shared {
|
class Shared {
|
||||||
//#region Properties
|
//#region Properties
|
||||||
/**
|
/**
|
||||||
* Shows log messages and other useful functions for module debugging.
|
* Shows log messages and other useful functions for module debugging.
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
static _debug = false;
|
static _debug = false;
|
||||||
/**
|
/**
|
||||||
* Indicates whether a user is logged in to the F95Zone platform or not.
|
* Indicates whether a user is logged in to the F95Zone platform or not.
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
static _isLogged = false;
|
static _isLogged = false;
|
||||||
/**
|
/**
|
||||||
* List of cookies obtained from the F95Zone platform.
|
* List of cookies obtained from the F95Zone platform.
|
||||||
* @type Object[]
|
* @type Object[]
|
||||||
*/
|
*/
|
||||||
static _cookies = null;
|
static _cookies = null;
|
||||||
/**
|
/**
|
||||||
* List of possible game engines used for development.
|
* List of possible game engines used for development.
|
||||||
* @type String[]
|
* @type String[]
|
||||||
*/
|
*/
|
||||||
static _engines = null;
|
static _engines = null;
|
||||||
/**
|
/**
|
||||||
* List of possible development statuses that a game can assume.
|
* List of possible development statuses that a game can assume.
|
||||||
* @type String[]
|
* @type String[]
|
||||||
*/
|
*/
|
||||||
static _statuses = null;
|
static _statuses = null;
|
||||||
/**
|
/**
|
||||||
* Wait instruction for the browser created by puppeteer.
|
* Wait instruction for the browser created by puppeteer.
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
static WAIT_STATEMENT = 'domcontentloaded';
|
static WAIT_STATEMENT = "domcontentloaded";
|
||||||
/**
|
/**
|
||||||
* Path to the directory to save the cache generated by the API.
|
* Path to the directory to save the cache generated by the API.
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
static _cacheDir = './f95cache';
|
static _cacheDir = "./f95cache";
|
||||||
/**
|
/**
|
||||||
* If true, it opens a new browser for each request to
|
* If true, it opens a new browser for each request to
|
||||||
* the F95Zone platform, otherwise it reuses the same.
|
* the F95Zone platform, otherwise it reuses the same.
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
static _isolation = false;
|
static _isolation = false;
|
||||||
//#endregion Properties
|
//#endregion Properties
|
||||||
|
|
||||||
//#region Getters
|
//#region Getters
|
||||||
/**
|
/**
|
||||||
* Shows log messages and other useful functions for module debugging.
|
* Shows log messages and other useful functions for module debugging.
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
static get debug() {
|
static get debug() {
|
||||||
return this._debug;
|
return this._debug;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Indicates whether a user is logged in to the F95Zone platform or not.
|
* Indicates whether a user is logged in to the F95Zone platform or not.
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
static get isLogged() {
|
static get isLogged() {
|
||||||
return this._isLogged;
|
return this._isLogged;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* List of cookies obtained from the F95Zone platform.
|
* List of cookies obtained from the F95Zone platform.
|
||||||
* @returns {Object[]}
|
* @returns {Object[]}
|
||||||
*/
|
*/
|
||||||
static get cookies() {
|
static get cookies() {
|
||||||
return this._cookies;
|
return this._cookies;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* List of possible game engines used for development.
|
* List of possible game engines used for development.
|
||||||
* @returns {String[]}
|
* @returns {String[]}
|
||||||
*/
|
*/
|
||||||
static get engines() {
|
static get engines() {
|
||||||
return this._engines;
|
return this._engines;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* List of possible development states that a game can assume.
|
* List of possible development states that a game can assume.
|
||||||
* @returns {String[]}
|
* @returns {String[]}
|
||||||
*/
|
*/
|
||||||
static get statuses() {
|
static get statuses() {
|
||||||
return this._statuses;
|
return this._statuses;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Directory to save the API cache.
|
* Directory to save the API cache.
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
static get cacheDir() {
|
static get cacheDir() {
|
||||||
return this._cacheDir;
|
return this._cacheDir;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Path to the F95 platform cache.
|
* Path to the F95 platform cache.
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
static get cookiesCachePath() {
|
static get cookiesCachePath() {
|
||||||
return join(this._cacheDir, 'cookies.json');
|
return join(this._cacheDir, "cookies.json");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Path to the game engine cache.
|
* Path to the game engine cache.
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
static get enginesCachePath() {
|
static get enginesCachePath() {
|
||||||
return join(this._cacheDir, 'engines.json');
|
return join(this._cacheDir, "engines.json");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Path to the cache of possible game states.
|
* Path to the cache of possible game states.
|
||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
static get statusesCachePath() {
|
static get statusesCachePath() {
|
||||||
return join(this._cacheDir, 'statuses.json');
|
return join(this._cacheDir, "statuses.json");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* If true, it opens a new browser for each request
|
* If true, it opens a new browser for each request
|
||||||
* to the F95Zone platform, otherwise it reuses the same.
|
* to the F95Zone platform, otherwise it reuses the same.
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
static get isolation() {
|
static get isolation() {
|
||||||
return this._isolation;
|
return this._isolation;
|
||||||
}
|
}
|
||||||
//#endregion Getters
|
//#endregion Getters
|
||||||
|
|
||||||
//#region Setters
|
//#region Setters
|
||||||
static set cookies(val) {
|
static set cookies(val) {
|
||||||
this._cookies = val;
|
this._cookies = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set engines(val) {
|
static set engines(val) {
|
||||||
this._engines = val;
|
this._engines = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set statuses(val) {
|
static set statuses(val) {
|
||||||
this._statuses = val;
|
this._statuses = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set cacheDir(val) {
|
static set cacheDir(val) {
|
||||||
this._cacheDir = val;
|
this._cacheDir = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set debug(val) {
|
static set debug(val) {
|
||||||
this._debug = val;
|
this._debug = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set isLogged(val) {
|
static set isLogged(val) {
|
||||||
this._isLogged = val;
|
this._isLogged = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set isolation(val) {
|
static set isolation(val) {
|
||||||
this._isolation = val;
|
this._isolation = val;
|
||||||
}
|
}
|
||||||
//#endregion Setters
|
//#endregion Setters
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Shared;
|
module.exports = Shared;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
// Modules from file
|
// Modules from file
|
||||||
const {
|
const { F95_BASE_URL } = require("./constants/urls.js");
|
||||||
F95_BASE_URL
|
|
||||||
} = require('./constants/urls.js');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
@ -11,10 +9,10 @@ const {
|
||||||
* @param {String} url URL to check
|
* @param {String} url URL to check
|
||||||
* @returns {Boolean} true if the url belongs to the domain, false otherwise
|
* @returns {Boolean} true if the url belongs to the domain, false otherwise
|
||||||
*/
|
*/
|
||||||
module.exports.isF95URL = function(url) {
|
module.exports.isF95URL = function (url) {
|
||||||
if (url.toString().startsWith(F95_BASE_URL)) return true;
|
if (url.toString().startsWith(F95_BASE_URL)) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
@ -22,11 +20,11 @@ module.exports.isF95URL = function(url) {
|
||||||
* @param {String} url String to check for correctness
|
* @param {String} url String to check for correctness
|
||||||
* @returns {Boolean} true if the string is a valid URL, false otherwise
|
* @returns {Boolean} true if the string is a valid URL, false otherwise
|
||||||
*/
|
*/
|
||||||
module.exports.isStringAValidURL = function(url) {
|
module.exports.isStringAValidURL = function (url) {
|
||||||
try {
|
try {
|
||||||
new URL(url);
|
new URL(url);
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in New Issue