QasimWani / LeetHub

Automatically sync your leetcode solutions to your github account - top 5 trending GitHub repository
https://chrome.google.com/webstore/detail/leethub/aciombdipochlnkbpcbgdpjffcfdbggi
MIT License
3.96k stars 1.39k forks source link

Out of curiosity.. Will the dynamic css class names change after leetcode re-deployment? #63

Closed madhur closed 3 years ago

madhur commented 3 years ago

Great work on this project. 👍

Might not be an issue, but I was looking at the source code and found references to dynamic css class names which seems to be generated by React Framework. For example:

// Problem difficulty, each problem difficulty has its own class.

  const isHard = document.getElementsByClassName('css-t42afm');
  const isMedium = document.getElementsByClassName('css-dcmtd5');
  const isEasy = document.getElementsByClassName('css-14oi08n');

My guess is that these will change whenever leetcode does a rebuild of their webpack bundle.

I think this might need to be handled in a different manner. What do you think?

rbajaj1997 commented 3 years ago

My thoughts too. I also noticed the use of data-cy attributes in multiple elements (typically used when cypress is used for testing). We might have to use css selectors in a more robust way. Like for example:

  const questionType = document.querySelector('[data-cy="question-title"] + div div');
  console.log(questionType.innerText);
  // output will be Hard, Medium or Easy
QasimWani commented 3 years ago

interesting @madhur. i've never used react so i'm not familiar with dynamic css. @rbajaj1997 could you open a PR to replace current class names? i'll merge it later.

rbajaj1997 commented 3 years ago

@QasimWani I may not find time to implement it. Although, I can help in getting the generic CSS selectors. Btw, amazing idea and great work on this project!

QasimWani commented 3 years ago

sure. closing for now.