Add glossary methods #4

Open
KaKi87 wants to merge 15 commits from Androz2091/deepl-scraper:glossary-v2 into master
Showing only changes of commit 9168c85e42 - Show all commits

View file

@ -11,6 +11,8 @@ const getBrowser = async () => {
const getNewPage = async () => await (await getBrowser()).newPage();
const glossaryButton = `.lmt__glossary_onOffSwitch_label`;
module.exports = {
translate: async (sentence, sourceLanguage = 'auto', targetLanguage) => {
if(!/^(auto|[a-z]{2})$/.test(sourceLanguage))
@ -84,7 +86,6 @@ module.exports = {
return _res;
},
clearGlossary: async () => {
const glossaryButton = `.lmt__glossary_onOffSwitch_label`;
const page = await getNewPage();
await page.goto(homepage);
await page.waitForSelector(glossaryButton, { visible: true });
@ -98,8 +99,8 @@ module.exports = {
setGlossary: async (glossary, sourceLanguage, targetLanguage) => {
sourceLanguage = sourceLanguage.toUpperCase();
targetLanguage = targetLanguage.toUpperCase();
const
glossaryButton = `.lmt__glossary_onOffSwitch_label`,
langSelect = `.lmt__glossary_newEntry_langButton`,
sourceGlossaryInput = `.lmt__glossary_newEntry_inputSource`,
targetGlossaryInput = `.lmt__glossary_newEntry_inputTarget`,