diff --git a/3rdparty/qjs b/3rdparty/qjs index 0df5c90..3fb0770 160000 --- a/3rdparty/qjs +++ b/3rdparty/qjs @@ -1 +1 @@ -Subproject commit 0df5c90086d54d67bb1cd6dacee2d560e7e3efed +Subproject commit 3fb0770c9ee5ab031a56072520641d4577b694e3 diff --git a/main/NekoRay.cpp b/main/NekoRay.cpp index 3263ac8..6700500 100644 --- a/main/NekoRay.cpp +++ b/main/NekoRay.cpp @@ -66,7 +66,7 @@ namespace NekoRay { _add(new configItem("sp_format", &system_proxy_format, itemType::string)); _add(new configItem("sub_clear", &sub_clear, itemType::boolean)); _add(new configItem("sub_insecure", &sub_insecure, itemType::boolean)); - _add(new configItem("enable_js_hook", &enable_js_hook, itemType::boolean)); + _add(new configItem("enable_js_hook", &enable_js_hook, itemType::integer)); } void DataStore::UpdateStartedId(int id) { @@ -233,49 +233,42 @@ namespace NekoRay { switch (item->type) { case itemType::string: if (value.type() != QJsonValue::String) { - MessageBoxWarning("错误", "Not a string\n" + key); continue; } *(QString *) item->ptr = value.toString(); break; case itemType::integer: if (value.type() != QJsonValue::Double) { - MessageBoxWarning("错误", "Not a int\n" + key); continue; } *(int *) item->ptr = value.toInt(); break; case itemType::integer64: if (value.type() != QJsonValue::Double) { - MessageBoxWarning("错误", "Not a int64\n" + key); continue; } *(long long *) item->ptr = value.toDouble(); break; case itemType::boolean: if (value.type() != QJsonValue::Bool) { - MessageBoxWarning("错误", "Not a bool\n" + key); continue; } *(bool *) item->ptr = value.toBool(); break; case itemType::stringList: if (value.type() != QJsonValue::Array) { - MessageBoxWarning("错误", "Not a Array\n" + key); continue; } *(QList *) item->ptr = QJsonArray2QListString(value.toArray()); break; case itemType::integerList: if (value.type() != QJsonValue::Array) { - MessageBoxWarning("错误", "Not a Array\n" + key); continue; } *(QList *) item->ptr = QJsonArray2QListInt(value.toArray()); break; case itemType::jsonStore: if (value.type() != QJsonValue::Object) { - MessageBoxWarning("错误", "Not a json object\n" + key); continue; } if (load_control_no_jsonStore) diff --git a/main/NekoRay_DataStore.hpp b/main/NekoRay_DataStore.hpp index 94d354c..5eeafbc 100644 --- a/main/NekoRay_DataStore.hpp +++ b/main/NekoRay_DataStore.hpp @@ -86,7 +86,7 @@ namespace NekoRay { // Security bool insecure_hint = true; bool skip_cert = false; - bool enable_js_hook = false; + int enable_js_hook = 0; // Remember int remember_spmode = NekoRay::SystemProxyMode::DISABLE; diff --git a/main/QJS.cpp b/main/QJS.cpp index d3791a9..0a276bb 100644 --- a/main/QJS.cpp +++ b/main/QJS.cpp @@ -80,6 +80,7 @@ namespace NekoRay::qjs { this->neko_ctx = malloc(sizeof(nekoray_qjs_context)); nekoray_qjs_new_arg arg; arg.neko_ctx = NEKO_CTX; + arg.enable_std = NekoRay::dataStore->enable_js_hook == 2 ? 1 : 0; arg.func_log = func_log; nekoray_qjs_new(arg); #endif @@ -138,7 +139,7 @@ namespace NekoRay::qjs { QByteArray ReadHookJS() { #ifndef NKR_NO_QUICKJS - if (NekoRay::dataStore->enable_js_hook) { + if (NekoRay::dataStore->enable_js_hook > 0) { return ReadFile(QString("./hook.%1.js").arg(software_name.toLower())); } #endif diff --git a/ui/dialog_basic_settings.cpp b/ui/dialog_basic_settings.cpp index 82abc32..13f26d7 100644 --- a/ui/dialog_basic_settings.cpp +++ b/ui/dialog_basic_settings.cpp @@ -228,7 +228,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent) D_LOAD_BOOL(insecure_hint) D_LOAD_BOOL(skip_cert) - D_LOAD_BOOL(enable_js_hook) + ui->enable_js_hook->setCurrentIndex(NekoRay::dataStore->enable_js_hook); } DialogBasicSettings::~DialogBasicSettings() { @@ -279,7 +279,7 @@ void DialogBasicSettings::accept() { D_SAVE_BOOL(insecure_hint) D_SAVE_BOOL(skip_cert) - D_SAVE_BOOL(enable_js_hook) + NekoRay::dataStore->enable_js_hook = ui->enable_js_hook->currentIndex(); MW_dialog_message(Dialog_DialogBasicSettings, "UpdateDataStore"); QDialog::accept(); diff --git a/ui/dialog_basic_settings.ui b/ui/dialog_basic_settings.ui index 8b615ea..e723bba 100644 --- a/ui/dialog_basic_settings.ui +++ b/ui/dialog_basic_settings.ui @@ -579,10 +579,41 @@ - - - Enable hook.js + + + + 0 + 0 + + + + + + Enable hook.js + + + + + + + + Disable + + + + + Enable + + + + + Enable + load std module + + + + +