Way to print a combined list of questions from multiple leetcode lists.

If you maintain a list of questions using the leetcode list feature and end up adding a question to multiple lists and want to know how many unique questions you have listed, you have to the right thread. I wrote a simple javascript code which uses leetcode graphQL Query and logs a merged/combined list of questions from all lists.
To run this code. Open leetcode in the browser and then go to the browser console and enter the following javascript code.

function printQuestions(data) {
    let questions = {};
    let allLists = data.data.favoritesLists.allFavorites
    for(let list of allLists) {
        for(let question of list.questions) {
            questions[question.questionId] = question.title; 
        }
    }
    console.log(questions);
    console.log(Object.keys(questions).length);   
}
fetch('https://leetcode.com/graphql?query=query%20favoritesList%20{favoritesLists%20{%20%20allFavorites%20{%20%20%20%20idHash%20%20%20%20name%20%20%20%20description%20%20%20%20viewCount%20%20%20%20creator%20%20%20%20isWatched%20%20%20%20isPublicFavorite%20%20%20%20questions%20{%20%20%20%20%20%20questionId%20%20%20%20%20%20status%20%20%20%20%20%20title%20%20%20%20%20%20titleSlug%20%20%20%20%20%20__typename%20%20%20%20}%20%20%20%20__typename%20%20}%20%20watchedFavorites%20{%20%20%20%20idHash%20%20%20%20name%20%20%20%20description%20%20%20%20viewCount%20%20%20%20creator%20%20%20%20isWatched%20%20%20%20isPublicFavorite%20%20%20%20questions%20{%20%20%20%20%20%20questionId%20%20%20%20%20%20status%20%20%20%20%20%20title%20%20%20%20%20%20titleSlug%20%20%20%20%20%20__typename%20%20%20%20}%20%20%20%20__typename%20%20}%20%20__typename}userStatus%20{%20%20username%20%20__typename}}')
  .then(response => response.json())
  .then(data => printQuestions(data));
Comments (0)