forked from KaKi87/deepl-scraper
Update glossary support #1
1 changed files with 9 additions and 16 deletions
25
index.js
25
index.js
|
|
@ -114,22 +114,15 @@ module.exports = {
|
||||||
await page.waitForSelector(langSelect, { visible: true });
|
await page.waitForSelector(langSelect, { visible: true });
|
||||||
await page.click(langSelect);
|
await page.click(langSelect);
|
||||||
try {
|
try {
|
||||||
await page.evaluate(({
|
for(const button of await page.$$('button[dl-test=glossary-newentry-lang-dropdown-option]')){
|
||||||
sourceLanguage,
|
const
|
||||||
targetLanguage
|
_sourceLanguage = await (await (await button.$('.langCode')).getProperty('textContent')).jsonValue(),
|
||||||
}) => {
|
_targetLanguage = await (await (await button.$('.langCode:nth-of-type(2)')).getProperty('textContent')).jsonValue();
|
||||||
const langButtons = Array.from(document.querySelectorAll('button[dl-test=glossary-newentry-lang-dropdown-option]'));
|
if(sourceLanguage === _sourceLanguage && targetLanguage === _targetLanguage){
|
||||||
const button = langButtons.find((btn) => {
|
await button.click();
|
||||||
const childrens = Array.from(Array.from(btn.children)[1].children);
|
break;
|
||||||
const buttonSourceLanguage = childrens[0].textContent;
|
}
|
||||||
const buttonTargetLanguage = childrens[2].textContent;
|
}
|
||||||
return buttonSourceLanguage === sourceLanguage && buttonTargetLanguage === targetLanguage;
|
|
||||||
});
|
|
||||||
button.click();
|
|
||||||
}, {
|
|
||||||
sourceLanguage,
|
|
||||||
targetLanguage
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch(_){
|
catch(_){
|
||||||
throw new Error('UNSUPPORTED_GLOSSARY_LANGUAGE');
|
throw new Error('UNSUPPORTED_GLOSSARY_LANGUAGE');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue