Add-Link-To-NPM-Devtool-Tech

add an link to npm devtool tech in npm package page

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name                Add-Link-To-NPM-Devtool-Tech
// @name:zh-CN          给npm包添加一个到NPM-Devtool-Tech的链接
// @namespace           http://tampermonkey.net/
// @version             0.0.1
// @description         add an link to npm devtool tech in npm package page
// @description:zh-CN   add an link to npm devtool tech in npm package page
// @author              kkopite
// @match               https://www.npmjs.com/package/*
// @icon                https://www.google.com/s2/favicons?sz=64&domain=www.npmjs.com
// @grant               none
// ==/UserScript==

(function () {
  'use strict'

  const h3s = document.querySelectorAll('h3')
  let h3 = [...h3s].find(h => h.innerText === 'Install')

  const link = document.createElement('div')
  const url = `https://npm.devtool.tech/${window.location.pathname.split('/')[2]}`
  link.innerHTML = `
  <div class="dib w-50 bb b--black-10 pr2 w-100">
    <h3 id="devtoolTech" class="f5 mt2 pt2 mb0">DevTool Tech</h3>
    <p class="_40aff104 fw6 mb3 mt2 truncate black-80 f5">
      <a aria-labelledby="DevTool Tech" class="b2812e30 f2874b88 fw6 mb3 mt2 truncate black-80 f4 link" href="${url}" target="_blank" rel="noopener noreferrer nofollow">
      <span>${url}</span>
      </a>
    </p>
  </div>
  `

  h3.parentNode.insertBefore(link, h3.nextSibling.nextSibling)

})()