github-npm-deps

Link dependencies from package.json to respective GitHub homepages

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         github-npm-deps
// @version      0.1.0
// @description  Link dependencies from package.json to respective GitHub homepages
// @license      MIT
// @namespace    https://github.com/eush77/github-npm-deps
// @supportURL   https://github.com/eush77/github-npm-deps
// @include      https://github.com/*
// ==/UserScript==


init();
document.addEventListener('click', function () {
  setTimeout(init, 500);
});


function init () {
  if (!/\/package\.json$/.test(location.pathname)) {
    return;
  }

  var trs = document.querySelectorAll('.blob-wrapper tr');

  [].reduce.call(trs, function (inDependencies, tr) {
    var row = tr.querySelector('.blob-code');
    if (row.textContent.indexOf('}') >= 0) {
      return false;
    }

    var pls = row.querySelectorAll('.pl-s');

    if (pls.length == 1) {
      pls = pls[0];
      if (pls.nextSibling &&
          pls.nextSibling.textContent.replace(/\s/g, '') == ':{' &&
          /^"\w*[dD]ependencies"$/.test(pls.textContent)) {
        return true;
      }
    }
    else if (inDependencies && pls.length == 2) {
      var name = pls[0].textContent;
      var link = document.createElement('a');
      link.href = 'http://ghub.io/' + name.slice(1, -1);
      link.textContent = name;
      pls[0].parentNode.replaceChild(link, pls[0]);
    }

    return inDependencies;
  }, false);
}