← Back to list

The JavaScript Automation Stack That Saved My Sanity

How I Went from Manual Chores to Auto-Everything Using Node.js, Puppeteer, and a Bit of Madness

Maximilian Oliver · 2025-07-03 17:36 · 0 claps · 4.2 min read paywalled
#javascript-tricks #automation #javascrıpt #sanity #programming
Open on Medium ↗
Wiki topics: 💻 · Programming 🌐 · Web Development

The JavaScript Automation Stack That Saved My Sanity

How I Went from Manual Chores to Auto-Everything Using Node.js, Puppeteer, and a Bit of Madness

I never thought I’d say this, but JavaScript saved me. Not the part where you fight with == and ===, or wonder why NaN !== NaN. No — the part where you use it as an automation engine to wipe out the boring, repetitive junk that clogs up your day.

In this article, I’m sharing the exact projects, patterns, and scripts I’ve built with JavaScript (specifically Node.js) to automate away the parts of my workflow that used to steal hours of focus. These aren’t side projects — these are the scripts I use weekly, sometimes daily.

Let’s dive into the stack.

1. Web Automation with Puppeteer: Logging In, Clicking Buttons, Getting Stuff Done

The moment I realized I could control a browser like a robot, I started using Puppeteer religiously.

Problem:

Every Monday, I had to log into a reporting dashboard, download a CSV, and email it to a manager.

Solution:

A headless script that logs in, clicks the download button, renames the file, and sends it via an API.

const puppeteer = require('puppeteer');
const fs = require('fs');
const path = require('path');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();

  await page.goto('https://dashboard.example.com/login');
  await page.type('#username', 'your_username');
  await page.type('#password', 'your_password');
  await page.click('button[type=submit]');
  await page.waitForNavigation();

  await page.goto('https://dashboard.example.com/reports');
  await page.click('#downloadCsv');
  await page.waitForTimeout(5000); // give time to download

  const downloadPath = '/Users/you/Downloads/report.csv';
  const newPath = path.join(__dirname, 'weekly_report.csv');
  fs.renameSync(downloadPath, newPath);

  console.log('Report downloaded and renamed!');
  await browser.close();
})();

Automating UIs is still one of the most powerful tricks in the book.

2. Node Cron Jobs: The Backend Butler That Never Sleeps

You can’t automate if your script doesn’t run on time. Enter: node-cron.

Problem:

Scripts shouldn’t rely on me remembering to run them.

Solution:

Scheduled tasks that check APIs, send reports, or clean up files.

npm install node-cron
const cron = require('node-cron');
const fs = require('fs');

cron.schedule('0 9 * * 1', () => {
  const message = `Weekly cleanup at ${new Date().toISOString()}`;
  fs.appendFileSync('log.txt', message + '\n');
  console.log('Cleanup logged.');
});

This tiny pattern now powers backups, cleanup tasks, reminders, even Git pull scripts on dev servers.

3. Headless PDFs with Puppeteer: HTML to PDF Like a Boss

Any HTML report can become a gorgeous PDF with one function call.

Problem:

Needed polished, branded reports without using Google Docs or Word.

Solution:

HTML + CSS + Puppeteer = designer-grade PDF.

const puppeteer = require('puppeteer');

async function generatePDF() {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  const html = `
    <html>
      <head>
        <style>
          body { font-family: sans-serif; padding: 2rem; }
          h1 { color: #4CAF50; }
        </style>
      </head>
      <body>
        <h1>Weekly Report</h1>
        <p>Everything is looking great this week.</p>
      </body>
    </html>
  `;

  await page.setContent(html);
  await page.pdf({ path: 'report.pdf', format: 'A4' });

  await browser.close();
  console.log('PDF created!');
}

generatePDF();

This helped me auto-generate invoices, summaries, even resumes on demand.

4. API Scripts: Calling 3rd Party Services Like a Pro

JavaScript shines when it comes to API integrations. With axios or native fetch, I’ve automated:

  • Sending Slack messages
  • Hitting webhooks
  • Uploading files to S3
  • Sending email alerts

Here’s a script I use to ping a webhook after a cron job:

npm install axios
const axios = require('axios');

