Added initial code to clear problem difficulties#383
Open
VolodymyrSemenov wants to merge 1 commit intomainfrom
Open
Added initial code to clear problem difficulties#383VolodymyrSemenov wants to merge 1 commit intomainfrom
VolodymyrSemenov wants to merge 1 commit intomainfrom
Conversation
Contributor
Author
|
I also couldn't figure out how to run prettier(or the js equivalent) on the file. |
miorel
reviewed
Aug 25, 2024
| function clearIndividualProblemDifficulty() { | ||
| let difficulty_elem = document.getElementsByClassName("dark:text-difficulty-hard")[0] || document.getElementsByClassName("dark:text-difficulty-easy")[0] || document.getElementsByClassName("dark:text-difficulty-medium")[0]; | ||
| difficulty_elem.innerText = difficulty_conversion[difficulty_elem.innerText]; | ||
| difficulty_elem.setAttribute("class", "relative inline-flex items-center justify-center text-caption px-2 py-1 gap-1 rounded-full bg-fill-secondary text-difficulty-easy dark:text-difficulty-easy"); |
Contributor
There was a problem hiding this comment.
I'm assuming you just want to modify one of the classes, not all of them. If so, try this API instead: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
|
|
||
| const problem_difficulty_classes = ["text-olive dark:text-dark-olive", "text-yellow dark:text-dark-yellow", "text-pink dark:text-dark-pink"]; | ||
|
|
||
| let problemClearingInterval = setInterval(clearProblemSetDifficulties, 100); // Needed because we have to wait for leetcode to request problems (nonblockingly) |
Contributor
There was a problem hiding this comment.
Seems like a reasonable starting point but I wonder if we could intercept the API data and rewrite the difficulties there... Running a script 10 times a second probably isn't great for perf.
Comment on lines
+7
to
+9
| 'Brutal': 'Brutal', // In order to keep it from going to undefined if run too many times | ||
| 'Excruciating': 'Excruciating', | ||
| 'Soul-Crushing': 'Soul-Crushing' |
Contributor
There was a problem hiding this comment.
Could we just not change it if it's not in the map?
miorel
reviewed
Aug 25, 2024
elimanzo
reviewed
Aug 26, 2024
Contributor
elimanzo
left a comment
There was a problem hiding this comment.
This is really cool, good job @VolodymyrSemenov 🔥 !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Created 2 functions to clear problem difficulties on problemset page and individual problem pages.
Issues:
clearProblemSetDifficulties needs to wait for the problems to load. Currently using polling, but maybe a better way?
clearProblemSetDifficulties needs to run several times to work. I added code to let it only run once, but leetcode rewrites the problems so the function has to run multiple times.
Code to run clearIndividualProblemDifficulty isn't setup.