Last active
January 25, 2022 22:01
-
-
Save dfrankland/f6c6992e375210ed25e8f51841b09152 to your computer and use it in GitHub Desktop.
Quickly add cards with plain text using AnkiWeb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go to https://ankiuser.net/edit/ | |
(async ({ cardType, nameOfDeck, data }) => { | |
const body = [ | |
["nid", ""], | |
["data", encodeURIComponent(JSON.stringify(data))], | |
["csrf_token", editor.token], | |
["mid", editor.mode.notetypes.find(({ name }) => name === cardType).id], | |
["deck", editor.mode.decks.find(({ name }) => name === nameOfDeck).id], | |
] | |
.map((x) => x.join("=")) | |
.join("&"); | |
const response = await fetch("https://ankiuser.net/edit/save", { | |
headers: { | |
"content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"x-requested-with": "XMLHttpRequest", | |
}, | |
body: body, | |
method: "POST", | |
credentials: "include", | |
}); | |
const json = await response.json(); | |
console.log('Success!'); | |
console.log(JSON.stringify(json, null, 2)); | |
setTimeout(() => window.location.reload(), 2000); | |
})({ | |
cardType: "Basic", | |
nameOfDeck: "AIAIJ Ch. 10 Kanji Sheet 2", | |
data: [ | |
[ | |
`残`, | |
`のこ(る) | |
ザン | |
残る(のこる) | |
残念(ざんねん)`.replace(/\n/g, '<br>'), | |
], | |
"", | |
], | |
}).catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copy(`国内 | |
ごくない | |
domestic [=国の中] | |
_________ | |
パス | |
pass | |
_________ | |
旅行社 | |
りょこうしゃ | |
travel agency | |
_________ | |
大都市 | |
だいとし | |
very big city; metropolis [=大きい町] | |
_________ | |
有効 | |
ゆうこう | |
valid | |
_________ | |
(〜)期間中 | |
(〜)きかんちゅう | |
during the period (when 〜) | |
_________ | |
鉄道 | |
てつどう | |
railway | |
_________ | |
北 | |
きた | |
north | |
_________ | |
南 | |
みなみ | |
south | |
_________ | |
走る | |
はしる | |
to run | |
_________ | |
フロンティア | |
frontier | |
_________ | |
大自然 | |
だいいぜん | |
Mother Nature [lit., mighty nature] | |
_________ | |
残る | |
のこる | |
to remain [vi.] | |
_________ | |
農業 | |
のうぎょう | |
agriculture | |
_________ | |
受ける | |
うける | |
to receive | |
_________ | |
牛 | |
うし | |
cow | |
_________ | |
馬 | |
うま | |
horse | |
_________ | |
羊 | |
ひつじ | |
sheep | |
_________ | |
サイロ | |
silo | |
_________ | |
建つ | |
たつ | |
to stand; to be built [v.i.] | |
_________ | |
景色 | |
けしき | |
scenery | |
_________ | |
先住民 | |
せんじゅうみん | |
people native to the land | |
_________ | |
アイヌ | |
Ainu | |
_________ | |
村 | |
むら | |
village | |
_________ | |
本州 | |
ぽんしゅう | |
[main island of Japan] | |
_________ | |
南北に | |
なんぼくに | |
from north to south | |
_________ | |
最大 | |
さいだい | |
largest [=一番大きい] | |
_________ | |
大阪 | |
おおさか | |
[place name] | |
_________ | |
横浜 | |
よこはま | |
[place name] | |
_________ | |
神戸 | |
こうべ | |
[place name] | |
_________ | |
国際的に | |
こくさいてきに | |
internationally | |
_________ | |
世界 | |
せかい | |
world | |
_________ | |
商業 | |
しょうぎょう | |
commerce | |
_________ | |
教育 | |
きょういく | |
education | |
_________ | |
芸術 | |
げいじゅつ | |
art | |
_________ | |
すべて | |
all [=全部] | |
_________ | |
中心 | |
ちゅうしん | |
center | |
_________ | |
醜い | |
みにくい | |
ugly | |
_________ | |
混雑した | |
ごんざつした | |
crowded | |
_________ | |
批判する | |
ひはんする | |
to criticize | |
_________ | |
ラッシュアワー | |
rush hour | |
_________ | |
秩序 | |
ちつじょ | |
order | |
_________ | |
特徵 | |
とくちょう | |
characteristics | |
_________ | |
十分の一 | |
じゅうぶんのいち | |
one tenth | |
_________ | |
アメリカあたり | |
America, for instance | |
_________ | |
犯罪 | |
はんざい | |
crime | |
_________ | |
夜 | |
よる | |
at night | |
_________ | |
ひとり歩き | |
ひとりあるき | |
walking alone | |
_________ | |
活気 | |
かっき | |
vigor; liveliness; vitality; energy | |
_________ | |
絶えず | |
たえず | |
constantly | |
_________ | |
(〜が)変化する | |
(〜が)へんかする | |
to change | |
_________ | |
魅力的(な) | |
みりょくてき(な) | |
attractive | |
_________ | |
都 | |
みやこ | |
city; capital | |
_________ | |
(〜に) 限る | |
(〜) would have to be the best choice [=〜がー番いい] | |
_________ | |
第二次世界大戦 | |
だいにじせかいだいせん | |
WWII | |
_________ | |
被害 | |
びがい | |
damage | |
_________ | |
お寺 | |
おてら | |
Buddhist temple | |
_________ | |
神社 | |
じんじゃ | |
Shinto shrine | |
_________ | |
見切れない | |
みきれない | |
I can't see them all | |
_________ | |
奈良 | |
なら | |
[place name] | |
_________ | |
大仏 | |
だいぶつ | |
big statue of Buddha | |
_________ | |
四国 | |
しこく | |
[smallest of the four main islands] | |
_________ | |
お城 | |
おしろ | |
castle | |
_________ | |
阿蘇山 | |
あそさん | |
Mt. Aso | |
_________ | |
桜島 | |
さくらじま | |
Mt. Sakurajima | |
_________ | |
火山 | |
かざん | |
volcano | |
_________ | |
各地 | |
かくち | |
various parts of the country | |
_________ | |
溫泉 | |
おんせん | |
hot spring | |
_________ | |
ゆっくり | |
leisurely`.split(` | |
_________ | |
`).map(x => x.split('\n\n', 2)).map(([front, back]) => `(async ({ cardType, nameOfDeck, data }) => { | |
const body = [ | |
["nid", ""], | |
["data", encodeURIComponent(JSON.stringify(data))], | |
["csrf_token", editor.token], | |
["mid", editor.mode.notetypes.find(({ name }) => name === cardType).id], | |
["deck", editor.mode.decks.find(({ name }) => name === nameOfDeck).id], | |
] | |
.map((x) => x.join("=")) | |
.join("&"); | |
const response = await fetch("https://ankiuser.net/edit/save", { | |
headers: { | |
"content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"x-requested-with": "XMLHttpRequest", | |
}, | |
body: body, | |
method: "POST", | |
credentials: "include", | |
}); | |
const json = await response.json(); | |
console.log('Success!'); | |
console.log(JSON.stringify(json, null, 2)); | |
setTimeout(() => window.location.reload(), 2000); | |
})({ | |
cardType: "Basic", | |
nameOfDeck: "AIAIJ Ch. 10 Tango Yomimono", | |
data: [ | |
[ | |
\`${front}\`, | |
\`${back}\`.replace(/\\n/g, '<br>'), | |
], | |
"", | |
], | |
}).catch((err) => console.error(err));`).join('\n\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment