Skip to content

Commit

Permalink
Update WhatAnime to trace.moe
Browse files Browse the repository at this point in the history
See #5
  • Loading branch information
ccloli committed Oct 25, 2018
1 parent 9ae1843 commit 8b99e73
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 36 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ Search By Image | 以图搜图
>
> 另外,搜索贴吧内图片时,如果出现搜索的 url 为 base64 的情况,请看此贴:http://tieba.baidu.com/p/3145502558
更新历史:
更新历史:
> 2018.10.26 1.6.3 Update WhatAnime to `trace.moe` ([#5](https://github.com/ccloli/Search-By-Image/issues/5))
>
> 2018.03.04 1.6.2 Fix setting is not loaded; Fix previous fixes is not working (Fix GreasyFork [#31706](https://greasyfork.org/en/forum/discussion/31706/x), these bugs makes WhatAnime & Ascii2D save twice or more times.)
>
> 2018.02.27 1.6.1 Fix "All" search may broken due to not remove deleted search engines completely
>
> 2018.02.27 1.6 Add Ascii2D; Fix compatibility with GreaseMonkey 4.x
Expand Down
75 changes: 40 additions & 35 deletions search-by-image.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Search By Image
// @version 1.6.2
// @version 1.6.3
// @description Search By Image | 以图搜图
// @match <all_urls>
// @include *
Expand Down Expand Up @@ -43,7 +43,7 @@ var default_setting = {
"SauceNAO": "https://saucenao.com/search.php?db=999&url={%s}",
"IQDB": "https://iqdb.org/?url={%s}",
"3D IQDB": "https://3d.iqdb.org/?url={%s}",
"WhatAnime": "https://whatanime.ga/?url={%s}",
"WhatAnime": "https://trace.moe/?url={%s}",
"Ascii2D": "https://ascii2d.net/search/url/{%s}"
},
"site_option": ["Google", "Baidu", "Bing", "TinEye", "Yandex", "Sogou", "360 ShiTu", "SauceNAO", "IQDB", "3D IQDB", "WhatAnime", "Ascii2D"],
Expand Down Expand Up @@ -145,48 +145,53 @@ function init() {
data_version = v;
last_update = t;

if (data_version < 5) {
if (data_version < 4) {
var new_site_list = {};
var new_site_option = [];
if (data_version < 6) {
if (data_version < 5) {
if (data_version < 4) {
var new_site_list = {};
var new_site_option = [];

for (var i in setting.site_list) {
// use for loop to keep order, will use array in 2.x
switch (i) {
case 'Baidu ShiTu':
case 'Baidu Image':
new_site_list['Baidu'] = default_setting.site_list['Baidu'];
break;
for (var i in setting.site_list) {
// use for loop to keep order, will use array in 2.x
switch (i) {
case 'Baidu ShiTu':
case 'Baidu Image':
new_site_list['Baidu'] = default_setting.site_list['Baidu'];
break;

case 'Bing':
case 'Sogou':
new_site_list[i] = default_setting.site_list[i];
break;
case 'Bing':
case 'Sogou':
new_site_list[i] = default_setting.site_list[i];
break;

default:
new_site_list[i] = setting.site_list[i];
default:
new_site_list[i] = setting.site_list[i];
}
}
}
new_site_list['WhatAnime'] = default_setting.site_list['WhatAnime'];
new_site_list['WhatAnime'] = default_setting.site_list['WhatAnime'];

for (var i = 0; i < setting.site_option.length; i++) {
if ((setting.site_option[i] === 'Baidu ShiTu' || setting.site_option[i] === 'Baidu Image') && !(/,?Baidu,?/.test(new_site_option.join(',')))) {
new_site_option.push('Baidu');
}
else {
new_site_option.push(setting.site_option[i]);
for (var i = 0; i < setting.site_option.length; i++) {
if ((setting.site_option[i] === 'Baidu ShiTu' || setting.site_option[i] === 'Baidu Image') && !(/,?Baidu,?/.test(new_site_option.join(',')))) {
new_site_option.push('Baidu');
}
else {
new_site_option.push(setting.site_option[i]);
}
}
new_site_option.push('WhatAnime');

setting.site_list = new_site_list;
setting.site_option = new_site_option;
}
new_site_option.push('WhatAnime');

setting.site_list = new_site_list;
setting.site_option = new_site_option;
setting.site_list['Ascii2D'] = default_setting.site_list['Ascii2D'];
setting.site_option.push('Ascii2D');
}

setting.site_list['Ascii2D'] = default_setting.site_list['Ascii2D'];
setting.site_option.push('Ascii2D');
set_setting(setting);
GM_setValue('version', data_version = 5);
if (setting.site_list['WhatAnime']) {
setting.site_list['WhatAnime'] = default_setting.site_list['WhatAnime'];
set_setting(setting);
}
GM_setValue('version', data_version = 6);
}

var repeatTest = {};
Expand Down

0 comments on commit 8b99e73

Please sign in to comment.