open-in-initcommit

Find the initial commit of the repository

  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. // @license MIT
  8. // @match https://github.com/**
  9. // @icon https://initcommit.info/logo.svg
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict'
  15.  
  16. function createButton() {
  17. const repoInfo = window.location.pathname.split('/').slice(1, 3).join('/')
  18. const a = document.createElement('a')
  19. a.href = `https://initcommit.info/${repoInfo}`
  20. a.classList.add('btn')
  21. a.classList.add('btn-sm')
  22. a.textContent = 'Init Commit'
  23. a.target = '_blank'
  24.  
  25. return a
  26. }
  27.  
  28. function run() {
  29. const repoActions = document.querySelector('#repository-details-container ul')
  30. if (repoActions) {
  31. const li = document.createElement('li')
  32. li.appendChild(createButton())
  33. repoActions.prepend(li)
  34. }
  35. }
  36.  
  37. run()
  38.  
  39. document.addEventListener('pjax:end', () => run())
  40. document.addEventListener('turbo:render', () => run())
  41. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址