add checkbox to disable speechtotext
This commit is contained in:
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html xmlns="http://www.w3.org/1999/html">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||||
@@ -33,6 +33,8 @@
|
|||||||
<option value="georgev">Hermès George V</option>
|
<option value="georgev">Hermès George V</option>
|
||||||
<option value="sevres">Hermès Sèvres</option>
|
<option value="sevres">Hermès Sèvres</option>
|
||||||
</select>
|
</select>
|
||||||
|
<br/>
|
||||||
|
<input name="audio_analyse" id="audio_analyse" type="checkbox" checked>自动语音分析</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ const createWindow = () => {
|
|||||||
win.loadFile('index.html').then((r) => {
|
win.loadFile('index.html').then((r) => {
|
||||||
|
|
||||||
})
|
})
|
||||||
ipcMain.on('start-book', (event, startNumber, endNumber, selectedStore) => {
|
ipcMain.on('start-book', (event, startNumber, endNumber, selectedStore, audioAnalyse) => {
|
||||||
startBook(startNumber, endNumber, selectedStore)
|
startBook(startNumber, endNumber, selectedStore, audioAnalyse)
|
||||||
})
|
})
|
||||||
ipcMain.handle('scan-devices', scanDevices)
|
ipcMain.handle('scan-devices', scanDevices)
|
||||||
// win.webContents.openDevTools();
|
// win.webContents.openDevTools();
|
||||||
@@ -37,15 +37,16 @@ app.on('window-all-closed', () => {
|
|||||||
if (process.platform !== 'darwin') app.quit()
|
if (process.platform !== 'darwin') app.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
function startBook(startNumber, endNumber, selectedStore) {
|
function startBook(startNumber, endNumber, selectedStore, audioAnalyse) {
|
||||||
console.log("startNumber: " + startNumber);
|
console.log("startNumber: " + startNumber);
|
||||||
console.log("endNumber: " + endNumber);
|
console.log("endNumber: " + endNumber);
|
||||||
console.log("selectedStore: " + selectedStore);
|
console.log("selectedStore: " + selectedStore);
|
||||||
|
console.log("audioAnalyse: " + audioAnalyse);
|
||||||
//load config.ini file
|
//load config.ini file
|
||||||
let config = loadIniFile.sync(configFilePath);
|
let config = loadIniFile.sync(configFilePath);
|
||||||
console.log(config);
|
console.log(config);
|
||||||
let contactExcelFilePath = config.DEFAULT.contact_list_file;
|
let contactExcelFilePath = config.DEFAULT.contact_list_file;
|
||||||
startBookWithNumbers(startNumber, endNumber, selectedStore, contactExcelFilePath).then(() => {
|
startBookWithNumbers(startNumber, endNumber, selectedStore, contactExcelFilePath, audioAnalyse).then(() => {
|
||||||
console.log("stop")
|
console.log("stop")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
const {contextBridge, ipcRenderer} = require('electron')
|
const {contextBridge, ipcRenderer} = require('electron')
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('appointment', {
|
contextBridge.exposeInMainWorld('appointment', {
|
||||||
startBook: (startNumber, endNumber, selectedStore) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore),
|
startBook: (startNumber, endNumber, selectedStore, audioAnalyse) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore, audioAnalyse),
|
||||||
scanDevices: () => ipcRenderer.invoke('scan-devices')
|
scanDevices: () => ipcRenderer.invoke('scan-devices')
|
||||||
})
|
})
|
||||||
+2
-1
@@ -16,7 +16,8 @@ window.addEventListener('load', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
document.getElementById("start_book_btn").addEventListener('click', () => {
|
document.getElementById("start_book_btn").addEventListener('click', () => {
|
||||||
window.appointment.startBook(startNumber, endNumber, selectedStore)
|
let audioAnalyse = document.getElementById("audio_analyse").checked;
|
||||||
|
window.appointment.startBook(startNumber, endNumber, selectedStore, audioAnalyse);
|
||||||
})
|
})
|
||||||
document.getElementById("store_selector").addEventListener('change', (event) => {
|
document.getElementById("store_selector").addEventListener('change', (event) => {
|
||||||
selectedStore = event.target.value
|
selectedStore = event.target.value
|
||||||
|
|||||||
+6
-6
@@ -35,11 +35,11 @@ async function needToBook(contact, mongoManager) {
|
|||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, selectedStore) {
|
async function startBook(contactPojo, device, selectedStore, audioAnalyse) {
|
||||||
console.log(`型号: ${device.model()}`);
|
console.log(`型号: ${device.model()}`);
|
||||||
console.log(`序列号: ${device.serial()}`);
|
console.log(`序列号: ${device.serial()}`);
|
||||||
if (await needToBook(contactPojo, mongoManager)) {
|
if (await needToBook(contactPojo, mongoManager)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore);
|
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore, audioAnalyse);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} else {
|
||||||
@@ -47,18 +47,18 @@ async function startBook(contactPojo, device, selectedStore) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startWithList(contacts, device, selectedStore) {
|
async function startWithList(contacts, device, selectedStore, audioAnalyse) {
|
||||||
await contacts.reduce(async (promise, contactPojo) => {
|
await contacts.reduce(async (promise, contactPojo) => {
|
||||||
// This line will wait for the last async function to finish.
|
// This line will wait for the last async function to finish.
|
||||||
// The first iteration uses an already resolved Promise
|
// The first iteration uses an already resolved Promise
|
||||||
// so, it will immediately continue.
|
// so, it will immediately continue.
|
||||||
await promise;
|
await promise;
|
||||||
const contents = await startBook(contactPojo, device, selectedStore);
|
const contents = await startBook(contactPojo, device, selectedStore, audioAnalyse);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx') {
|
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false) {
|
||||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||||
let contactList;
|
let contactList;
|
||||||
if (endNumber <= allContactList.length) {
|
if (endNumber <= allContactList.length) {
|
||||||
@@ -80,7 +80,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
}
|
}
|
||||||
let segmentNumber = listToBook.length / devices.length;
|
let segmentNumber = listToBook.length / devices.length;
|
||||||
for (let i = 0; i < devices.length; i++) {
|
for (let i = 0; i < devices.length; i++) {
|
||||||
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore);
|
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function log(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE) {
|
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
this.device = device;
|
this.device = device;
|
||||||
this.mongoManager = mongoManager;
|
this.mongoManager = mongoManager;
|
||||||
@@ -65,6 +65,7 @@ class CommandorPage {
|
|||||||
this.choosedStore = selectedStore
|
this.choosedStore = selectedStore
|
||||||
this.isFillingFields = false;
|
this.isFillingFields = false;
|
||||||
this.isTerminated = false;
|
this.isTerminated = false;
|
||||||
|
this.audioAnalyse = audioAnalyse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -294,7 +295,9 @@ class CommandorPage {
|
|||||||
let content = await currentPage.content();
|
let content = await currentPage.content();
|
||||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||||
if (content.toString().includes(captcha_url)) {
|
if (content.toString().includes(captcha_url)) {
|
||||||
|
if (this.audioAnalyse) {
|
||||||
await this.checkAudioBtn();
|
await this.checkAudioBtn();
|
||||||
|
}
|
||||||
for (let i = 0; i < 15; i++) {
|
for (let i = 0; i < 15; i++) {
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
shell.beep()
|
shell.beep()
|
||||||
@@ -325,8 +328,8 @@ class CommandorPage {
|
|||||||
if (audioBtn) {
|
if (audioBtn) {
|
||||||
log("audioBtn found")
|
log("audioBtn found")
|
||||||
audioBtn.click()
|
audioBtn.click()
|
||||||
let captchSolver = new GeoCaptchaSolver(this.page)
|
let captchaSolver = new GeoCaptchaSolver(this.page)
|
||||||
captchSolver.solve()
|
await captchaSolver.solve()
|
||||||
} else {
|
} else {
|
||||||
log("audioBtn not found")
|
log("audioBtn not found")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const crypto = require('crypto');
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const homedir = require('os').homedir();
|
const homedir = require('os').homedir();
|
||||||
const dest_dir = homedir + "/wavs/"
|
const dest_dir = homedir + "/wavs/"
|
||||||
// iframe.query_selector('.audio-captcha-track').inner_html()
|
|
||||||
const AUDIO_CAPTCHA_TRACK = ".audio-captcha-track";
|
const AUDIO_CAPTCHA_TRACK = ".audio-captcha-track";
|
||||||
const CAPTCHA_CONTAINER = "#captcha-container";
|
const CAPTCHA_CONTAINER = "#captcha-container";
|
||||||
const WAV_URL_REGEX = "https:.+.wav";
|
const WAV_URL_REGEX = "https:.+.wav";
|
||||||
|
|||||||
Reference in New Issue
Block a user