Skip to content

Instantly share code, notes, and snippets.

@agamm
Last active February 26, 2024 08:56
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agamm/ea65f0510e65e67f65eca189d55ee32b to your computer and use it in GitHub Desktop.
Save agamm/ea65f0510e65e67f65eca189d55ee32b to your computer and use it in GitHub Desktop.
Show all resolved comments in a Github Pull Request

Run this in the console:

document.querySelectorAll('span.Details-content--closed').forEach((e)=>{e.click()})

From the creator of: unzip.dev 🚀

@maelvls
Copy link

maelvls commented Jul 1, 2021

For future reference, to "Unfold Reolved Comments" on Chrome:

  1. Add a bookmark
  2. In the URL field, copy-paste this:
    javascript:document.querySelectorAll('.js-resolvable-timeline-thread-container').forEach(e => { e.setAttribute('open', '') })()

If you would like to also "Load items" (source):

  1. Add a bookmark
  2. In the URL field, copy-paste this:
    javascript:function loadAllCommentsAndShowResolved(){let e=!1;Array.from(document.querySelectorAll("button, .btn-link.Details-content--closed")).forEach(o=>{o.classList.contains("ajax-pagination-btn")?o.hasAttribute("disabled")||"Load more…"!==o.innerText?o.hasAttribute("disabled")&&"Loading…"===o.innerText?(console.log("waiting",o),e=!0):console.log("unrecognized 'Load more' button",o):(console.log("found",o),e=!0,o.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))):o.classList.contains("Details-content--closed")&&"Show resolved"===o.innerText&&o.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}),e?setTimeout(loadAllCommentsAndShowResolved,200):console.log("all comments loaded")}loadAllCommentsAndShowResolved();

@spidiweb
Copy link

spidiweb commented Nov 17, 2021

All of the above will not work when we have too many conversations.

For me, there was a PR having more than 120 comments, so first I had to get all the hidden items loaded, then expension of resolved comments needs to be done. For the same, I have written below script:

let isActiveExpension = false;
let interval = setInterval(()=>{
isActiveExpension = true;
const elements = document.querySelectorAll("button[type=submit].ajax-pagination-btn"); if(elements.length === 0){
    console.log("All sections are expanded");
    clearInterval(interval);
    isActiveExpension = false;
    expandSubSections();
    setTimeout(expandSubSections, 10000)
}
else{
    console.log("Expanding sections");
    elements[0].click();
    expandSubSections();
}
},10000);

function expandSubSections()
{
    console.log("Expanding sub-sections");
    document.querySelectorAll(".btn-link.text-gray.f6.Details-content--closed").forEach((element)=>{element.click();});
}

However, above too does not works as it seems like github is using some optimizations to load limited HTML at a time to keep page light.

So, to resolve this issue, we may have to add some scroll script too to above one, which I'll do after some time.

Note: This script worked on my company's enterprise github, I haven't tried the same on public git.

@ardfar68
Copy link

to Unfold all Resolved conversation I use below and it works fine:
javascript:document.querySelectorAll('.js-resolvable-timeline-thread-container').forEach(e => { e.setAttribute('open', '') })()

What code should I use to Fold them again ?
thanks

@kemalizing
Copy link

kemalizing commented May 12, 2022

What code should I use to Fold them again ? thanks

just refresh?

@amonsosanz
Copy link

You can use Alt + Click on one comment to fold/unfold them all.

@jeanjackson-lp
Copy link

^ What @amonsosanz said worked for me. On Mac, that would be option + click

@mccataldo
Copy link

Thanks, @amonsosanz! 🎉

@qmcree
Copy link

qmcree commented Jul 24, 2023

Whoa, game changer. On Mac Chrome, Option + Click on one comment's "Show resolved" link shows all for me. Thanks @amonsosanz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment