github-go-deepwiki

github仓库跳转到deepwiki

Από την 26/04/2025. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         github-go-deepwiki
// @namespace
// @version      0.2
// @description  github仓库跳转到deepwiki
// @source       https://github.com/gxr404/go-deepwiki
// @author       gxr404
// @match        https://github.com/*
// @grant        none
// @namespace 
// ==/UserScript==
(function() {
  'use strict';

  const bodyEl = document.querySelector('body')
  if (bodyEl) {
      watchDom(bodyEl, main)
      main()
  }
})();

function watchDom(dom, callback) {
  const observer = new MutationObserver(() => {
    callback()
  })
  observer.observe(dom, {
    childList: true,
    subtree: true,
  })
}

function main() {
  if (document.getElementById('go-deepwiki')) return
  const repoBtnContainer = document.getElementById('repository-details-container')
  if (!repoBtnContainer) return
  const btnList = repoBtnContainer.querySelector('ul')
  if (!btnList) return
  btnList.appendChild(createGoDeepWikiDOM())
}

function createGoDeepWikiDOM() {
  const li = document.createElement('li')
  const repName = location.pathname.split('/').filter(Boolean).slice(0,2).join('/')
  const deepWikiUrl = `https://deepwiki.com/${repName}`
  li.innerHTML = `
<li id="go-deepwiki">
  <div data-view-component="true" class="BtnGroup d-flex">
      <a href="${deepWikiUrl}"
        rel="nofollow"
        aria-label="Go DeepDeepwikiWiki"
        data-view-component="true"
        class="tooltipped tooltipped-sw btn-sm btn">
        Go Deepwiki
      </a>
  </div>
</li>
`
  return li
}