2022-05-12 21:49:30 +00:00
|
|
|
async function scrape(doc, url = doc.location.href) {
|
2019-08-02 10:09:36 +00:00
|
|
|
// TODO adjust the url building
|
2021-12-29 01:32:56 +00:00
|
|
|
let m = url.match(/FId=([\w\d]+)&/);
|
2019-08-02 10:09:36 +00:00
|
|
|
if (m) {
|
|
|
|
// e.g. http://www.fachportal-paedagogik.de/fis_bildung/suche/fis_ausg.html?FId=A18196&lart=BibTeX&Speichern=Speichern&senden_an=+E-Mail-Adresse
|
2021-12-29 01:32:56 +00:00
|
|
|
let bibUrl = '/fis_bildung/suche/fis_ausg.html?FId=' + m[1] + '&lart=BibTeX';
|
|
|
|
let bibText = await requestText(bibUrl);
|
|
|
|
let translator = Zotero.loadTranslator("import");
|
|
|
|
translator.setTranslator('9cb70025-a888-4a29-a210-93ec52da40d4');
|
|
|
|
translator.setString(bibText);
|
|
|
|
translator.setHandler('itemDone', (_obj, item) => {
|
|
|
|
item.attachments.push({
|
|
|
|
title: 'Snapshot',
|
|
|
|
document: doc
|
2019-08-02 10:09:36 +00:00
|
|
|
});
|
2021-12-29 01:32:56 +00:00
|
|
|
item.complete();
|
2019-08-02 10:09:36 +00:00
|
|
|
});
|
2021-12-29 01:32:56 +00:00
|
|
|
await translator.translate();
|
2019-08-02 10:09:36 +00:00
|
|
|
}
|
|
|
|
}
|