Forked from justinpersaud/gist:6993832c26c2359fba1ac6245ddb77c4
Created
July 16, 2020 00:28
-
-
Save rafecolton/bc8548e55cf50b9864ae720534458f76 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