diff --git a/core/plugins/plugin.qq.com.go b/core/plugins/plugin.qq.com.go index 11551cb..394fdd7 100644 --- a/core/plugins/plugin.qq.com.go +++ b/core/plugins/plugin.qq.com.go @@ -14,6 +14,9 @@ import ( "strings" ) +var qqMediaRegex = regexp.MustCompile(`get\s*media\(\)\{`) +var qqCommentRegex = regexp.MustCompile(`async\s*finderGetCommentDetail\((\w+)\)\s*\{return(.*?)\s*}\s*async`) + type QqPlugin struct { bridge *shared.Bridge } @@ -72,7 +75,7 @@ func (p *QqPlugin) OnResponse(resp *http.Response, ctx *goproxy.ProxyCtx) *http. return respTemp } bodyStr := string(body) - newBody := regexp.MustCompile(`get\s*media\(\)\{`). + newBody := qqMediaRegex. ReplaceAllString(bodyStr, ` get media(){ if(this.objectDesc){ @@ -85,7 +88,7 @@ func (p *QqPlugin) OnResponse(resp *http.Response, ctx *goproxy.ProxyCtx) *http. `) - newBody = regexp.MustCompile(`async\s*finderGetCommentDetail\((\w+)\)\s*\{return(.*?)\s*}\s*async`). + newBody = qqCommentRegex. ReplaceAllString(newBody, ` async finderGetCommentDetail($1) { var res = await$2; diff --git a/core/resource.go b/core/resource.go index 82d91bb..1ea24ec 100644 --- a/core/resource.go +++ b/core/resource.go @@ -28,23 +28,26 @@ type Resource struct { func initResource() *Resource { if resourceOnce == nil { - resourceOnce = &Resource{ - resType: map[string]bool{ - "all": true, - "image": true, - "audio": true, - "video": true, - "m3u8": true, - "live": true, - "xls": true, - "doc": true, - "pdf": true, - }, - } + resourceOnce = &Resource{} + resourceOnce.resType = resourceOnce.buildResType(globalConfig.MimeMap) } return resourceOnce } +func (r *Resource) buildResType(mime map[string]MimeInfo) map[string]bool { + t := map[string]bool{ + "all": true, + } + + for _, item := range mime { + if _, ok := t[item.Type]; !ok { + t[item.Type] = true + } + } + + return t +} + func (r *Resource) mediaIsMarked(key string) bool { _, loaded := r.mediaMark.Load(key) return loaded @@ -63,22 +66,16 @@ func (r *Resource) getResType(key string) (bool, bool) { func (r *Resource) setResType(n []string) { r.resTypeMux.Lock() - defer r.resTypeMux.Unlock() - r.resType = map[string]bool{ - "all": false, - "image": false, - "audio": false, - "video": false, - "m3u8": false, - "live": false, - "xls": false, - "doc": false, - "pdf": false, + for key := range r.resType { + r.resType[key] = false } for _, value := range n { - r.resType[value] = true + if _, ok := r.resType[value]; ok { + r.resType[value] = true + } } + r.resTypeMux.Unlock() } func (r *Resource) clear() { diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index cc3ebd1..995c5df 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -98,7 +98,7 @@ "connections_tip": "Keep default if unsure, usually CPU cores * 2, for faster downloads", "use_headers_tip": "Define headers for downloads, comma separated", "mime_map": "Intercept Rules", - "mime_map_tip": "JSON format, keep default if unsure" + "mime_map_tip": "JSON format, keep default if unsure, please restart software after modification" }, "footer": { "title": "About Us", diff --git a/frontend/src/locales/zh.json b/frontend/src/locales/zh.json index 029e112..1d04229 100644 --- a/frontend/src/locales/zh.json +++ b/frontend/src/locales/zh.json @@ -83,7 +83,7 @@ "filename_rules": "文件命名", "filename_rules_tip": "输入框控制文件命名的长度(不含时间、0为无效,此选项有描述信息时有效),开关控制文件末尾是否添加时间标识", "auto_proxy": "自动拦截", - "auto_proxy_tip": "打开软件时动启用拦截", + "auto_proxy_tip": "打开软件时自动启用拦截", "quality": "清晰度", "quality_value": "默认(推荐),超清,高画质,中画质,低画质", "quality_tip": "视频号有效", @@ -98,7 +98,7 @@ "connections_tip": "如不清楚请保持默认,通常CPU核心数*2,用于加速下载", "use_headers_tip": "定义下载时可使用的header参数,逗号分割", "mime_map": "拦截规则", - "mime_map_tip": "json格式,如果不清楚保持默认就行" + "mime_map_tip": "json格式,如果不清楚保持默认就行,修改后请重启软件" }, "footer": { "title": "关于我们", diff --git a/frontend/src/views/index.vue b/frontend/src/views/index.vue index d367cc6..c2d7cf8 100644 --- a/frontend/src/views/index.vue +++ b/frontend/src/views/index.vue @@ -84,7 +84,7 @@ const classifyAlias: { [key: string]: any } = { m3u8: computed(() => t("index.m3u8")), live: computed(() => t("index.live")), xls: computed(() => t("index.xls")), - doc: computed(() => t("index.pdf")), + doc: computed(() => t("index.doc")), pdf: computed(() => t("index.pdf")), font: computed(() => t("index.font")) }