diff --git a/src/scripts/classes/mapping/post.ts b/src/scripts/classes/mapping/post.ts index 0b618e5..10db347 100644 --- a/src/scripts/classes/mapping/post.ts +++ b/src/scripts/classes/mapping/post.ts @@ -84,7 +84,7 @@ export default class Post { const post = $(THREAD.POSTS_IN_PAGE).toArray().find((el, idx) => { // Fetch the ID and check if it is what we are searching const sid: string = $(el).find(POST.ID).attr("id").replace("post-", ""); - const id = parseInt(sid); + const id = parseInt(sid, 10); if (id === this.id) return el; }); @@ -101,11 +101,11 @@ export default class Post { private async parsePost($: cheerio.Root, post: cheerio.Cheerio): Promise { // Find post's ID const sid: string = post.find(POST.ID).attr("id").replace("post-", ""); - this._id = parseInt(sid); + this._id = parseInt(sid, 10); // Find post's number const sNumber: string = post.find(POST.NUMBER).text().replace("#", ""); - this._number = parseInt(sNumber); + this._number = parseInt(sNumber, 10); // Find post's publishing date const sPublishing: string = post.find(POST.PUBLISH_DATE).attr("datetime"); @@ -117,7 +117,7 @@ export default class Post { // Find post's owner const sOwnerID: string = post.find(POST.OWNER_ID).attr("data-user-id").trim(); - this._owner = new PlatformUser(parseInt(sOwnerID)); + this._owner = new PlatformUser(parseInt(sOwnerID, 10)); await this._owner.fetch(); // Find if the post is bookmarked diff --git a/src/scripts/classes/mapping/thread.ts b/src/scripts/classes/mapping/thread.ts index 6803cff..008934b 100644 --- a/src/scripts/classes/mapping/thread.ts +++ b/src/scripts/classes/mapping/thread.ts @@ -125,7 +125,7 @@ export default class Thread { .toArray() .map((el, idx) => { const id = $(el).find(POST.ID).attr("id").replace("post-", ""); - return new Post(parseInt(id)); + return new Post(parseInt(id, 10)); }); // Wait for the post to be fetched @@ -174,8 +174,8 @@ export default class Thread { const ratingTree = data["aggregateRating"] as TJsonLD; const rating: TRating = { average: ratingTree ? parseFloat(ratingTree["ratingValue"] as string) : 0, - best: ratingTree ? parseInt(ratingTree["bestRating"] as string) : 0, - count: ratingTree ? parseInt(ratingTree["ratingCount"] as string) : 0, + best: ratingTree ? parseInt(ratingTree["bestRating"] as string, 10) : 0, + count: ratingTree ? parseInt(ratingTree["ratingCount"] as string, 10) : 0, }; return rating; @@ -227,7 +227,7 @@ export default class Thread { this._title = this.cleanHeadline(JSONLD["headline"] as string); this._tags = tagArray.map(el => $(el).text().trim()); this._prefixes = prefixArray.map(el => $(el).text().trim()); - this._owner = new PlatformUser(parseInt(ownerID)); + this._owner = new PlatformUser(parseInt(ownerID, 10)); await this._owner.fetch(); this._rating = this.parseRating(JSONLD); this._category = JSONLD["articleSection"] as TCategory; diff --git a/src/scripts/classes/mapping/user-profile.ts b/src/scripts/classes/mapping/user-profile.ts index c75e85f..ed4514a 100644 --- a/src/scripts/classes/mapping/user-profile.ts +++ b/src/scripts/classes/mapping/user-profile.ts @@ -100,7 +100,7 @@ export default class UserProfile extends PlatformUser { const $ = cheerio.load(htmlResponse.value); const sid = $(GENERIC.CURRENT_USER_ID).attr("data-user-id").trim(); - return parseInt(sid); + return parseInt(sid, 10); } else throw htmlResponse.value; } @@ -116,7 +116,7 @@ export default class UserProfile extends PlatformUser { const $ = cheerio.load(htmlResponse.value); // Fetch the pages - const lastPage = parseInt($(WATCHED_THREAD.LAST_PAGE).text().trim()); + const lastPage = parseInt($(WATCHED_THREAD.LAST_PAGE).text().trim(), 10); const pages = await this.fetchPages(url, lastPage); const watchedThreads = pages.map((r, idx) => { diff --git a/src/scripts/classes/prefix-parser.ts b/src/scripts/classes/prefix-parser.ts index 15c8e25..dda21ff 100644 --- a/src/scripts/classes/prefix-parser.ts +++ b/src/scripts/classes/prefix-parser.ts @@ -82,7 +82,7 @@ export default class PrefixParser { if (dict) { // Extract the key from the dict const key = this.getKeyByValue(dict, p); - ids.push(parseInt(key)); + ids.push(parseInt(key), 10); } } return ids;