diff --git a/src/General/Config.coffee b/src/General/Config.coffee
index f0b3d768d..85bf7c99b 100755
--- a/src/General/Config.coffee
+++ b/src/General/Config.coffee
@@ -520,16 +520,18 @@ Config =
https://www.google.com/searchbyimage?image_url=%TURL
http://iqdb.org/?url=%TURL
#//tineye.com/search?url=%TURL
-#http://saucenao.com/search.php?url=%TURL
+#//saucenao.com/search.php?url=%TURL
#http://3d.iqdb.org/?url=%TURL
#http://regex.info/exif.cgi?imgurl=%URL
# uploaders:
-#http://imgur.com/upload?url=%URL;text:Upload to imgur
-#http://ompldr.org/upload?url1=%URL;text:Upload to ompldr
+#//imgur.com/upload?url=%URL;text:Upload to imgur
# "View Same" in archives:
#//archive.foolz.us/_/search/image/%MD5/;text:View same on foolz
-#//archive.foolz.us/%board/search/image/%MD5/;text:View same on foolz /%board/
-#//archive.installgentoo.net/%board/image/%MD5;text:View same on installgentoo /%board/
+#//archive.foolz.us/%board/search/image/%MD5/;text:View same on foolz /%board/;boards:a,biz,c,co,diy,gd,int,jp,m,out,po,sci,sp,tg,tv,vg,vp,vr,wsg
+#https://rbt.asia/%board/image/%MD5;text:View same on rebeccablacktech /%board/;boards:cgl,con,g,mu,w
+# 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:
diff --git a/src/General/html/Settings/Sauce.html b/src/General/html/Settings/Sauce.html
index 7bdd83d7d..9ec3d3762 100755
--- a/src/General/html/Settings/Sauce.html
+++ b/src/General/html/Settings/Sauce.html
@@ -1,12 +1,14 @@
Sauce is disabled.
Lines starting with a # will be ignored.
You can specify a display text by appending ;text:[text] to the URL.
+You can specify the applicable boards by appending ;boards:board1,board2.
+You can specify the applicable file types by appending ;types:extension1,extension2.
These parameters will be replaced by their corresponding values:
%TURL: Thumbnail URL.
%URL: Full image URL.
%MD5: MD5 hash.
%name: Original file name.
%board: Current board.
- %%: Literal %.
+ %%, %semi: Literal % and ;.
diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee
index 2507ab53d..75f50c234 100755
--- a/src/Images/Sauce.coffee
+++ b/src/Images/Sauce.coffee
@@ -14,12 +14,15 @@ Sauce =
Post.callbacks.push
name: 'Sauce'
cb: @node
- createSauceLink: (link, post, a) ->
- text = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)?[1] or '?'
- link = link.replace /;text:.+$/, ''
- parts = [link, text]
- for i in [0..1]
- parts[i] = parts[i].replace /%(T?URL|MD5|board|name|%)/g, (parameter) ->
+ createSauceLink: (link, post) ->
+ parts = {}
+ for part in link.split ';'
+ m = part.match /^(?:(url|text|boards|types):)?(.*)$/
+ parts[m[1] or 'url'] = m[2]
+ parts['url'] or= 'javascript:;'
+ parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
+ for key of parts
+ parts[key] = parts[key].replace /%(T?URL|MD5|board|name|%|semi)/g, (parameter) ->
type = {
'%TURL': post.file.thumbURL
'%URL': post.file.URL
@@ -27,18 +30,25 @@ Sauce =
'%board': post.board
'%name': post.file.name
'%%': '%'
+ '%semi': ';'
}[parameter]
- if i is 0 and parameter isnt '%%'
+ if key is 'url' and parameter isnt '%%' and parameter isnt '%semi'
encodeURIComponent type
else
type
- a.href = parts[0]
- a.textContent = parts[1]
- a
+ ext = post.file.URL.match(/\.([^\.]*)$/)?[1] or ''
+ if (!parts['boards'] or post.board.ID in parts['boards'].split ',') and (!parts['types'] or ext in parts['types'].split ',')
+ a = Sauce.link.cloneNode true
+ a.href = parts['url']
+ a.textContent = parts['text']
+ a
+ else
+ null
node: ->
return if @isClone or !@file
nodes = []
for link in Sauce.links
- # \u00A0 is nbsp
- nodes.push $.tn('\u00A0'), (Sauce.createSauceLink link, @, Sauce.link.cloneNode true)
+ if node = Sauce.createSauceLink link, @
+ # \u00A0 is nbsp
+ nodes.push $.tn('\u00A0'), node
$.add @file.text, nodes