Giter Site home page Giter Site logo

order-placement-scripts's Introduction

Automated order placement scripts

This is an automated order placement script built by Typescript.

It is applicable to any products in the Canada Computers official website.

Support custom configurations, such as logging blogs an, automatic email alerts, and record potential errors(for user debugging).

Classification

  1. Notification version
    1. Notification of the availability of items on the shelves.
    2. Excellent speed and stability.
  2. Automated order version
    1. Automatic login and successful order placement.
    2. Audible alerts when items are available.
    3. Note that pick-up address need to be changed manually. (More info please check ./src/settings.ts)

Features

  • Automatic user login.
  • Supports two options to pass reCAPTCHA checks
  • Stable operation.
  • Audible alerts when items are on the shelves.
  • The settings file supports a wide range of customized options.
  • Stable error handling to ensure program keep running.

Tools

  • Language: TypeScript

  • Nodemailer

  • log4js

  • chalk

  • Puppeteer

  • Chromium

  • pm2

Deployment

Notice: Setting your configuration first.

  • Running locally

    • npm run start   // Automated order placement scripts
      npm run inform  // Email inform scripts
  • Running on the server

    • Install Chromium ,Node.js.
      • Notice: Default executable_Path is '/usr/bin/chromium'.
    • Use pm2 to manage node process.

Configuration

user configuration file is './src/settings.ts'

const min: number = 60000
const seconds: number = 1000
enum CHECKLIST {
	RTX_3060 = 'https://www.canadacomputers.com/index.php?cPath=43&sf=:3_8,3_9&mfr=&pr=',
	RTX_3060_3070 = 'https://www.canadacomputers.com/index.php?cPath=43_557&sf=:3_7,3_9&mfr=&pr=',
	RTX_3070 = 'https://www.canadacomputers.com/index.php?cPath=43&sf=:3_7&mfr=&pr=',
	RTX_3080 = 'https://www.canadacomputers.com/index.php?cPath=43&sf=:3_5&mfr=&pr=',
	RTX_3070_3080 = 'https://www.canadacomputers.com/index.php?cPath=43&sf=:3_5,3_7&mfr=&pr=',
	RTX_3060_3070_3080 = 'https://www.canadacomputers.com/index.php?cPath=43&sf=:3_5,3_7,3_8,3_9&mfr=&pr=',
}

enum SERVER_CHROME_PATH {
	Snap = '/snap/bin/chromium',
	Usr = '/usr/bin/chromium',
}

export const INFO: _INFO = {
	Manual_Login: false, // manually login
	Location_Ottawa: false, // ottawa or toronto
	Store_Page: false,
	Local: true, // server to false
	Logger: false, // server to false
	Solver: false, // pass the recaptcha, not stable
	Target: CHECKLIST.RTX_3060_3070,
	Server_Chrome_Path: SERVER_CHROME_PATH.Snap, // server chromium path
	HeadLess: false,
	Test: true, // proxy or not
	Slow_Mode: false,
}

export const TIME_SET: _TIME_SET = {
	TimerB_Wait: 0.2 * min, // timerB backup time
	Time_Gap: 0.2 * min, // reboot waiting time
	Logger_Gap: 200, // min times to trigger local logs.`
	Loading_Time: 5 * seconds, // Time gap of each round
}
export const EMAIL: _EMAIL = {
	Email_Address: '[email protected]',
	Email_Service: 'Gmail',
	Smtp_Pass: 'XXXXX', // your smtp pass
	Email_To: ['[email protected]'], // Array<string>
}
export const BANK: _BANK = {
	LAST_4_DIGIT: 'XXXX', // bank info, it can be set manually.
	LAST_NAME: 'XXXXX',
}

export const USER: _USER = {
	Username: 'your username',
	Password: 'your password',
}
export const URL: _URL = {
	Complete_Url: INFO.Target,
	Base_Url: 'www.canadacomputers.com/index.php?cPath',
	Login_Url: 'https://www.canadacomputers.com/login.php',
}

Pick-up Address in ./src/utils/index.ts

//Currently support Ottawa and Toronto
	//Ottawa
	const OttawaDowntown = await page.$('input[id="OD]"]')
	const OttawaMerivale = await page.$('input[id="OTT2]')
	const OttawaOrleans = await page.$('input[id="OTT3]')
	const Gatineau = await page.$('input[id="GT]"]')
	const Kanata = await page.$('input[id="KANA]"]')
	//Toronto
	const WaterLoo = await page.$('input[id="WATERLOO"]')
	const London = await page.$('input[id="LOND"]')
	const MarkHam = await page.$('input[id="MU"]')
	const Scarborough = await page.$('input[id="1203"]')
	const RichMoundHill = await page.$('input[id="R-HILL"]')
	const NorthYork = await page.$('input[id="NO"]')
	const MidTownToronto = await page.$('input[id="EGLN"]')
	const Vaughan = await page.$('input[id="VAUG"]')
	const AJAX = await page.$('input[id="AJAX"]')
	const DownTownToronto = await page.$('input[id="C343"]')
	const Whitby = await page.$('input[id="WHIT"]')
	const Etobicoke = await page.$('input[id="ETOB"]')

order-placement-scripts's People

Contributors

fleetingecho avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

order-placement-scripts's Issues

pick-up address selection

are we suppose to click on the radio button for the pickup address manually when it comes up?

It seems to get stuck on that screen if that's not the case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.