Update prettier printWidth
parent
e06f0db041
commit
1d5836c0d0
|
@ -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<Game>(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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<LoginResult> {
|
||||
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<boolean> {
|
||||
export async function urlExists(url: string, checkRedirect: boolean = false): Promise<boolean> {
|
||||
// Local variables
|
||||
let valid = false;
|
||||
|
||||
|
@ -376,10 +368,7 @@ function manageLoginPOSTResponse(response: AxiosResponse<any>) {
|
|||
}
|
||||
|
||||
// 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() === "";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -59,9 +59,7 @@ function parseJSONLD(element: cheerio.Element): TJsonLD {
|
|||
const html = cheerio(element).html().trim();
|
||||
|
||||
// Obtain the JSON-LD
|
||||
const data = html
|
||||
.replace('<script type="application/ld+json">', "")
|
||||
.replace("</script>", "");
|
||||
const data = html.replace('<script type="application/ld+json">', "").replace("</script>", "");
|
||||
|
||||
// Convert the string to an object
|
||||
return JSON.parse(data);
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue