diff --git a/src/example.ts b/src/example.ts index 89f97a5..b036a7f 100644 --- a/src/example.ts +++ b/src/example.ts @@ -60,11 +60,7 @@ async function main() { // Log in the platform console.log("Authenticating..."); - const result = await login( - process.env.F95_USERNAME, - process.env.F95_PASSWORD, - insert2faCode - ); + const result = await login(process.env.F95_USERNAME, process.env.F95_PASSWORD, insert2faCode); console.log(`Authentication result: ${result.message}\n`); // Manage failed login @@ -87,9 +83,7 @@ async function main() { latestQuery.includedTags = ["3d game"]; const latestUpdates = await getLatestUpdates(latestQuery, 1); - console.log( - `"${latestUpdates.shift().name}" was the last "3d game" tagged game to be updated\n` - ); + console.log(`"${latestUpdates.shift().name}" was the last "3d game" tagged game to be updated\n`); // Get game data for (const gamename of gameList) { diff --git a/src/scripts/classes/handiwork/handiwork.ts b/src/scripts/classes/handiwork/handiwork.ts index 6c5af21..cb68d27 100644 --- a/src/scripts/classes/handiwork/handiwork.ts +++ b/src/scripts/classes/handiwork/handiwork.ts @@ -6,14 +6,7 @@ "use strict"; // Modules from files -import { - TAuthor, - TRating, - IHandiwork, - TEngine, - TCategory, - TStatus -} from "../../interfaces"; +import { TAuthor, TRating, IHandiwork, TEngine, TCategory, TStatus } from "../../interfaces"; /** * It represents a generic work, be it a game, a comic, an animation or an asset. diff --git a/src/scripts/classes/query/handiwork-search-query.ts b/src/scripts/classes/query/handiwork-search-query.ts index e55c328..0ab3399 100644 --- a/src/scripts/classes/query/handiwork-search-query.ts +++ b/src/scripts/classes/query/handiwork-search-query.ts @@ -96,8 +96,7 @@ export default class HandiworkSearchQuery implements IQuery { // If the keywords are set or the number // of included tags is greather than 5, // we must perform a thread search - if (this.keywords || this.includedTags.length > MAX_TAGS_LATEST_SEARCH) - return "thread"; + if (this.keywords || this.includedTags.length > MAX_TAGS_LATEST_SEARCH) return "thread"; return DEFAULT_SEARCH_TYPE; } diff --git a/src/scripts/classes/query/thread-search-query.ts b/src/scripts/classes/query/thread-search-query.ts index cfa8308..10569c6 100644 --- a/src/scripts/classes/query/thread-search-query.ts +++ b/src/scripts/classes/query/thread-search-query.ts @@ -130,8 +130,7 @@ export default class ThreadSearchQuery implements IQuery { if (this.excludedTags) params["c[excludeTags]"] = this.excludedTags.join(","); // Set minimum reply number - if (this.minimumReplies > 0) - params["c[min_reply_count]"] = this.minimumReplies.toString(); + if (this.minimumReplies > 0) params["c[min_reply_count]"] = this.minimumReplies.toString(); // Add prefixes const parser = new PrefixParser(); diff --git a/src/scripts/classes/session.ts b/src/scripts/classes/session.ts index 79b328f..a3603b6 100644 --- a/src/scripts/classes/session.ts +++ b/src/scripts/classes/session.ts @@ -210,8 +210,8 @@ export default class Session { // Search for expired cookies const jarValid = - this._cookieJar.getCookiesSync("https://f95zone.to").filter((el) => el.TTL() === 0) - .length === 0; + this._cookieJar.getCookiesSync("https://f95zone.to").filter((el) => el.TTL() === 0).length === + 0; return dateValid && hashValid && jarValid; } diff --git a/src/scripts/constants/css-selector.ts b/src/scripts/constants/css-selector.ts index d1c528b..e1bc733 100644 --- a/src/scripts/constants/css-selector.ts +++ b/src/scripts/constants/css-selector.ts @@ -162,8 +162,7 @@ export const POST = { /** * Contents of a spoiler element in a post. */ - SPOILER_CONTENT: - "div.bbCodeSpoiler-content > div.bbCodeBlock--spoiler > div.bbCodeBlock-content" + SPOILER_CONTENT: "div.bbCodeSpoiler-content > div.bbCodeBlock--spoiler > div.bbCodeBlock-content" }; export const MEMBER = { @@ -214,8 +213,7 @@ export const MEMBER = { * If the text is `Unfollow` then the user is followed. * If the text is `Follow` then the user is not followed. */ - FOLLOWED: - "div.memberHeader-buttons > div.buttonGroup:first-child > a[data-sk-follow] > span", + FOLLOWED: "div.memberHeader-buttons > div.buttonGroup:first-child > a[data-sk-follow] > span", /** * Button used to ignore/unignore the user. * diff --git a/src/scripts/interfaces.ts b/src/scripts/interfaces.ts index ba544c6..33916e6 100644 --- a/src/scripts/interfaces.ts +++ b/src/scripts/interfaces.ts @@ -83,10 +83,7 @@ export type TCategory = "games" | "mods" | "comics" | "animations" | "assets"; /** * Valid names of classes that implement the IQuery interface. */ -export type TQueryInterface = - | "LatestSearchQuery" - | "ThreadSearchQuery" - | "HandiworkSearchQuery"; +export type TQueryInterface = "LatestSearchQuery" | "ThreadSearchQuery" | "HandiworkSearchQuery"; /** * Collection of values defined for each diff --git a/src/scripts/network-helper.ts b/src/scripts/network-helper.ts index 86293bf..d2d29d3 100644 --- a/src/scripts/network-helper.ts +++ b/src/scripts/network-helper.ts @@ -86,9 +86,7 @@ export async function fetchHTML( error: null }); - return isHTML - ? success(response.value.data as string) - : failure(unexpectedResponseError); + return isHTML ? success(response.value.data as string) : failure(unexpectedResponseError); } else return failure(response.value as GenericAxiosError); } @@ -105,8 +103,7 @@ export async function authenticate( force: boolean = false ): Promise { shared.logger.info(`Authenticating with user ${credentials.username}`); - if (!credentials.token) - throw new InvalidF95Token(`Invalid token for auth: ${credentials.token}`); + if (!credentials.token) throw new InvalidF95Token(`Invalid token for auth: ${credentials.token}`); // Secure the URL const secureURL = enforceHttpsUrl(urls.LOGIN); @@ -216,9 +213,7 @@ export async function fetchGETResponse( const response = await axios.get(secureURL, commonConfig); return success(response); } catch (e) { - shared.logger.error( - `(GET) Error ${e.message} occurred while trying to fetch ${secureURL}` - ); + shared.logger.error(`(GET) Error ${e.message} occurred while trying to fetch ${secureURL}`); const genericError = new GenericAxiosError({ id: 1, message: `(GET) Error ${e.message} occurred while trying to fetch ${secureURL}`, @@ -305,10 +300,7 @@ export function isStringAValidURL(url: string): boolean { * If `true`, the function will consider redirects a violation and return `false`. * Default: `false` */ -export async function urlExists( - url: string, - checkRedirect: boolean = false -): Promise { +export async function urlExists(url: string, checkRedirect: boolean = false): Promise { // Local variables let valid = false; @@ -376,10 +368,7 @@ function manageLoginPOSTResponse(response: AxiosResponse) { } // Get the error message (if any) and remove the new line chars - const errorMessage = $("body") - .find(GENERIC.LOGIN_MESSAGE_ERROR) - .text() - .replace(/\n/g, ""); + const errorMessage = $("body").find(GENERIC.LOGIN_MESSAGE_ERROR).text().replace(/\n/g, ""); // Return the result of the authentication const result = errorMessage.trim() === ""; diff --git a/src/scripts/scrape-data/handiwork-parse.ts b/src/scripts/scrape-data/handiwork-parse.ts index 892295b..98b4a25 100644 --- a/src/scripts/scrape-data/handiwork-parse.ts +++ b/src/scripts/scrape-data/handiwork-parse.ts @@ -122,10 +122,7 @@ function stringToBoolean(s: string): boolean { * * Case-insensitive. */ -function getPostElementByName( - elements: IPostElement[], - name: string -): IPostElement | undefined { +function getPostElementByName(elements: IPostElement[], name: string): IPostElement | undefined { return elements.find((el) => el.name.toUpperCase() === name.toUpperCase()); } @@ -162,8 +159,7 @@ function fillWithPrefixes(hw: HandiWork, prefixes: string[]) { // Check what the prefix indicates if (stringInDict(prefix, shared.prefixes["engines"])) engine = prefix as TEngine; - else if (stringInDict(prefix, shared.prefixes["statuses"])) - status = prefix as TStatus; + else if (stringInDict(prefix, shared.prefixes["statuses"])) status = prefix as TStatus; else if (stringInDict(prefix, fakeModDict)) mod = true; // Anyway add the prefix to list @@ -206,8 +202,7 @@ function fillWithPostData(hw: HandiWork, elements: IPostElement[]) { // Parse the censorship const censored = - getPostElementByName(elements, "censored") || - getPostElementByName(elements, "censorship"); + getPostElementByName(elements, "censored") || getPostElementByName(elements, "censorship"); if (censored) hw.censored = stringToBoolean(censored.text); // Get the genres @@ -249,8 +244,7 @@ function fillWithPostData(hw: HandiWork, elements: IPostElement[]) { //#region Get the changelog hw.changelog = []; const changelogElement = - getPostElementByName(elements, "changelog") || - getPostElementByName(elements, "change-log"); + getPostElementByName(elements, "changelog") || getPostElementByName(elements, "change-log"); if (changelogElement) { const changelogSpoiler = changelogElement?.content.find((el) => { return el.type === "Spoiler" && el.content.length > 0; diff --git a/src/scripts/scrape-data/json-ld.ts b/src/scripts/scrape-data/json-ld.ts index 360492a..446ee1c 100644 --- a/src/scripts/scrape-data/json-ld.ts +++ b/src/scripts/scrape-data/json-ld.ts @@ -59,9 +59,7 @@ function parseJSONLD(element: cheerio.Element): TJsonLD { const html = cheerio(element).html().trim(); // Obtain the JSON-LD - const data = html - .replace('", ""); + const data = html.replace('", ""); // Convert the string to an object return JSON.parse(data); diff --git a/test/classes/mapping/thread.ts b/test/classes/mapping/thread.ts index e9bac61..f932a40 100644 --- a/test/classes/mapping/thread.ts +++ b/test/classes/mapping/thread.ts @@ -34,8 +34,6 @@ export function suite(): void { it("Fetch post with invalid ID", async function fetchWithInvalidID() { Shared.setIsLogged(true); const thread = new Thread(-1); - await expect(thread.getPost(0)).to.be.rejectedWith( - "Index must be greater or equal than 1" - ); + await expect(thread.getPost(0)).to.be.rejectedWith("Index must be greater or equal than 1"); }); } diff --git a/test/classes/prefix-parser.ts b/test/classes/prefix-parser.ts index 6460179..f4a28cd 100644 --- a/test/classes/prefix-parser.ts +++ b/test/classes/prefix-parser.ts @@ -29,15 +29,7 @@ export function suite(): void { // Test values const testIDs = [103, 225, 44, 13, 2, 7, 22]; - const testPrefixes = [ - "corruption", - "pregnancy", - "slave", - "VN", - "RPGM", - "Ren'Py", - "Abandoned" - ]; + const testPrefixes = ["corruption", "pregnancy", "slave", "VN", "RPGM", "Ren'Py", "Abandoned"]; // Parse values const ids = parser.prefixesToIDs(testPrefixes);