Skip to content

Instantly share code, notes, and snippets.

@nonefffds
Last active July 7, 2025 09:20
Show Gist options
  • Select an option

  • Save nonefffds/532580aaa591d01f40c5d2c387fac129 to your computer and use it in GitHub Desktop.

Select an option

Save nonefffds/532580aaa591d01f40c5d2c387fac129 to your computer and use it in GitHub Desktop.
对加密的anki卡片内容解密
//本脚本参考了 https://oddpaw.com/2023/07/decrypt-anki-deck/
//非常感谢原作者的贡献
//本脚本仅供个人使用,请勿将获取他人的anki卡组解密后再次售卖
//本脚本适用于anki卡片模板里有 decryptBack() 的js函数的anki卡片,本质:使用了 https://www.jsjiami.com/jsjiami.v6.html 进行加密
//使用方法:在anki里使用chrome inspector打断点获得加密使用的key,在本脚本开头填入key,在本脚本末尾填入输入输出的txt路径
//保存本脚本为 anki-decryption.js 在终端内导航到脚本所在位置并输入 node ./anki-decryption.js
//如何打断点:(如果有时间再更新)
function akDecrypt(encryptedText) {
const key = "这里填写打断点获得的key";
const iv = "12345679abcdefgj";
return KKK['JJJ'].decrypt(encryptedText, KKK.enc.Utf8.parse(key), {
'iv': KKK.enc.Utf8.parse(iv),
'mode': KKK.mode.CBC,
'padding': KKK.pad.Pkcs7
}).toString(KKK.enc.Utf8);
}
//为了避免一些原因,请在这自行插入你找到的从
//KKK = KKK || function(u, p) {
//开始,一直到
//u.JJJ = p._createHelper(d)})();
//这里结束的大概715行的代码
const fs = require('fs');
const regex = /≯#.*?#≮/g;
function run(){
const content = fs.readFileSync('这里填写输入的txt文件路径', {encoding: 'utf-8'});
const rows = content.split('\n');
const results = [];
for(const row of rows){
const matches = row.match(regex);
if(!matches){
results.push(row);
continue;
}
let newRow = row;
for(const match of matches){
newRow = newRow.replace(match, akDecrypt(match.replace('≯#', '').replace('#≮', '')));
}
results.push(newRow);
}
fs.writeFileSync('这里填写输出的txt文件路径', results.join('\n'), {encoding: 'utf-8'})
}
run();