Skip to content

Instantly share code, notes, and snippets.

@samal-rasmussen
Last active March 14, 2023 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samal-rasmussen/fb1563001fc9c2989c23e7debf4acdc5 to your computer and use it in GitHub Desktop.
Save samal-rasmussen/fb1563001fc9c2989c23e7debf4acdc5 to your computer and use it in GitHub Desktop.
npmtrends download flooding sanitisation

In the .js bundle on the npmtrends site I found the success handler for fetch requests.

It looks like this:

  e.fetch = function(t, e) {
      ...
      return this.retryer = new a.m4({
          fn: y.fetchFn,
          abort: null == h || null == (o = h.abort) ? void 0 : o.bind(h),
          onSuccess: function(t) {
              s.setData(t),

I put a breakpoint of the setData line and executed this in the terminal:

t.map((tt) => {
    tt.downloads = tt.downloads.map((d) => {
        d.downloads = d.downloads > 155911 ? 70000 : d.downloads;
        return d;
    })
    return tt;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment