Skip to content

Commit

Permalink
Add Download script
Browse files Browse the repository at this point in the history
  • Loading branch information
madnh committed Feb 1, 2021
1 parent 14afdbf commit 6e6b732
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions download-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(async () => {
const $ = (selector, target = document) => target.querySelector(selector)
const $$ = (selector, target = document) => Array.from(target.querySelectorAll(selector))

const $log = (...args) => console.log(...args)
const $warn = (...args) => console.warn(...args)

const $allTrs = $$('#ctl00_PlaceHolderMain_grid1_DXMainTable > tbody > tr')

const wait = (ms) => new Promise(res => setTimeout(res, ms))

$log("number of tr:", $allTrs.length)
let i = 0
for (let $tr of $allTrs){
const rowId = i++
const $img = $('img:nth-child(1)', $tr)
$log($img)

$img.click()

await wait(5000)

const $chkPhuongXa = $(`#ctl00_PlaceHolderMain_grid1_dxdt${rowId}_check_I`)
if(!$chkPhuongXa){
$warn("Checkbox `phuong xa` not found")
continue
}

$chkPhuongXa.click()

$dlBtn = $(`#ctl00_PlaceHolderMain_grid1_dxdt${rowId}_ASPxButton2`)

if(!$dlBtn){
$warn("Download btn not found")
continue
}

$log(`Start download: ${rowId}`)
$dlBtn.click()
await wait(4000)
}
})()

0 comments on commit 6e6b732

Please sign in to comment.