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

puppet-king-of-time

v1.2.0

Published

Have KING OF TIME (www.kingtime.jp) like a puppet on a string

Downloads

11

Readme

puppet-king-of-time

Have KING OF TIME like a puppet on a string

Features

Powered by Headless Chrome, puppet-king-of-time automatically logs in to KING OF TIME's recorder with your ID/password and allows you to programatically clock in/out for you.

Getting Started

Installation

npm i puppet-king-of-time

Note: puppet-king-of-time contains Puppeteer. During installation, it automatically downloads a recent version of Chromium. To skip the download, see Environment variables.

Usage

import PuppetKOT from "puppet-king-of-time";

(async () => {
  // Launch the puppet-king-of-time with your ID/password
  const puppetKOT = await PuppetKOT.launch({ id: "Your ID", password: "Your password" });
  // Clock in
  await puppetKOT.clockIn();
  // Clock out
  await puppetKOT.clockOut();
  // Close the puppet-king-of-time
  await puppetKOT.close();
})();

API reference

Table of Contents

class: PuppetKOT

PuppetKOT provides methods to launch a Chromium instance.

import PuppetKOT from "puppet-king-of-time";

(async () => {
  const puppetKOT = await PuppetKOT.launch({ id: "Your ID", password: "Your password" });
  await puppetKOT.clockIn();
  await puppetKOT.close();
})();

PuppetKOT.launch([options])

  • options <Object>
    • loginUrl <string> Login url to KING OF TIME's recorder, default to https://s2.kingtime.jp/independent/recorder/personal/.
    • idSelector <string> Login ID input's selector, default to #id.
    • passwordSelector <string> Login password input's selector, default to #password.
    • loginSelector <string> Login button's selector, default to .btn-control-message.
    • clockInSelector <string> Clock in button's selector, default to .record-clock-in.
    • clockOutSelector <string> Clock out button's selector, default to .record-clock-out.
    • notificationSelector <string> Notification selector, default to #notification_wrapper[style="display: none;"].
    • loginNotificationContent <string> Notification content after clock in, default to データを取得しました.
    • clockInNotificationContent <string> Notification content after clock in, default to 出勤が完了しました.
    • clockOutNotificationContent <string> Notification content after clock out, default to 退勤が完了しました.
    • timeout <number> Maximum wait time in milliseconds, default to 10000,
    • id <string> required
    • password <string> required
  • returns: <Promise<PuppetKOT>> Promise which resolves to PuppetKOT instance.

The method launches a Chromium instance. The following options are passed to puppeteer.launch().

ignoreHTTPSErrors, headless, executablePath, slowMo, args, ignoreDefaultArgs, handleSIGINT, handleSIGTERM, handleSIGHUP, dumpio, userDataDir, env, devtools

puppetKOT.clockIn()

  • returns: <Promise> Promise resolved when clock in button is clicked.

puppetKOT.clockOut()

  • returns: <Promise> Promise resolved when clock out button is clicked.

puppetKOT.close()

  • returns: <Promise> Promise resolved when the browser is closed.

Debugging tips

Launch options

PuppetKOT.launch()'s options are passed to puppeteer.launch(). It may be useful to set the headless and slowMo options so that you can see what is going on.

PuppetKOT.launch({ id: "Your ID", password: "Your password", headless: false, slowMo: 10 });

Launch in Docker

Build the container with this Dockerfile:

docker build -t puppet-king-of-time-linux .

Run the container by passing node -e "<yourscript.js content as a string>" as the command:

docker run -i --rm --cap-add=SYS_ADMIN \
  --name puppet-king-of-time puppet-king-of-time-linux \
  node -e "`cat yourscript.js`"