npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stack-fanatic

v0.0.1

Published

A node module that uses Google's Puppeteer library to visit your Stack Overflow profile and check the progress of the badge you are currently tracking.

Downloads

7

Readme

Stack Fanatic

npm package version Travis build status npm package downloads code style license

A node module that uses Google's Puppeteer library to visit your Stack Overflow profile and check the progress of the badge you are currently tracking.

Installation

npm install stack-fanatic

Usage

Options

The following options can be passed to any functions (however none of them are required):

  • debug - A boolean stating wether or not debugging information should be displayed in the console (Default: false)

  • loginEmail - A string containing the email address asssociated with the StackOverflow account that you would like to log in to.

  • loginPassword - A string containing the password for the StackOverflow account that you would like to log in to.

  • puppeteerOpts - An object containing any options you wish to pass to the puppeteer.launch() function. (Sets the user agent to Google Chrome and the user data directory to ./userData by default)

  • site - A string containing the URL for the Stack Exchange site that you would like to pull badge info from. Should include the protocol at the beginning and no trailing slash. (Default: https://stackoverflow.com)

check(options)

Visits your StackOverflow profile page and returns a promise that resolves with information about your tracked badge.

Note: The login function will automatically be ran if loginEmail and loginPassword are passed as options and you are not currently logged in.

const stackFanatic = require('stack-fanatic')

stackFanatic
  .check({
    loginEmail: '[email protected]',
    loginPassword: 'password1234',
    site: 'https://stackoverflow.com'
  })
  .then(res => {
    console.log('Badge Name:', res.badge)
    console.log('Badge Type:', res.type)
    console.log('Current Progress:', res.now)
    console.log('Percent Completed:', res.percent)
  })
  .catch(err => {
    console.log(err.message)
  })

Example Response

{
  badge: 'Fanatic',
  max: 100,
  min: 0,
  now: 20,
  percent: 20,
  profile: 'https://stackoverflow.com/users/5463842/kodie-grantham',
  type: 'Gold'
}

login(options)

Logs into a StackOverflow account and returns a promise that resolves with true or false depending on if the login was successful or not.

Note: After you are logged in, your session info will be saved in ./userData so that you can run the check function without having to log in again.

const stackFanatic = require('stack-fanatic')

stackFanatic
  .login({
    loginEmail: '[email protected]',
    loginPassword: 'password1234'
  })
  .then(loggedIn => {
    if (loggedIn) {
      console.log('Yay! You are logged in! :D')
    } else {
      console.log('Aw dang! You are not logged in. :(')
    }
  })
  .catch(err => {
    console.log(err.message)
  })

Tips/Tricks

Check badge progress without logging in

Just set site to the URL of your Stack Overflow profile and make sure that you have ?tab=topactivity at the end of it.

While you're at it, set Puppeteer's userDataDir option to false so that no session data or cache is saved.

stackFanatic
  .check({
    site: 'https://stackoverflow.com/users/5463842/kodie-grantham?tab=topactivity',
    puppeteerOpts: {
      userDataDir: false
    }
  })

Related

License

MIT. See the LICENSE file for more info.