axios.post('https://hooks.zapier.com/hooks/catch/123456/abcde', {
  status: 'Report generated',
  time: new Date().toISOString()
})
.then(res => console.log('Webhook hit'))
.catch(err => console.error('Error:', err.message));

Simple, but in production, this connects multiple systems into one seamless workflow.

5. File System Automation: Cleaning, Tagging, Organizing

Node’s fs module is criminally underrated. I built a script that scans a downloads folder, classifies files based on extension or keywords, and moves them to proper folders.

const fs = require('fs');
const path = require('path');

const downloads = '/Users/you/Downloads';
const folders = {
  pdf: '/Users/you/Documents/PDFs',
  jpg: '/Users/you/Pictures',
};

fs.readdirSync(downloads).forEach(file => {
  const ext = path.extname(file).slice(1);
  const dest = folders[ext];
  if (dest) {
    fs.renameSync(
      path.join(downloads, file),
      path.join(dest, file)
    );
    console.log(`Moved ${file} to ${dest}`);
  }
});

Result: clean folders, no duplicates, nothing manual.

6. Browserless APIs: Server-Side Puppeteer with Speed

Hosting Puppeteer scripts on servers is messy. That’s why I switched to browserless.io — a hosted Chromium-as-a-service.

Now, I hit a REST endpoint and get back PDFs or screenshots without managing browser instances.

Use case: Automatically generating snapshots of websites or dashboards every day.

7. Terminal Tools with Inquirer and Commander.js

For personal use, I build CLI tools using commander for options and inquirer for interactivity.

npm install commander inquirer
const { Command } = require('commander');
const inquirer = require('inquirer');
const program = new Command();

program.version('1.0.0');

program
  .command('greet')
  .description('Say hello')
  .action(() => {
    inquirer.prompt([
      { type: 'input', name: 'name', message: 'Your name:' }
    ]).then(answers => {
      console.log(`Hello, ${answers.name}!`);
    });
  });

program.parse(process.argv);

I’ve used this pattern to build internal CLI dashboards, deployment tools, and helper scripts.

8. Web Scraping with Cheerio: Fast, Clean, and Headless

For pages that don’t require JS, I avoid Puppeteer and use cheerio for raw scraping.

npm install axios cheerio
const axios = require('axios');
const cheerio = require('cheerio');

async function scrapeSite() {
  const { data } = await axios.get('https://example.com/news');
  const $ = cheerio.load(data);

  $('h2.article-title').each((i, el) => {
    console.log($(el).text());
  });
}

scrapeSite();

I use this for scraping news, pricing data, competitor updates, and more.

9. Automated Email Reports with NodeMailer

Integrating email into your workflows is a game-changer. I built a script that emails the weekly report PDF to myself.

npm install nodemailer
const nodemailer = require('nodemailer');

async function sendEmail() {
  let transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
      user: 'your.email@gmail.com',
      pass: 'your_app_password'
    }
  });

  let info = await transporter.sendMail({
    from: '"Bot" <your.email@gmail.com>',
    to: 'manager@company.com',
    subject: 'Weekly Report',
    text: 'Please find attached the report.',
    attachments: [{
      filename: 'report.pdf',
      path: './report.pdf'
    }]
  });

  console.log('Email sent:', info.messageId);
}

sendEmail();

Final Thoughts

JavaScript isn’t just for building web apps. It’s a full-blown automation engine when you combine Node.js with the right packages. From scraping to PDF generation to scheduling — it’s the Swiss Army knife I reach for when I want to turn repetitive work into one-click magic.

And it’s only getting better.


메타데이터
post_id
5fdbbbd4f70c
slug
the-javascript-automation-stack-that-saved-my-sanity-5fdbbbd4f70c
url
https://medium.com/@maximilianoliver25/the-javascript-automation-stack-that-saved-my-sanity-5fdbbbd4f70c
canonical_url
https://medium.com/@maximilianoliver25/the-javascript-automation-stack-that-saved-my-sanity-5fdbbbd4f70c
author_url
https://medium.com/@maximilianoliver25
status
ok
fetched_at
2026-08-08 04:14:00