WIP
This commit is contained in:
parent
5057d6b6cf
commit
38c1a9a593
@ -78,13 +78,13 @@ class AnkiWeb {
|
|||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener('error', () => reject('failed to execute scrape request'));
|
xhr.addEventListener('error', () => reject('failed to execute scrape request'));
|
||||||
xhr.addEventListener('load', () => {
|
xhr.addEventListener('load', () => {
|
||||||
const modelsJson = JSON.parse(/editor\.models = (.*}]);/.exec(data)[1]);
|
const modelsJson = JSON.parse(/editor\.models = (.*}]);/.exec(xhr.responseText)[1]);
|
||||||
if (!modelsJson) {
|
if (!modelsJson) {
|
||||||
reject('failed to scrape model data');
|
reject('failed to scrape model data');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const decksJson = JSON.parse(/editor\.decks = (.*}});/.exec(data)[1]);
|
const decksJson = JSON.parse(/editor\.decks = (.*}});/.exec(xhr.responseText)[1]);
|
||||||
if (!decksJson) {
|
if (!decksJson) {
|
||||||
reject('failed to scrape deck data');
|
reject('failed to scrape deck data');
|
||||||
return;
|
return;
|
||||||
@ -112,7 +112,7 @@ class AnkiWeb {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener('error', () => reject('failed to execute login request'));
|
xhr.addEventListener('error', () => reject('failed to execute login request'));
|
||||||
xhr.addEventListener('success', () => {
|
xhr.addEventListener('load', () => {
|
||||||
if (xhr.responseText.includes('class="mitem"')) {
|
if (xhr.responseText.includes('class="mitem"')) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user