Skip to content

Commit

Permalink
Merge pull request #17 from dipta007/loader_v2
Browse files Browse the repository at this point in the history
Loader v2
  • Loading branch information
raphaelheinz authored Jan 8, 2024
2 parents c186104 + 685e268 commit d7f813c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,10 @@ LeetCodeV2.prototype.insertToAnchorElement = function (elem) {
return;
}

if (checkElem(document.getElementsByClassName('ml-auto flex items-center space-x-4'))) {
const target = document.getElementsByClassName('ml-auto flex items-center space-x-4')[0];
if (checkElem(document.getElementsByClassName('ml-auto'))) {
const target = document.getElementsByClassName('ml-auto')[0];
elem.className = 'runcode-wrapper__8rXm';
if (target.childNodes.length > 0) target.childNodes[0].prepend(elem);
if (target.childNodes.length > 0) target.prepend(elem);
}
};
LeetCodeV2.prototype.markUploaded = function () {
Expand Down Expand Up @@ -945,13 +945,16 @@ chrome.storage.local.get('isSync', data => {

const loader = (leetCode) => {
let iterations = 0;
// start upload indicator here
leetCode.startSpinner();
const intervalId = setInterval(async () => {
try {
const isSuccessfulSubmission = leetCode.getSuccessStateAndUpdate();
if (!isSuccessfulSubmission) {
iterations++;
if (iterations > 9) {
clearInterval(intervalId); // poll for max 10 attempts (10 seconds)
leetCode.markUploadFailed();
}
return;
}
Expand Down Expand Up @@ -979,9 +982,6 @@ const loader = (leetCode) => {
throw new Error('Could not find language');
}

// start upload indicator here
leetCode.startSpinner();

/* Upload README */
const updateReadMe = await chrome.storage.local.get('stats').then(({ stats }) => {
const shaExists = stats?.shas?.[problemName]?.['README.md'] !== undefined;
Expand Down

0 comments on commit d7f813c

Please sign in to comment.