Merge branch 'master' of bitbucket.org:panleicim/appointment_tool_js
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const {exec} = require("child_process");
|
||||
const regexDevices = /[a-zA-Z0-9]/g
|
||||
exec("adb devices ", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
// find the device id from output
|
||||
// let matchedDeviceIds = regexDevices.exec(stdout)
|
||||
regexDevices.global = true
|
||||
let matchedDeviceIds = stdout.matchAll(regexDevices);
|
||||
for (m in matchedDeviceIds) {
|
||||
console.log(m);
|
||||
}
|
||||
console.log(matchedDeviceIds)
|
||||
// var m;
|
||||
// do {
|
||||
// let m = regexDevices.exec(stdout);
|
||||
// if (m) {
|
||||
// console.log(m[1], m[2]);
|
||||
// }
|
||||
// } while (m);
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
const {_android: android} = require('playwright');
|
||||
const {exec} = require("child_process");
|
||||
|
||||
function delay(delayInMs) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(2);
|
||||
}, delayInMs);
|
||||
});
|
||||
}
|
||||
|
||||
android.devices().then((devices) => {
|
||||
devices.forEach((device) => {
|
||||
console.log(device.serial() + ":will reset browser");
|
||||
exec("adb -s " + device.serial() + " shell pm clear com.android.chrome", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
exec("adb -s " + device.serial() + " shell am set-debug-app --persistent com.android.chrome", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
exec("adb -s " + device.serial() + " shell am start -n com.android.chrome/com.google.android.apps.chrome.Main", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -247,7 +247,98 @@ adb -s APU7N16321020182 shell pm clear com.android.chrome
|
||||
adb -s APU7N16321020182 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
|
||||
#huawei mate 8
|
||||
adb -s emulator-5554 shell pm clear com.android.chrome
|
||||
adb -s emulator-5554 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s emulator-5554 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#1
|
||||
adb -s 2469c020930c7ece shell pm clear com.android.chrome
|
||||
adb -s 2469c020930c7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 2469c020930c7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#2
|
||||
adb -s 2890e299833f7ece shell pm clear com.android.chrome
|
||||
adb -s 2890e299833f7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 2890e299833f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#3
|
||||
adb -s 2890e6d52b3f7ece shell pm clear com.android.chrome
|
||||
adb -s 2890e6d52b3f7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 2890e6d52b3f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#4
|
||||
adb -s 3058394b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 3058394b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 3058394b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#5
|
||||
adb -s 3131315531523098 shell pm clear com.android.chrome
|
||||
adb -s 3131315531523098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 3131315531523098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#6
|
||||
adb -s 324d414b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 324d414b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 324d414b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#7
|
||||
adb -s 3452543639393498 shell pm clear com.android.chrome
|
||||
adb -s 3452543639393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 3452543639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#8
|
||||
adb -s 34e8475c2e0b7ece shell pm clear com.android.chrome
|
||||
adb -s 34e8475c2e0b7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 34e8475c2e0b7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#9
|
||||
adb -s 364f55374c4c3098 shell pm clear com.android.chrome
|
||||
adb -s 364f55374c4c3098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 364f55374c4c3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#10
|
||||
adb -s 374a4a4b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 374a4a4b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 374a4a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#11
|
||||
adb -s 433954544a4a3098 shell pm clear com.android.chrome
|
||||
adb -s 433954544a4a3098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 433954544a4a3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#12
|
||||
adb -s 4347394655383098 shell pm clear com.android.chrome
|
||||
adb -s 4347394655383098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4347394655383098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#13
|
||||
adb -s 4448465253313498 shell pm clear com.android.chrome
|
||||
adb -s 4448465253313498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4448465253313498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#14
|
||||
adb -s 4653345154303098 shell pm clear com.android.chrome
|
||||
adb -s 4653345154303098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4653345154303098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#15
|
||||
adb -s 4b504b4b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 4b504b4b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4b504b4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#16
|
||||
adb -s 53534a4b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 53534a4b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 53534a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#17
|
||||
adb -s 5634563639393498 shell pm clear com.android.chrome
|
||||
adb -s 5634563639393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 5634563639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#18
|
||||
adb -s 344d395044413098 shell pm clear com.android.chrome
|
||||
adb -s 344d395044413098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 344d395044413098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
+119
@@ -176,3 +176,122 @@ adb -s emulator-5556 shell am start -n com.android.chrome/com.google.android.app
|
||||
adb -s APU7N16321020182 shell pm clear com.android.chrome
|
||||
adb -s APU7N16321020182 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
#1
|
||||
adb -s 2469c020930c7ece shell pm clear com.android.chrome
|
||||
adb -s 2469c020930c7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 2469c020930c7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#2
|
||||
adb -s 2890e299833f7ece shell pm clear com.android.chrome
|
||||
adb -s 2890e299833f7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 2890e299833f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#3
|
||||
adb -s 2890e6d52b3f7ece shell pm clear com.android.chrome
|
||||
adb -s 2890e6d52b3f7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 2890e6d52b3f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#4
|
||||
adb -s 3058394b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 3058394b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 3058394b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#5
|
||||
adb -s 3131315531523098 shell pm clear com.android.chrome
|
||||
adb -s 3131315531523098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 3131315531523098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#6
|
||||
adb -s 324d414b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 324d414b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 324d414b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#7
|
||||
adb -s 3452543639393498 shell pm clear com.android.chrome
|
||||
adb -s 3452543639393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 3452543639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#8
|
||||
adb -s 34e8475c2e0b7ece shell pm clear com.android.chrome
|
||||
adb -s 34e8475c2e0b7ece shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 34e8475c2e0b7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#9
|
||||
adb -s 364f55374c4c3098 shell pm clear com.android.chrome
|
||||
adb -s 364f55374c4c3098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 364f55374c4c3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#10
|
||||
adb -s 374a4a4b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 374a4a4b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 374a4a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#11
|
||||
adb -s 433954544a4a3098 shell pm clear com.android.chrome
|
||||
adb -s 433954544a4a3098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 433954544a4a3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#12
|
||||
adb -s 4347394655383098 shell pm clear com.android.chrome
|
||||
adb -s 4347394655383098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4347394655383098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#13
|
||||
adb -s 4448465253313498 shell pm clear com.android.chrome
|
||||
adb -s 4448465253313498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4448465253313498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#14
|
||||
adb -s 4653345154303098 shell pm clear com.android.chrome
|
||||
adb -s 4653345154303098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4653345154303098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#15
|
||||
adb -s 4b504b4b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 4b504b4b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 4b504b4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#16
|
||||
adb -s 53534a4b4a393498 shell pm clear com.android.chrome
|
||||
adb -s 53534a4b4a393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 53534a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#17
|
||||
adb -s 5634563639393498 shell pm clear com.android.chrome
|
||||
adb -s 5634563639393498 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 5634563639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#18
|
||||
adb -s 344d395044413098 shell pm clear com.android.chrome
|
||||
adb -s 344d395044413098 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 344d395044413098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#18
|
||||
adb -s emulator-5562 shell pm clear com.android.chrome
|
||||
adb -s emulator-5562 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s emulator-5562 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
|
||||
#18
|
||||
adb -s emulator-5558 shell pm clear com.android.chrome
|
||||
adb -s emulator-5558 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s emulator-5558 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
adb -s emulator-5560 shell pm clear com.android.chrome
|
||||
adb -s emulator-5560 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s emulator-5560 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#18
|
||||
adb -s 192.168.0.37:5555 shell pm clear com.android.chrome
|
||||
adb -s 192.168.0.37:5555 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 192.168.0.37:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#18
|
||||
adb -s 192.168.0.27:5555 shell pm clear com.android.chrome
|
||||
adb -s 192.168.0.27:5555 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s 192.168.0.27:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
|
||||
#18
|
||||
adb -s emulator-5560 shell pm clear com.android.chrome
|
||||
adb -s emulator-5560 shell am set-debug-app --persistent com.android.chrome
|
||||
adb -s emulator-5560 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||
+12
-2
@@ -44,13 +44,23 @@
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<h5>连接的手机</h5>
|
||||
<h5>连接的设备</h5>
|
||||
<div id="device_list"/>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<button id="start_book_btn" type="button" class="btn btn-primary">开始约会
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
|
||||
<button id="scheduler_book_btn" type="button" class="btn btn-primary">10点30开始
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="./renderer.js"></script>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const {app, BrowserWindow, ipcMain} = require('electron')
|
||||
const {_android: android} = require('playwright');
|
||||
const startBookWithNumbers = require('./src/appointment')
|
||||
const {startBookWithNumbers, scheduleBookWithNumbers} = require('./src/appointment')
|
||||
const path = require("path");
|
||||
const homedir = require('os').homedir();
|
||||
const loadIniFile = require('read-ini-file')
|
||||
@@ -22,6 +22,9 @@ const createWindow = () => {
|
||||
ipcMain.on('start-book', (event, startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => {
|
||||
startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep)
|
||||
})
|
||||
ipcMain.on('schedule-book', (event, startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => {
|
||||
scheduleBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep)
|
||||
})
|
||||
ipcMain.on('clearAllBrowsers', (event) => {
|
||||
clearAllBrowsers()
|
||||
})
|
||||
@@ -83,6 +86,20 @@ function startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBee
|
||||
})
|
||||
}
|
||||
|
||||
function scheduleBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) {
|
||||
console.log("scheduleBook: " + startNumber);
|
||||
console.log("endNumber: " + endNumber);
|
||||
console.log("selectedStore: " + selectedStore);
|
||||
console.log("audioAnalyse: " + audioAnalyse);
|
||||
//load config.ini file
|
||||
let config = loadIniFile.sync(configFilePath);
|
||||
console.log(config);
|
||||
let contactExcelFilePath = config.DEFAULT.contact_list_file;
|
||||
scheduleBookWithNumbers(startNumber, endNumber, selectedStore, contactExcelFilePath, audioAnalyse, alertBeep).then(() => {
|
||||
console.log("stop")
|
||||
})
|
||||
}
|
||||
|
||||
async function scanDevices() {
|
||||
exec("adb devices ", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
|
||||
@@ -2,6 +2,13 @@ const {contextBridge, ipcRenderer} = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('appointment', {
|
||||
startBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep),
|
||||
scheduleBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('schedule-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep),
|
||||
clearAllBrowsers: () => ipcRenderer.send('clearAllBrowsers'),
|
||||
scanDevices: () => ipcRenderer.invoke('scan-devices')
|
||||
})
|
||||
|
||||
// contextBridge.exposeInMainWorld('appointment', {
|
||||
// startBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('schedule-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep),
|
||||
// clearAllBrowsers: () => ipcRenderer.send('clearAllBrowsers'),
|
||||
// scanDevices: () => ipcRenderer.invoke('scan-devices')
|
||||
// })
|
||||
+11
-2
@@ -5,14 +5,17 @@ let selectedStore = 'random';
|
||||
window.addEventListener('load', () => {
|
||||
window.appointment.scanDevices().then((deviceList) => {
|
||||
// Make the list
|
||||
let listElement = document.getElementById('device_list');
|
||||
let deviceListSection = document.getElementById('device_list');
|
||||
let deviceNumberInfo = document.createElement("div")
|
||||
deviceNumberInfo.innerHTML = "连接的设备数:" + deviceList.length;
|
||||
deviceListSection.appendChild(deviceNumberInfo);
|
||||
for (i = 0; i < deviceList.length; ++i) {
|
||||
// Create an item for each one
|
||||
let listItem = document.createElement('li');
|
||||
// Add the item text
|
||||
listItem.innerHTML = deviceList[i].join(" : ");
|
||||
// Add listItem to the listElement
|
||||
listElement.appendChild(listItem);
|
||||
deviceListSection.appendChild(listItem);
|
||||
}
|
||||
})
|
||||
document.getElementById("start_book_btn").addEventListener('click', () => {
|
||||
@@ -21,6 +24,12 @@ window.addEventListener('load', () => {
|
||||
window.appointment.startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep);
|
||||
})
|
||||
|
||||
document.getElementById("scheduler_book_btn").addEventListener('click', () => {
|
||||
let audioAnalyse = document.getElementById("audio_analyse").checked;
|
||||
let alertBeep = document.getElementById("alert_beep").checked;
|
||||
window.appointment.scheduleBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep);
|
||||
})
|
||||
|
||||
document.getElementById("clear_all_browsers").addEventListener('click', () => {
|
||||
window.appointment.clearAllBrowsers();
|
||||
})
|
||||
|
||||
+23
-9
@@ -3,12 +3,14 @@ const ExcelUtil = require("./excel/ExcelUtil");
|
||||
const CommandorPage = require("./workers/CommandorPage");
|
||||
const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
||||
const alert = require('alert');
|
||||
const schedule = require("node-schedule");
|
||||
|
||||
const mongoManager = new MongoManager();
|
||||
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
||||
const THIRTY_DAYS_IN_S = 3600 * 24 * 30;
|
||||
const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
||||
let excelUtil = new ExcelUtil();
|
||||
let collectionName = formatDate(new Date())
|
||||
device_to_excludes = ["47e7e36b", "e30eb015"]
|
||||
|
||||
async function filterAlreadyBookedContacts(contactList) {
|
||||
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
@@ -31,7 +33,7 @@ async function filterAlreadyAccepteddContacts(contactList) {
|
||||
console.log("=====handle already accepted item before booking====");
|
||||
console.log("accepted_at is " + acceptedItem.accepted_at);
|
||||
console.log("accepted email is " + acceptedItem.email);
|
||||
needToBook = acceptedItem.accepted_at + THIRTY_DAYS_IN_S <= (new Date()) / 1000;
|
||||
needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
||||
if (!needToBook) {
|
||||
console.log("already accepted appointment --> skip");
|
||||
}
|
||||
@@ -98,7 +100,7 @@ async function needToBook(contact, mongoManager) {
|
||||
console.log("=====handle already accepted item====");
|
||||
console.log("accepted_at is " + acceptedItem.accepted_at);
|
||||
console.log("accepted email is " + acceptedItem.email);
|
||||
needToBook = acceptedItem.accepted_at + THIRTY_DAYS_IN_S <= (new Date()) / 1000;
|
||||
needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
||||
if (!needToBook) {
|
||||
console.log("already accepted appointment --> skip");
|
||||
}
|
||||
@@ -132,7 +134,18 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) {
|
||||
async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
||||
console.log("scheduleBookWithNumbers() called")
|
||||
alert("定时成功")
|
||||
schedule.scheduleJob('30 10 * * *', function () {
|
||||
console.log("start startBookWithNumbers")
|
||||
startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse, alertBeep)
|
||||
})
|
||||
}
|
||||
|
||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
||||
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
|
||||
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
|
||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||
let contactList;
|
||||
if (endNumber <= allContactList.length) {
|
||||
@@ -154,11 +167,12 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
alert("未找到连接的设备");
|
||||
return
|
||||
}
|
||||
let segmentNumber = listWithoutBlackContact.length / devices.length;
|
||||
console.log("connected device number:" + devices.length)
|
||||
let filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial()))
|
||||
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
||||
console.log("connected device number:" + filteredDeviceList.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
||||
for (let i = 0; i < filteredDeviceList.length; i++) {
|
||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), filteredDeviceList[i], selectedStore, audioAnalyse, alertBeep);
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -168,4 +182,4 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = startBookWithNumbers
|
||||
module.exports = {startBookWithNumbers, scheduleBookWithNumbers}
|
||||
@@ -8,8 +8,6 @@ class ExcelUtil {
|
||||
let contactList = [];
|
||||
workSheetsFromFile[0].data.forEach(
|
||||
(info, index, list) => {
|
||||
// console.log("info:" + info)
|
||||
// console.log("index:" + index)
|
||||
if (index > 0 && info.length > 0) {
|
||||
// console.log(info)
|
||||
let name = info[0].split(" ")
|
||||
|
||||
@@ -7,7 +7,7 @@ const {
|
||||
shell
|
||||
} = require('electron')
|
||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||
// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
|
||||
// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html";
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
const BLANK_URL = "about:blank"
|
||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||
@@ -36,7 +36,7 @@ const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
||||
const REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||
const DEFAULT_STORE = 'faubourg';
|
||||
const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous', 'online+appointment+hermes', 'hermes+online+appointment']
|
||||
const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous','hermes+rendez+vous+paris', 'online+appointment+hermes', 'hermes+online+appointment', 'paris+hermes+online+appointment']
|
||||
|
||||
function delay(delayInMs) {
|
||||
return new Promise(resolve => {
|
||||
@@ -95,22 +95,24 @@ class CommandorPage {
|
||||
})
|
||||
try {
|
||||
const item = searchTexts[Math.floor(Math.random() * searchTexts.length)];
|
||||
await this.page.goto("https://www.google.com/search?q=" + item, {timeout: 90 * 1000});
|
||||
await this.page.goto("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 90 * 1000});
|
||||
// await this.page.goto(RDV_URL, {timeout: 90 * 1000});
|
||||
} catch (e) {
|
||||
log(e)
|
||||
this.isTerminated = true
|
||||
}
|
||||
try {
|
||||
this.page.locator('button:has-text("Tout accepter")').click()
|
||||
} catch (e) {
|
||||
log(e)
|
||||
}
|
||||
try {
|
||||
this.page.locator('button:has-text("Accept all")').click()
|
||||
if (this.page.url().includes("google"))
|
||||
this.page.locator('button >> nth=3').click()
|
||||
// this.page.locator('button:has-text("Tout accepter")').click()
|
||||
} catch (e) {
|
||||
log(e)
|
||||
}
|
||||
// try {
|
||||
// this.page.locator('button:has-text("Accept all")').click()
|
||||
// } catch (e) {
|
||||
// log(e)
|
||||
// }
|
||||
try {
|
||||
this.page.locator(':nth-match(:text("Online Appointment"), 1)').click()
|
||||
} catch (e) {
|
||||
@@ -259,7 +261,6 @@ class CommandorPage {
|
||||
log(e);
|
||||
this.isTerminated = true;
|
||||
}
|
||||
// await page.click(PREFER_STORE);
|
||||
}
|
||||
|
||||
|
||||
@@ -311,6 +312,10 @@ class CommandorPage {
|
||||
await this.push_message_to_queue(PublishType.SUCCESS)
|
||||
return
|
||||
}
|
||||
//check whether there is captcha
|
||||
let pageContent = await page.content()
|
||||
let hasCaptcha = pageContent.includes("g-recaptcha-response")
|
||||
if (hasCaptcha) {
|
||||
this.captchaSolver = new SolveCaptcha(page);
|
||||
await this.captchaSolver.start((solution) => {
|
||||
log("solution is: " + solution);
|
||||
@@ -332,6 +337,9 @@ class CommandorPage {
|
||||
this.isTerminated = true;
|
||||
}
|
||||
})
|
||||
} else {
|
||||
await this.clickValid();
|
||||
}
|
||||
}
|
||||
|
||||
async isBlocked() {
|
||||
@@ -357,6 +365,8 @@ class CommandorPage {
|
||||
}
|
||||
}
|
||||
log("发现datadome");
|
||||
} else if (currentPage.url().includes("sorry")) {
|
||||
await this.resetBrowser()
|
||||
} else {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
await this.fillFields(this.page);
|
||||
|
||||
@@ -10,6 +10,7 @@ const CAPTCHA_CONTAINER = "#captcha-container";
|
||||
const WAV_URL_REGEX = "https:.+.wav";
|
||||
const re = new RegExp(WAV_URL_REGEX);
|
||||
const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000"
|
||||
|
||||
// const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000"
|
||||
|
||||
function delay(delayInMs) {
|
||||
@@ -66,6 +67,17 @@ class GeoCaptchaSolver {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
async clearLastDigit(iframeHandler) {
|
||||
let selector = "#captcha__audio > div.audio-captcha-input-container > input:nth-child(" + 6 + ")"
|
||||
let lastDigit = await iframeHandler.locator(selector).inputValue()
|
||||
if (lastDigit !== "") {
|
||||
console.log(this.device.model() + ":last digit is not empty, clear it")
|
||||
await iframeHandler.locator(selector).fill("")
|
||||
} else {
|
||||
console.log(this.device.model() + ":last digit is empty, do nothing")
|
||||
}
|
||||
}
|
||||
|
||||
async solve(onResult) {
|
||||
console.log(this.device.model() + ":solve() called.")
|
||||
console.log(this.device.model() + ":play audio")
|
||||
@@ -89,6 +101,9 @@ class GeoCaptchaSolver {
|
||||
// console.log("selector is " + selector)
|
||||
try {
|
||||
await iframeHandler.locator(selector).focus()
|
||||
if (i === 5) {
|
||||
await this.clearLastDigit(iframeHandler)
|
||||
}
|
||||
await iframeHandler.locator(selector).fill("" + number_list[i - 1])
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -100,7 +115,7 @@ class GeoCaptchaSolver {
|
||||
try {
|
||||
|
||||
let content = await captcha_container.innerHTML()
|
||||
console.log("inner container is " + content)
|
||||
console.log(this.device.model() + ":inner container is " + content)
|
||||
try {
|
||||
if (number_list.length === 0) {
|
||||
onResult(false)
|
||||
@@ -144,7 +159,7 @@ class GeoCaptchaSolver {
|
||||
}
|
||||
|
||||
async resetBrowser() {
|
||||
console.log("will reset browser")
|
||||
console.log(this.device.model() + ":will reset browser")
|
||||
await this.device.shell("pm clear com.android.chrome")
|
||||
await delay(1000)
|
||||
await this.device.shell("am set-debug-app --persistent com.android.chrome")
|
||||
|
||||
@@ -7,3 +7,6 @@ emulator -avd Pixel_2_API_30_5 &
|
||||
emulator -avd Pixel_2_API_30_6 &
|
||||
emulator -avd Pixel_2_API_30_7 &
|
||||
emulator -avd Pixel_2_API_30_8 &
|
||||
emulator -avd Pixel_2_API_30_9 &
|
||||
emulator -avd Pixel_2_API_30_10 &
|
||||
emulator -avd Pixel_2_API_30_11 &
|
||||
@@ -0,0 +1,4 @@
|
||||
emulator -avd Pixel_0 &
|
||||
emulator -avd Pixel_1 &
|
||||
emulator -avd Pixel_2 &
|
||||
emulator -avd Pixel_3 &
|
||||
Reference in New Issue
Block a user