open-in-initcommit

Find the initial commit of the repository

2024-05-21 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name open-in-initcommit
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.1
  5. // @description Find the initial commit of the repository
  6. // @author yuyinws
  7. // @match https://github.com/**
  8. // @icon https://initcommit.info/logo.svg
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict'
  14.  
  15. function createButton() {
  16. const repoInfo = window.location.pathname.split('/').slice(1, 3).join('/')
  17. const a = document.createElement('a')
  18. a.href = `https://initcommit.info/${repoInfo}`
  19. a.classList.add('btn')
  20. a.classList.add('btn-sm')
  21. a.textContent = 'Init Commit'
  22. a.target = '_blank'
  23.  
  24. return a
  25. }
  26.  
  27. function run() {
  28. const repoActions = document.querySelector('#repository-details-container ul')
  29. if (repoActions) {
  30. const li = document.createElement('li')
  31. li.appendChild(createButton())
  32. repoActions.prepend(li)
  33. }
  34. }
  35.  
  36. run()
  37.  
  38. document.addEventListener('pjax:end', () => run())
  39. document.addEventListener('turbo:render', () => run())
  40. })()