diff --git a/YoutubeConfig.json b/YoutubeConfig.json index fc09719ac558cc3e53dbe6059e17e545223d921a..fa3ac8471f2f2080816d6184af43eee83f7720d2 100644 --- a/YoutubeConfig.json +++ b/YoutubeConfig.json @@ -7,7 +7,7 @@ "sourceUrl": "https://plugins.grayjay.app/Youtube/YoutubeConfig.json", "repositoryUrl": "https://futo.org", "scriptUrl": "./YoutubeScript.js", - "version": 147, + "version": 148, "iconUrl": "./youtube.png", "id": "35ae969a-a7db-11ed-afa1-0242ac120002", diff --git a/YoutubeScript.js b/YoutubeScript.js index 7cc655756fdd940ec51a82e6da18ec6548bf3670..df1a02d643956797617c8639da798b870b3d148f 100644 --- a/YoutubeScript.js +++ b/YoutubeScript.js @@ -2384,6 +2384,30 @@ function extractVideoPage_VideoDetails(initialData, initialPlayerData, contextDa } } + }, + segmentedLikeDislikeButtonViewModel(renderer) { + if(IS_TESTING) + console.log("Found new likes model:", renderer); + let likeButtonViewModel = renderer?.likeButtonViewModel; + if(likeButtonViewModel.likeButtonViewModel) //Youtube double nested, not sure if a bug on their end which may be removed + likeButtonViewModel = likeButtonViewModel.likeButtonViewModel; + let toggleButtonViewModel = likeButtonViewModel?.toggleButtonViewModel; + if(toggleButtonViewModel.toggleButtonViewModel) //Youtube double nested, not sure if a bug on their end which may be removed + toggleButtonViewModel = toggleButtonViewModel.toggleButtonViewModel; + + const buttonViewModel = toggleButtonViewModel?.defaultButtonViewModel?.buttonViewModel; + if(buttonViewModel?.title) { + let num = parseInt(buttonViewModel.title); + if(!isNaN(num)) + video.rating = new RatingLikes(num); + num = extractHumanNumber_Integer(buttonViewModel.title); + if(!isNaN(num) && num >= 0) + video.rating = new RatingLikes(num); + else + throw new ScriptException("Found unknown likes model, please report to dev:\n" + JSON.stringify(buttonViewModel.title)); + } + else + log("UNKNOWN LIKES MODEL:\n" + JSON.stringify(renderer, null, " ")); } }); });