Add %URL parameter to use full image URL or thumbnail as appropriate for image search.

This commit is contained in:
ccd0 2015-03-14 20:24:56 -07:00
parent cca624bd29
commit c1428b7e09
3 changed files with 11 additions and 12 deletions

View File

@ -654,12 +654,12 @@ Config =
MD5: ''
sauces: """
https://www.google.com/searchbyimage?image_url=%TURL
http://iqdb.org/?url=%TURL
https://www.google.com/searchbyimage?image_url=%IMG
http://iqdb.org/?url=%IMG
http://eye.swfchan.com/search/?q=%name;types:swf
#//tineye.com/search?url=%TURL
#//saucenao.com/search.php?url=%TURL
#http://3d.iqdb.org/?url=%TURL
#//tineye.com/search?url=%IMG
#//saucenao.com/search.php?url=%IMG
#http://3d.iqdb.org/?url=%IMG
#http://regex.info/exif.cgi?imgurl=%URL
# uploaders:
#//imgur.com/upload?url=%URL;text:Upload to imgur
@ -671,9 +671,6 @@ Config =
#https://rbt.asia/%board/image/%MD5;text:View same on RBT /%board/;boards:<%=
grunt.file.readJSON('src/Archive/archives.json').filter(function(x) {return x.uid === 8})[0].files.join(',')
%>
# Search with full image only for image file types:
#https://www.google.com/searchbyimage?image_url=%URL;types:gif,jpg,png
#https://www.google.com/searchbyimage?image_url=%TURL;types:webm,pdf
"""
FappeT:

View File

@ -6,6 +6,7 @@
<ul>These parameters will be replaced by their corresponding values:
<li><code>%TURL</code>: Thumbnail URL.</li>
<li><code>%URL</code>: Full image URL.</li>
<li><code>%IMG</code>: Full image URL for GIF, JPG, and PNG; thumbnail URL for other types.</li>
<li><code>%MD5</code>: MD5 hash.</li>
<li><code>%name</code>: Original file name.</li>
<li><code>%board</code>: Current board.</li>

View File

@ -26,14 +26,16 @@ Sauce =
else
m = part.match /^(\w*):(.*)$/
parts[m[1]] = m[2]
parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
ext = post.file.URL.match(/[^.]*$/)[0]
skip = false
for key of parts
parts[key] = parts[key].replace /%(T?URL|MD5|board|name|%|semi)/g, (parameter) ->
parts[key] = parts[key].replace /%(T?URL|IMG|MD5|board|name|%|semi)/g, (parameter) ->
type = {
'%TURL': post.file.thumbURL
'%URL': post.file.URL
'%IMG': if ext in ['gif', 'jpg', 'png'] then post.file.URL else post.file.thumbURL
'%MD5': post.file.MD5
'%board': post.board.ID
'%name': post.file.name
@ -50,10 +52,9 @@ Sauce =
type
return null if skip
ext = post.file.URL.match(/\.([^\.]*)$/)?[1] or ''
return null unless !parts['boards'] or post.board.ID in parts['boards'].split ','
return null unless !parts['types'] or ext in parts['types'].split ','
a = Sauce.link.cloneNode true
a.href = parts['url']
a.textContent = parts['text']