Have KING OF TIME (www.kingtime.jp) like a puppet on a string
MIT License
Have KING OF TIME like a puppet on a string
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.
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.
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();
})();
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();
})();
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
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.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 });
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`"