You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/utils/CrackWallaby.ts

101 lines
2.8 KiB

import * as fs from "fs-extra-plus";
import { homedir } from "os";
import { join } from "path";
/**
可以将wallaby.js升级到最新的版本 然后在运行一次这个 ctrl+shift+= force update
*/
//1.先激活 后运行这个脚本
async function main()
{
let delFiles = [
join(homedir(), ".quokka/.qid"),
join(homedir(), ".quokka/state.json"),
join(homedir(), ".quokka/notifications.json"),
join(homedir(), ".wallaby/key.lic"),
join(homedir(), ".wallaby/notifications.json"),
];
for (let file of delFiles)
try
{
await fs.remove(file);//必须删除 更新试用的key
} catch { }
let wallabys = await fs.glob(["wallabyjs.wallaby-vscode*"], { cwd: join(homedir(), ".vscode\\extensions\\"), onlyDirectories: true });
for (let wallaby of wallabys)
{
try
{
let index = join(wallaby, "dist/index.js");
await fs.copy(index, join(wallaby, "dist/index_bak.js"));
let str = await fs.readFile(index, "utf-8");
if (str.includes("破解成功!自动续订!"))
{
console.log(`${wallaby} 已经破解过了!`);
continue;
};
str = str.replace(`this.on("notification",a=>{`,
`
this.on("notification",a=>{
a.text = "破解成功!自动续订!" + a.text;
this._continueTrial();
`);
await fs.writeFile(index, str);
if (str.includes("破解成功!自动续订!"))
console.log(`${wallaby} 破解成功!`);
else
console.log(`${wallaby} 破解失败!`);
} catch (error)
{
}
}
let quokkas = await fs.glob(["wallabyjs.quokka-vscode*"], { cwd: join(homedir(), ".vscode\\extensions\\"), onlyDirectories: true });
for (let quokka of quokkas)
{
try
{
let index = join(quokka, "dist/index.js");
let str = await fs.readFile(index, "utf-8");
if (str.includes("破解成功!自动续订!"))
{
console.log(`${quokka} 已经破解过了!`);
continue;
};
await fs.copy(index, join(quokka, "dist/index_bak.js"));
str = str.replace(`_showNotification(e,t){`,
`
_showNotification(e,t){
e.text = "破解成功!自动续订!" + e.text;
t.continueTrial();
`);
await fs.writeFile(index, str);
if (str.includes("破解成功!自动续订!"))
console.log(`${quokka} 破解成功!`);
else
console.log(`${quokka} 破解失败!`);
} catch (error)
{
}
}
console.log("破解完成!");
}
main();