scripts/leetcode.js
/* Parser function for the question and tags */
Parser function for the question and tags
Parser function for the question and tags
function parseQuestion() {
  var questionUrl = window.location.href
  if(questionUrl.endsWith('/submissions/')){
    questionUrl = questionUrl.substring(0, questionUrl.lastIndexOf("/submissions/")+1)
  }
  const questionElem = document.getElementsByClassName(
    'content__u3I1 question-content__JfgR',
  );
  const questionDescriptionElem = document.getElementsByClassName("question-description__3U1T");
  if (checkElem(questionElem)) {
    const qbody = questionElem[0].innerHTML;
    let qtitle = document.getElementsByClassName('css-v3d350');
    if (checkElem(qtitle)) {
      qtitle = qtitle[0].innerHTML;
    } else {
      qtitle = 'unknown-problem';
    }
    const isHard = document.getElementsByClassName('css-t42afm');
    const isMedium = document.getElementsByClassName('css-dcmtd5');
    const isEasy = document.getElementsByClassName('css-14oi08n');
    if (checkElem(isEasy)) {
      difficulty = 'Easy';
    } else if (checkElem(isMedium)) {
      difficulty = 'Medium';
    } else if (checkElem(isHard)) {
      difficulty = 'Hard';
    }
    const markdown = `<h2><a href="${questionUrl}">${qtitle}</a></h2><h3>${difficulty}</h3><hr>${qbody}`;
    return markdown;
  } else if(checkElem(questionDescriptionElem)){
    let questionTitle = document.getElementsByClassName("question-title");
    if(checkElem(questionTitle)){
      questionTitle = questionTitle[0].innerText;
    } else{
      questionTitle = "unknown-problem";
    }
    const questionBody = questionDescriptionElem[0].innerHTML;
    const markdown = `<h2>${questionTitle}</h2><hr>${questionBody}`;
    return markdown;
  }
  return null;
}
function parseQuestion ( ) { var questionUrl = window . location . href if ( questionUrl . endsWith ( '/submissions/' ) ) { questionUrl = questionUrl . substring ( 0 , questionUrl . lastIndexOf ( "/submissions/" ) + 1 ) } const questionElem = document . getElementsByClassName ( 'content__u3I1 question-content__JfgR' , ) ; const questionDescriptionElem = document . getElementsByClassName ( "question-description__3U1T" ) ; if ( checkElem ( questionElem ) ) { const qbody = questionElem [ 0 ] . innerHTML ; let qtitle = document . getElementsByClassName ( 'css-v3d350' ) ; if ( checkElem ( qtitle ) ) { qtitle = qtitle [ 0 ] . innerHTML ; } else { qtitle = 'unknown-problem' ; } const isHard = document . getElementsByClassName ( 'css-t42afm' ) ; const isMedium = document . getElementsByClassName ( 'css-dcmtd5' ) ; const isEasy = document . getElementsByClassName ( 'css-14oi08n' ) ; if ( checkElem ( isEasy ) ) { difficulty = 'Easy' ; } else if ( checkElem ( isMedium ) ) { difficulty = 'Medium' ; } else if ( checkElem ( isHard ) ) { difficulty = 'Hard' ; } const markdown = ` ${ questionUrl } ${ qtitle } ${ difficulty } ${ qbody } ` ; return markdown ; } else if ( checkElem ( questionDescriptionElem ) ) { let questionTitle = document . getElementsByClassName ( "question-title" ) ; if ( checkElem ( questionTitle ) ) { questionTitle = questionTitle [ 0 ] . innerText ; } else { questionTitle = "unknown-problem" ; } const questionBody = questionDescriptionElem [ 0 ] . innerHTML ; const markdown = ` ${ questionTitle } ${ questionBody } ` ; return markdown ; } return null ; }
Parser function for the question and tags
Parser function for the question and tags
// Problem title. // Problem difficulty, each problem difficulty has its own class. // Final formatting of the contents of the README for each problem