Make rewriting of is.4chan.org links to i.4cdn.org optional (Use Faster Image Host option, default: true). #1141
This commit is contained in:
parent
f0f962ccdd
commit
3259517b0d
12
src/Images/ImageHost.coffee
Normal file
12
src/Images/ImageHost.coffee
Normal file
@ -0,0 +1,12 @@
|
||||
ImageHost =
|
||||
init: ->
|
||||
return unless Conf['Use Faster Image Host'] and g.VIEW in ['index', 'thread']
|
||||
Callbacks.Post.push
|
||||
name: 'Image Host Rewriting'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
return unless @file and not @isClone and (m = @file.url.match /^https?:\/\/is\.4chan\.org\/(.*)$/)
|
||||
@file.link.hostname = 'i.4cdn.org'
|
||||
@file.thumbLink.hostname = 'i.4cdn.org' if @file.thumbLink
|
||||
@file.url = @file.link.href
|
||||
@ -188,8 +188,6 @@ class Post
|
||||
return if not (link = $ '.fileText > a, .fileText-original > a', fileRoot)
|
||||
return if not (info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/)
|
||||
fileText = fileRoot.firstElementChild
|
||||
# XXX full images on https://is.4chan.org don't load
|
||||
link.hostname = 'i.4cdn.org' if link.hostname is 'is.4chan.org'
|
||||
@file =
|
||||
text: fileText
|
||||
link: link
|
||||
@ -205,8 +203,6 @@ class Post
|
||||
size *= 1024 while unit-- > 0
|
||||
@file.sizeInBytes = size
|
||||
if (thumb = $ 'a.fileThumb > [data-md5]', fileRoot)
|
||||
# XXX full images on https://is.4chan.org don't load
|
||||
thumb.parentNode.hostname = 'i.4cdn.org' if thumb.parentNode.hostname is 'is.4chan.org'
|
||||
$.extend @file,
|
||||
thumb: thumb
|
||||
thumbLink: thumb.parentNode
|
||||
|
||||
@ -184,6 +184,10 @@ Config =
|
||||
]
|
||||
|
||||
'Images and Videos':
|
||||
'Use Faster Image Host': [
|
||||
true
|
||||
'Change is.4chan.org links to point to the faster i.4cdn.org host.'
|
||||
]
|
||||
'Image Expansion': [
|
||||
true
|
||||
'Expand images / videos.'
|
||||
|
||||
@ -425,6 +425,7 @@ Main =
|
||||
['Board Configuration', BoardConfig]
|
||||
['Normalize URL', NormalizeURL]
|
||||
['Captcha Configuration', Captcha.replace]
|
||||
['Image Host Rewriting', ImageHost]
|
||||
['Redirect', Redirect]
|
||||
['Header', Header]
|
||||
['Catalog Links', CatalogLinks]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user