Created
April 21, 2020 14:01
-
-
Save justinpersaud/6993832c26c2359fba1ac6245ddb77c4 to your computer and use it in GitHub Desktop.
Expand all hidden github comments on issues
This file contains 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
function loadAllComments() { | |
let needRescheduling = false; | |
const buttons = Array.from(document.querySelectorAll('button')); | |
buttons.forEach((button) => { | |
if (button.classList.contains('ajax-pagination-btn')) { | |
if(!button.hasAttribute('disabled') && button.innerText === 'Load more…') { | |
console.log("found", button); | |
needRescheduling = true; | |
button.dispatchEvent(new MouseEvent('click', { | |
bubbles: true, | |
cancelable: true | |
})); | |
} | |
else if(button.hasAttribute('disabled') && button.innerText === 'Loading…') { | |
console.log("waiting", button); | |
needRescheduling = true; | |
} | |
else { | |
console.log("unrecognized 'Load more' button", button); | |
} | |
} | |
}); | |
if (needRescheduling) { | |
setTimeout(loadAllComments, 200) | |
} | |
else { | |
console.log("all comments loaded"); | |
} | |
} | |
loadAllComments(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment