New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Add "sync all solved problems" button #77
Comments
@JasperSui see #15 const getAllSolvedProblems = () => {
const LEETCODE_API_URL = 'https://leetcode.com/api/problems/algorithms';
const LEETCODE_PROBLEM_URL_PREFIX = "https://leetcode.com/problems/";
const xhr = new XMLHttpRequest();
/* Gather data */
var problems_data = [];
xhr.addEventListener('readystatechange', function () {
if (xhr.readyState === 4) {
let problems = JSON.parse(xhr.responseText)["stat_status_pairs"];
problems.forEach(problem => {
if(problem["status"] && problem["status"] === "ac")
{
var stat = problem["stat"];
let problem_data = {"title" : stat["question__title"], "url" : LEETCODE_PROBLEM_URL_PREFIX + stat["question__title_slug"], "id" : stat["frontend_question_id"]};
problems_data.push(problem_data);
}
});
console.log(problems_data[0]);
}
});
xhr.open('POST', LEETCODE_API_URL, true);
xhr.send();
}; The problem lies in getting the actual code for an existing problem. There's no public facing leetcode api that does this. This means that LeetHub would need to run N requests (N = number of solved leetcode problems that aren't already on LeetHub) causing the browser to be very slow. Since we can take care of it asynchronously, the process can very easily break down if you close the page (say welcome.html) that performs this action. Sure we can store this, but the main drawback that I see is that this will be very slow. I personally think this is a great idea (see link above for past discussion) but I can't come up with a more time efficient approach. If you (or anyone else) has a better way of doing it, please submit a PR! |
@QasimWani I totally agree with your opinion that sync all problems one by one will facing some unexpected errors (closing welcome page, network issue, e.g.), I'll try to think about a better way after fully understanding this project. Thank you again about explaining the reason why you chose not to do this and having an open mind! Have a great day! |
#77 |
there is a pre-existing repo on GitHub which can sync all previous submissions please take a look at that repo's code to get some idea and add a new feature for adding previously solved problem check this https://github.com/joshcai/leetcode-sync |
All i just need is the go ahead |
Sure thing. Plz join our discord (see readMe) and we can chat over there for updates |
😎😎😎😎 |
Hi @QasimWani / Someone, How to use this. Can someone please explain. I want push the old submission codes to github with same dates(if i do manully its pushing with today date not the date which i submitted the leetcode question). Thanks in advance! |
I think it can be a feasible if we check if number of solved problems are less than let say 50 , then only this feature will work |
Hi Qasim Wani,
It's a very useful project, and how about having a "sync all solved problems" button to sync all solved problems on LeetCode but not in the specific repository?
It will be helpful for those who used to solve problems on LeetCode but are new to your extension.
Thank you for your contribution, I really appreciate it!
The text was updated successfully, but these errors were encountered: