|
@@ -137,13 +137,16 @@ function import_ssr_url(btn, urlname, sid) {
|
|
|
var serverInfo = temp[0].split(":");
|
|
|
var server = serverInfo[0];
|
|
|
var port = serverInfo[1].replace("/","");
|
|
|
- var method, password, plugin, pluginOpts;
|
|
|
+ var method, password, enable_plugin, plugin, pluginOpts;
|
|
|
if (temp[1]) {
|
|
|
var pluginInfo = decodeURIComponent(temp[1]);
|
|
|
- var pluginIndex = pluginInfo.indexOf(";");
|
|
|
- var pluginNameInfo = pluginInfo.substr(0, pluginIndex);
|
|
|
- plugin = pluginNameInfo.substr(pluginNameInfo.indexOf("=") + 1);
|
|
|
- pluginOpts = pluginInfo.substr(pluginIndex + 1);
|
|
|
+ // 使用正則匹配 plugin 參數
|
|
|
+ var pluginNameInfo = pluginInfo.match(/plugin=([^&]+)/);
|
|
|
+ if (pluginNameInfo) {
|
|
|
+ var pluginParams = pluginNameInfo[1].split(";");
|
|
|
+ plugin = pluginParams.shift(); // 获取 plugin
|
|
|
+ pluginOpts = pluginParams.length > 0 ? pluginParams.join(";") : "";
|
|
|
+ }
|
|
|
}
|
|
|
var userInfoSplitIndex = userInfo.indexOf(":");
|
|
|
if (userInfoSplitIndex != -1) {
|
|
@@ -156,12 +159,19 @@ function import_ssr_url(btn, urlname, sid) {
|
|
|
document.getElementsByName('cbid.shadowsocksr.' + sid + '.server_port')[0].value = port;
|
|
|
document.getElementsByName('cbid.shadowsocksr.' + sid + '.password')[0].value = password || "";
|
|
|
document.getElementsByName('cbid.shadowsocksr.' + sid + '.encrypt_method_ss')[0].value = method || "";
|
|
|
- document.getElementsByName('cbid.shadowsocksr.' + sid + '.plugin')[0].value = plugin || "none";
|
|
|
- document.getElementsByName('cbid.shadowsocksr.' + sid + '.plugin')[0].dispatchEvent(event);
|
|
|
- if (plugin != undefined) {
|
|
|
- document.getElementsByName('cbid.shadowsocksr.' + sid + '.plugin_opts')[0].value = pluginOpts || "";
|
|
|
+ if (plugin && plugin !== "none") {
|
|
|
+ document.getElementsByName('cbid.shadowsocksr.' + sid + '.enable_plugin')[0].checked = true; // 设置 enable_plugin 为 true
|
|
|
+ document.getElementsByName('cbid.shadowsocksr.' + sid + '.enable_plugin')[0].dispatchEvent(event); // 触发事件
|
|
|
+
|
|
|
+ document.getElementsByName('cbid.shadowsocksr.' + sid + '.plugin')[0].value = plugin || "none";
|
|
|
+ document.getElementsByName('cbid.shadowsocksr.' + sid + '.plugin')[0].dispatchEvent(event);
|
|
|
+ if (plugin !== undefined) {
|
|
|
+ document.getElementsByName('cbid.shadowsocksr.' + sid + '.plugin_opts')[0].value = pluginOpts || "";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ document.getElementsByName('cbid.shadowsocksr.' + sid + '.enable_plugin')[0].checked = false;
|
|
|
}
|
|
|
- if (param != undefined) {
|
|
|
+ if (param !== undefined) {
|
|
|
document.getElementsByName('cbid.shadowsocksr.' + sid + '.alias')[0].value = decodeURI(param);
|
|
|
}
|
|
|
s.innerHTML = "<font style=\'color:green\'><%:Import configuration information successfully.%></font>";
|
|
@@ -518,3 +528,4 @@ function import_ssr_url(btn, urlname, sid) {
|
|
|
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Import%>" onclick="return import_ssr_url(this, '<%=self.option%>', '<%=self.value%>')" />
|
|
|
<span id="<%=self.option%>-status"></span>
|
|
|
<%+cbi/valuefooter%>
|
|
|
+
|