forked from KaKi87/deepl-scraper
Update glossary support #1
1 changed files with 5 additions and 4 deletions
9
index.js
9
index.js
|
|
@ -110,19 +110,20 @@ module.exports = {
|
||||||
await page.click(glossaryButton);
|
await page.click(glossaryButton);
|
||||||
await page.waitForSelector(langSelect, { visible: true });
|
await page.waitForSelector(langSelect, { visible: true });
|
||||||
await page.click(langSelect);
|
await page.click(langSelect);
|
||||||
try {
|
{
|
||||||
|
let isSet = false;
|
||||||
for(const button of await page.$$('button[dl-test=glossary-newentry-lang-dropdown-option]')){
|
for(const button of await page.$$('button[dl-test=glossary-newentry-lang-dropdown-option]')){
|
||||||
const
|
const
|
||||||
_sourceLanguage = await (await (await button.$('.langCode')).getProperty('textContent')).jsonValue(),
|
_sourceLanguage = await (await (await button.$('.langCode')).getProperty('textContent')).jsonValue(),
|
||||||
_targetLanguage = await (await (await button.$('.langCode:nth-of-type(2)')).getProperty('textContent')).jsonValue();
|
_targetLanguage = await (await (await button.$('.langCode:nth-of-type(2)')).getProperty('textContent')).jsonValue();
|
||||||
if(sourceLanguage === _sourceLanguage && targetLanguage === _targetLanguage){
|
if(sourceLanguage === _sourceLanguage && targetLanguage === _targetLanguage){
|
||||||
await button.click();
|
await button.click();
|
||||||
|
isSet = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if(!isSet)
|
||||||
catch(_){
|
throw new Error('UNSUPPORTED_GLOSSARY_LANGUAGE');
|
||||||
throw new Error('UNSUPPORTED_GLOSSARY_LANGUAGE');
|
|
||||||
}
|
}
|
||||||
await page.waitForSelector(sourceGlossaryInput, { visible: true });
|
await page.waitForSelector(sourceGlossaryInput, { visible: true });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue