add boards and types options to sauce links; update example list
This commit is contained in:
parent
3fa001636d
commit
7e7645bf1a
@ -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:
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
<div class=warning><code>Sauce</code> is disabled.</div>
|
||||
<div>Lines starting with a <code>#</code> will be ignored.</div>
|
||||
<div>You can specify a display text by appending <code>;text:[text]</code> to the URL.</div>
|
||||
<div>You can specify the applicable boards by appending <code>;boards:board1,board2</code>.</div>
|
||||
<div>You can specify the applicable file types by appending <code>;types:extension1,extension2</code>.</div>
|
||||
<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>%MD5</code>: MD5 hash.</li>
|
||||
<li><code>%name</code>: Original file name.</li>
|
||||
<li><code>%board</code>: Current board.</li>
|
||||
<li><code>%%</code>: Literal <code>%</code>.</li>
|
||||
<li><code>%%</code>, <code>%semi</code>: Literal <code>%</code> and <code>;</code>.</li>
|
||||
</ul>
|
||||
<textarea name=sauces class=field spellcheck=false></textarea>
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user