|
6 | 6 | // @description Powerful picture viewing tool online, which can popup/scale/rotate/batch save pictures or find the HD original picture automatically |
7 | 7 | // @description:zh-CN NLF 的围观图修改版,增加高清原图查找显示(在线看图工具,支持图片翻转、旋转、缩放、弹出大图、批量保存、查找原图) |
8 | 8 | // @description:zh-TW NLF 的圍觀圖修改版,增加高清原圖查詢顯示(線上看圖工具,支援圖片翻轉、旋轉、縮放、彈出大圖、批量儲存、查詢原圖) |
9 | | -// @version 2017.2.27.1 |
| 9 | +// @version 2017.3.2.1 |
10 | 10 | // @created 2011-6-15 |
11 | 11 | // @namespace http://userscripts.org/users/NLF |
12 | 12 | // @homepage http://hoothin.com |
|
39 | 39 | ;(function(topObject,window,document,unsafeWindow){ |
40 | 40 | 'use strict'; |
41 | 41 |
|
| 42 | + var prefs; |
42 | 43 | function init(topObject,window,document,arrayFn,envir,storage,unsafeWindow){ |
43 | | - |
44 | 44 | // 默认设置,请到设置界面修改 |
45 | | - var prefs={ |
| 45 | + prefs={ |
46 | 46 | floatBar:{//浮动工具栏相关设置. |
47 | 47 | butonOrder:['actual','gallery','magnifier','current','search'],//按钮排列顺序'actual'(实际的图片),'current'(当前显示的图片),'magnifier'(放大镜观察),'gallery'(图集) |
48 | 48 | showDelay:366,//浮动工具栏显示延时.单位(毫秒) |
|
134 | 134 | // lowLevel: true, // 如果有多个图片,优先选择低一级的 |
135 | 135 |
|
136 | 136 | debug: false, |
| 137 | + firstEngine:"Tineye" |
137 | 138 | }; |
138 | 139 |
|
139 | 140 | //各网站高级规则; |
@@ -4928,6 +4929,7 @@ left:0px;\ |
4928 | 4929 | setSearchState(""); |
4929 | 4930 | } |
4930 | 4931 | searchButton.addEventListener('click',function(e){ |
| 4932 | + sortSearch(); |
4931 | 4933 | searchImgByImg(self.img.src, function(srcs, index){ |
4932 | 4934 | from=index; |
4933 | 4935 | self.srcs=srcs; |
@@ -6504,6 +6506,7 @@ background-color:rgba(255, 0, 0, 0.150);\ |
6504 | 6506 | } else { |
6505 | 6507 | if (!this.data.xhr) { |
6506 | 6508 | if(this.buttonType == 'search'){ |
| 6509 | + sortSearch(); |
6507 | 6510 | let from=0; |
6508 | 6511 | let searchFun=function(){ |
6509 | 6512 | console.log(self.data.imgSrc); |
@@ -8170,6 +8173,16 @@ background-image:url("'+ prefs.icons.magnifier +'");\ |
8170 | 8173 | type: 'checkbox', |
8171 | 8174 | "default": prefs.debug |
8172 | 8175 | }, |
| 8176 | + 'firstEngine': { |
| 8177 | + label: '首选搜图引擎', |
| 8178 | + type: 'select', |
| 8179 | + options: { |
| 8180 | + "Tineye":"Tineye", |
| 8181 | + "Google":"Google", |
| 8182 | + "Baidu":"Baidu" |
| 8183 | + }, |
| 8184 | + "default": prefs.firstEngine, |
| 8185 | + }, |
8173 | 8186 | }, |
8174 | 8187 | events: { |
8175 | 8188 | open: function(doc, win, frame) { |
@@ -8345,6 +8358,16 @@ background-image:url("'+ prefs.icons.magnifier +'");\ |
8345 | 8358 | } |
8346 | 8359 |
|
8347 | 8360 | var searchSort=["Tineye","Google","Baidu"]; |
| 8361 | + function sortSearch(){ |
| 8362 | + for(var i=0;i<searchSort.length;i++){ |
| 8363 | + if(searchSort[i]==prefs.firstEngine){ |
| 8364 | + searchSort.splice(i,1); |
| 8365 | + break; |
| 8366 | + } |
| 8367 | + } |
| 8368 | + searchSort.unshift(prefs.firstEngine); |
| 8369 | + } |
| 8370 | + |
8348 | 8371 | function searchImgByImg(imgSrc, callBack, onError, noneResult, searchFrom){ |
8349 | 8372 | let srcs=[]; |
8350 | 8373 | var searchBaidu=function(){ |
@@ -8381,7 +8404,7 @@ background-image:url("'+ prefs.icons.magnifier +'");\ |
8381 | 8404 | }; |
8382 | 8405 | var searchGoogle=function(){ |
8383 | 8406 | setSearchState("谷歌识图开始……"); |
8384 | | - getUrl("https://www.google.com/searchbyimage?image_url="+encodeURIComponent(imgSrc), function(d){ |
| 8407 | + getUrl("https://www.google.com/searchbyimage?safe=off&image_url="+encodeURIComponent(imgSrc), function(d){ |
8385 | 8408 | let googleHtml=document.implementation.createHTMLDocument(''); |
8386 | 8409 | googleHtml.documentElement.innerHTML = d.responseText; |
8387 | 8410 | let sizeUrl=googleHtml.querySelector("div.card-section>div>div>span.gl>a"); |
|
0 commit comments