Tarball viewer

View content of tarballs without download them.

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 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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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        Tarball viewer
// @namespace   https://gera2ld.space/
// @description View content of tarballs without download them.
// @match       *://www.npmjs.com/package/*
// @version     0.2.0
// @author      Gerald <[email protected]>
// @require     https://cdn.jsdelivr.net/combine/npm/@violentmonkey/dom@2,npm/@violentmonkey/[email protected]
// @grant       GM_openInTab
// @grant       GM_registerMenuCommand
// ==/UserScript==

(function () {
'use strict';

async function main() {
  const matches = window.location.pathname.match(/^\/package\/(.*?)(?:\/v\/([a-z0-9.-]+))?$/);
  if (!matches) {
    VM.showToast('Package not found');
    return;
  }
  const [, pkgName, version] = matches;
  const name = [pkgName, version].filter(Boolean).join('@');
  const qs = new URLSearchParams({
    r: `npm:${name}`
  });
  GM_openInTab(`https://webfs.gera2ld.space/#${qs}`);
}
GM_registerMenuCommand('Explore tarball', main);

})();