bpceee/oldest

Doesn't work

lackovic opened this issue ยท 7 comments

Steps to reproduce

  1. drag the bookmarklet onto your bookmark bar
  2. open your repository commits page
  3. click on the bookmarked link

Expected

The page reloads and shows the oldest commit.

Actual

Nothing happens.

What am I missing?

Using Chrome Version 79.0.3945.79 (Official Build).

I don't think the domain is registered anymore

pzij commented

Same in my case, the console indicates :

VM85:1 Uncaught (in promise) TypeError: Cannot read property 'innerText' of null
at :1:308

It seems that the bookmarklet needs to be updated.

pzij commented
(([_, repo, branch='master']) => {
  fetch(`https://github.com/${repo}/tree/${branch}`)
    .then(res => res.text())
    .then(res => {
      let mainDocument = new DOMParser().parseFromString(res, 'text/html');
      let commitCount = mainDocument.evaluate('//span[@class="d-none d-sm-inline"]//strong', mainDocument.body).iterateNext().innerText;
      commitCount = Number(commitCount.trim().replace(',', ''));
      let commitId = mainDocument.evaluate('//*[@class="f6 link-gray text-mono ml-2 d-none d-lg-inline"]', mainDocument.body).iterateNext().getAttribute("href").split('/').pop();
      let url = `https://github.com/${repo}/commits/${branch}?after=${commitId}+${commitCount-10}`;
      window.location = url;
  })
})(window.location.pathname.match(/\/([^\/]+\/[^\/]+)(?:\/(?:tree|commits)\/(.+))?/));

I made some modifications with @bpceee 's code, this works fine with the current version of github, go try it.

Oh, shoot. Sorry guys. Being swamped in work-related Github notifications recently.. Thanks for using this tiny little tool.
@swanf Much appreciated if you could open a PR on this?

pzij commented

@bpceee Sure, I just did :)

Should be work now. But need to drag a new bookmark from https://bpceee.github.io/oldest/ again...
Kudos to @swanf