Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harytfw committed Sep 30, 2017
1 parent 638232b commit 9f6199b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 6 deletions.
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@
"message": "Chinese",
"description": "Select box classes on Options - Search Template"
},
"elem_SearchTemplateClasses_Image": {
"message": "Image",
"description": "Select box classes on Options - Search Template"
},
"elem_SearchTemplateClasses_ImageSearch": {
"message": "Image(upload file)",
"description": "Select box classes on Options - Search Template"
Expand Down
4 changes: 4 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@
"message": "中文",
"description": "Select box classes on Options - Search Template"
},
"elem_SearchTemplateClasses_Image": {
"message": "图片",
"description": "Select box classes on Options - Search Template"
},
"elem_SearchTemplateClasses_ImageSearch": {
"message": "图片(上传文件)",
"description": "Select box classes on Options - Search Template"
Expand Down
4 changes: 4 additions & 0 deletions _locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@
"message": "中文",
"description": "Select box classes on Options - Search Template"
},
"elem_SearchTemplateClasses_Image": {
"message": "圖片",
"description": "Select box classes on Options - Search Template"
},
"elem_SearchTemplateClasses_ImageSearch": {
"message": "圖片(上傳檔案)",
"description": "Select box classes on Options - Search Template"
Expand Down
16 changes: 15 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class ExecutorClass {
}
break;
case commons.ACT_SEARCH:

if (this.data.actionType === "linkAction") {
if (this.action.search_type === commons.SEARCH_IMAGE_LINK && this.data.imageLink !== "") {
this.searchText(this.data.imageLink);
Expand All @@ -184,6 +185,9 @@ class ExecutorClass {
this.searchText(this.data.selection);
}
}
else if (this.data.actionType === "imageAction") {
this.searchImage(this.data.selection);
}
else if (this.action.search_type === commons.SEARCH_TEXT) {
this.searchText(this.data.textSelection);
}
Expand Down Expand Up @@ -333,7 +337,11 @@ class ExecutorClass {
// "%x":`${keyword} site:${this.data.domain}`,
// }
let url = config.getSearchURL(this.action.engine_name)
if (this.action.search_onsite === commons.SEARCH_ONSITE_YES) {
if (url.startsWith("{redirect.html}")) {
this.searchImage(keyword);
return;
}
if (this.action.search_onsite === commons.SEARCH_ONSITE_YES && this.data.actionType !== "imageAction") {
url = url.replace("%s", "%x");
}
this.openTab(
Expand All @@ -354,6 +362,12 @@ class ExecutorClass {
}

openRedirectPage(params) {
if ("fileInfo" in this.data === false) {
this.data.fileInfo = {
name: "example.jpg",
type: "image/jpeg",
}
}
if (typeof params === "string") {
this.openTab(REDIRECT_URL + params + `&fileName=${this.data.fileInfo.name}&fileType=${this.data.fileInfo.type}`);
}
Expand Down
2 changes: 1 addition & 1 deletion default_config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//TODO:减少全局变量,修改变量名
const ACTION_CONSTRUCTOR = (parameter = {}) => {
return Object.assign({ act_name: commons.ACT_OPEN, tab_active: commons.BACK_GROUND, tab_pos: commons.TAB_LAST, engine_name: "", open_type: "", search_type: "", copy_type: "", download_type: "", download_directory: [], download_saveas: commons.DOWNLOAD_SAVEAS_YES, search_onsite: commons.SEARCH_ONSITE_YES }, parameter)
return Object.assign({ act_name: commons.ACT_OPEN, tab_active: commons.BACK_GROUND, tab_pos: commons.TAB_LAST, engine_name: "", open_type: commons.OPEN_LINK, search_type: commons.SEARCH_TEXT, copy_type: commons.COPY_TEXT, download_type: commons.DOWNLOAD_LINK, download_directory: [], download_saveas: commons.DOWNLOAD_SAVEAS_YES, search_onsite: commons.SEARCH_ONSITE_NO }, parameter)
}
const GENERATE_DEFAULT_CONFIG = () => {

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "__MSG_extensionDescription__",
"manifest_version": 2,
"name": "__MSG_extensionName__",
"version": "1.52.0b2",
"version": "1.52.0",
"homepage_url": "https://github.com/harytfw/GlitterDrag",
"icons": {
"48": "Drag.png",
Expand Down
1 change: 1 addition & 0 deletions options/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ a:visited {
border-radius: 4px;
margin-right: 15px;
margin-bottom: 15px;
width: 60%;
}

#actions>div>div>label {
Expand Down
9 changes: 6 additions & 3 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@
<option value="https://en.wikipedia.org/wiki/%s">Wikipedia (English)</option>
<option value="https://www.amazon.com/s/?field-keywords=%s">Amazon Search</option>
<option value="https://www.qwant.com/?q=%s&t=all">Qwant Search</option>
<option value="https://www.google.com/searchbyimage?image_url=%s">Google Image</option>
<option value="https://tineye.com/search/?url=%s">Tineye</option>
<option value="https://www.yandex.com/images/search?url=%s&rpt=imageview">Yandex Image</option>
</select>
<select style="display:inline-block">
<option selected="selected" disabled="disabled" data-i18n="SearchTemplateClasses_Chinese">Chinese</option>
Expand All @@ -93,6 +90,12 @@
<option value="https://www.douban.com/search?q=">豆瓣搜索</option>
<option value="https://www.zhihu.com/search?q=%s">知乎搜索</option>
<option value="https://zh.wikipedia.org/wiki/%s">中文维基百科</option>
</select>
<select style="display:inline-block">
<option selected="selected" disabled="disabled" data-i18n="SearchTemplateClasses_Image">Image</option>
<option value="https://www.google.com/searchbyimage?image_url=%s">Google Image</option>
<option value="https://tineye.com/search/?url=%s">Tineye</option>
<option value="https://www.yandex.com/images/search?url=%s&rpt=imageview">Yandex Image</option>
<option value="http://image.baidu.com/n/pc_search?queryImageUrl=%s">百度图片</option>
</select>
<select style="display:inline-block">
Expand Down

0 comments on commit 9f6199b

Please sign in to comment.