From a903148bc5d50d4e5f9258ee29e30f08612f0f1d Mon Sep 17 00:00:00 2001 From: HenkerX64 Date: Fri, 25 Feb 2022 03:09:00 +0100 Subject: [PATCH] Added YouTube video auto fetching, PostCommentOnFriendsScreenshot quest moved to non-limited accounts. - added noinspection for default options --- classes/CCommunityLeader.js | 12 ++++++++---- resources/OCommunityLeaderDefault.js | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/classes/CCommunityLeader.js b/classes/CCommunityLeader.js index e8c7160..2fc41b2 100644 --- a/classes/CCommunityLeader.js +++ b/classes/CCommunityLeader.js @@ -205,7 +205,6 @@ function CCommunityLeader(communityBadge, options) { friendQuests.push('PostCommentOnFriendsPage'); } await execute(friendQuests.concat([ - 'PostCommentOnFriendsScreenshot', 'RateUpContentInActivityFeed', 'UseEmoticonInChat', ])); @@ -220,6 +219,7 @@ function CCommunityLeader(communityBadge, options) { ]); if (!this.isLimitedAccount) { await execute([ + 'PostCommentOnFriendsScreenshot', 'RecommendGame', ]); } @@ -405,10 +405,14 @@ CCommunityLeader.prototype.PostVideo = function () { return new Promise(async (resolve) => { this._badgeUnlocker.setYoutubeCookies(this.options.youtubeCookies); if (!this.options.youtubeId) { - resolve(false); - return; + const videos = await this._badgeUnlocker.fetchYoutubeVideos().catch(() => []); + if (videos.length === 0) { + resolve(false); + return; + } + this.options.youtubeId = videos[0].youtubeId; } - const postedVideos = await this._badgeUnlocker.postYoutubeVideo(this.options.youtubeId); + const postedVideos = await this._badgeUnlocker.postYoutubeVideo(this.options.youtubeId).catch(() => 0); if (postedVideos > 0) { const videos = await this._badgeUnlocker.getProfileVideos().catch(() => []); for (let video of videos) { diff --git a/resources/OCommunityLeaderDefault.js b/resources/OCommunityLeaderDefault.js index c1490ce..287da0a 100644 --- a/resources/OCommunityLeaderDefault.js +++ b/resources/OCommunityLeaderDefault.js @@ -1,3 +1,5 @@ +// noinspection JSValidateJSDoc + /** @class OCommunityLeaderDefault */ module.exports = { /** @type {string} */ @@ -34,11 +36,11 @@ module.exports = { /** @type {string} */ screenshotPath: __dirname + '/empty.png', - /** @type {string} */ + /** @type {string|null} (optional) */ youtubeId: null, /** @type {YoutubeCookies} */ youtubeCookies: { - accessToken: '', + accessToken: null, authAccount: '', refreshToken: 'null', },