Add support for is2.4chan.org host.
This commit is contained in:
parent
a110d2f703
commit
c5f175ed13
@ -26,7 +26,8 @@
|
|||||||
"*://sys.4chan.org/*",
|
"*://sys.4chan.org/*",
|
||||||
"*://www.4chan.org/*",
|
"*://www.4chan.org/*",
|
||||||
"*://i.4cdn.org/*",
|
"*://i.4cdn.org/*",
|
||||||
"*://is.4chan.org/*"
|
"*://is.4chan.org/*",
|
||||||
|
"*://is2.4chan.org/*"
|
||||||
],
|
],
|
||||||
"matches_only": [
|
"matches_only": [
|
||||||
"*://*.4chan.org/*",
|
"*://*.4chan.org/*",
|
||||||
|
|||||||
@ -26,7 +26,7 @@ Build.Test =
|
|||||||
href = el.href
|
href = el.href
|
||||||
href = href.replace /(^\w+:\/\/boards.4chan.org\/[^\/]+\/thread\/\d+)\/.*/, '$1'
|
href = href.replace /(^\w+:\/\/boards.4chan.org\/[^\/]+\/thread\/\d+)\/.*/, '$1'
|
||||||
el.setAttribute 'href', href
|
el.setAttribute 'href', href
|
||||||
for el in $$ '.fileText > a, a.fileThumb', root2 when el.hostname is 'is.4chan.org'
|
for el in $$ '.fileText > a, a.fileThumb', root2 when ImageHost.regex.test(el.hostname)
|
||||||
el.hostname = 'i.4cdn.org'
|
el.hostname = 'i.4cdn.org'
|
||||||
for el in $$ 'img[src]', root2
|
for el in $$ 'img[src]', root2
|
||||||
el.src = el.src.replace /(spoiler-\w+)\d(\.png)$/, '$11$2'
|
el.src = el.src.replace /(spoiler-\w+)\d(\.png)$/, '$11$2'
|
||||||
|
|||||||
@ -34,7 +34,7 @@ ImageCommon =
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
isFromArchive: (file) ->
|
isFromArchive: (file) ->
|
||||||
file.src.split('/')[2] not in ['i.4cdn.org', 'is.4chan.org']
|
!Main.isImageHost(file.src.split('/')[2])
|
||||||
|
|
||||||
error: (file, post, delay, cb) ->
|
error: (file, post, delay, cb) ->
|
||||||
src = post.file.url.split '/'
|
src = post.file.url.split '/'
|
||||||
|
|||||||
@ -1,16 +1,21 @@
|
|||||||
ImageHost =
|
ImageHost =
|
||||||
init: ->
|
init: ->
|
||||||
return unless Conf['Use Faster Image Host'] and g.VIEW in ['index', 'thread']
|
return unless (@enabled = Conf['Use Faster Image Host'] and g.VIEW in ['index', 'thread'])
|
||||||
Callbacks.Post.push
|
Callbacks.Post.push
|
||||||
name: 'Image Host Rewriting'
|
name: 'Image Host Rewriting'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
|
regex: /^is\d*\.4chan\.org$/
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
return if @isClone
|
return if @isClone
|
||||||
if @file and (m = @file.url.match /^https?:\/\/is\d*\.4chan\.org\/(.*)$/)
|
if @file and ImageHost.regex.test(@file.url.split('/')[2])
|
||||||
@file.link.hostname = 'i.4cdn.org'
|
@file.link.hostname = 'i.4cdn.org'
|
||||||
@file.thumbLink.hostname = 'i.4cdn.org' if @file.thumbLink
|
@file.thumbLink.hostname = 'i.4cdn.org' if @file.thumbLink
|
||||||
@file.url = @file.link.href
|
@file.url = @file.link.href
|
||||||
for link in $$ 'a[href^="http://is.4chan.org/"], a[href^="https://is.4chan.org/"]', @nodes.comment
|
ImageHost.fixLinks $$('a', @nodes.comment)
|
||||||
|
|
||||||
|
fixLinks: (links) ->
|
||||||
|
for link in links when ImageHost.regex.test(link.hostname)
|
||||||
link.hostname = 'i.4cdn.org'
|
link.hostname = 'i.4cdn.org'
|
||||||
return
|
return
|
||||||
|
|||||||
@ -229,7 +229,7 @@ Embedding =
|
|||||||
controls: true
|
controls: true
|
||||||
preload: 'auto'
|
preload: 'auto'
|
||||||
src: a.dataset.href
|
src: a.dataset.href
|
||||||
loop: /^https?:\/\/(i\.4cdn|is\.4chan)\.org\//.test a.dataset.href
|
loop: Main.isImageHost a.dataset.href.split('/')[2]
|
||||||
$.on el, 'loadedmetadata', ->
|
$.on el, 'loadedmetadata', ->
|
||||||
if el.videoHeight is 0 and el.parentNode
|
if el.videoHeight is 0 and el.parentNode
|
||||||
$.replace el, Embedding.types.audio.el(a)
|
$.replace el, Embedding.types.audio.el(a)
|
||||||
|
|||||||
@ -14,10 +14,11 @@ Linkify =
|
|||||||
node: ->
|
node: ->
|
||||||
return Embedding.events @ if @isClone
|
return Embedding.events @ if @isClone
|
||||||
return unless Linkify.regString.test @info.comment
|
return unless Linkify.regString.test @info.comment
|
||||||
for link in $$ 'a[href^="http://i.4cdn.org/"], a[href^="https://i.4cdn.org/"], a[href^="http://is.4chan.org/"], a[href^="https://is.4chan.org/"]', @nodes.comment
|
for link in $$ 'a', @nodes.comment when Main.isImageHost link.hostname
|
||||||
$.addClass link, 'linkify'
|
$.addClass link, 'linkify'
|
||||||
Embedding.process link, @
|
Embedding.process link, @
|
||||||
links = Linkify.process @nodes.comment
|
links = Linkify.process @nodes.comment
|
||||||
|
ImageHost.fixLinks links if ImageHost.enabled
|
||||||
Embedding.process link, @ for link in links
|
Embedding.process link, @ for link in links
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@ -290,7 +290,7 @@ Config =
|
|||||||
]
|
]
|
||||||
'Use Faster Image Host': [
|
'Use Faster Image Host': [
|
||||||
true
|
true
|
||||||
'Change is.4chan.org links to point to the faster i.4cdn.org host.'
|
'Change is*.4chan.org links to point to the faster i.4cdn.org host.'
|
||||||
]
|
]
|
||||||
|
|
||||||
'Menu':
|
'Menu':
|
||||||
|
|||||||
@ -129,23 +129,24 @@ Main =
|
|||||||
else if pathname[2] is 'post'
|
else if pathname[2] is 'post'
|
||||||
PostSuccessful.init()
|
PostSuccessful.init()
|
||||||
return
|
return
|
||||||
when 'i.4cdn.org', 'is.4chan.org'
|
|
||||||
return unless pathname[2] and not /[sm]\.jpg$/.test(pathname[2])
|
if Main.isImageHost hostname
|
||||||
$.asap (-> d.readyState isnt 'loading'), ->
|
return unless pathname[2] and not /[sm]\.jpg$/.test(pathname[2])
|
||||||
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
|
$.asap (-> d.readyState isnt 'loading'), ->
|
||||||
Redirect.navigate 'file', {
|
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
|
||||||
boardID: g.BOARD.ID
|
Redirect.navigate 'file', {
|
||||||
filename: pathname[pathname.length - 1]
|
boardID: g.BOARD.ID
|
||||||
}
|
filename: pathname[pathname.length - 1]
|
||||||
else if video = $ 'video'
|
}
|
||||||
if Conf['Volume in New Tab']
|
else if video = $ 'video'
|
||||||
Volume.setup video
|
if Conf['Volume in New Tab']
|
||||||
if Conf['Loop in New Tab']
|
Volume.setup video
|
||||||
video.loop = true
|
if Conf['Loop in New Tab']
|
||||||
video.controls = false
|
video.loop = true
|
||||||
video.play()
|
video.controls = false
|
||||||
ImageCommon.addControls video
|
video.play()
|
||||||
return
|
ImageCommon.addControls video
|
||||||
|
return
|
||||||
|
|
||||||
return unless hostname is 'boards.4chan.org'
|
return unless hostname is 'boards.4chan.org'
|
||||||
|
|
||||||
@ -410,6 +411,9 @@ Main =
|
|||||||
url = "<%= meta.newIssue.replace('%title', '#{encodeURIComponent title}').replace('%details', '#{encodeURIComponent details}') %>"
|
url = "<%= meta.newIssue.replace('%title', '#{encodeURIComponent title}').replace('%details', '#{encodeURIComponent details}') %>"
|
||||||
<%= html('<span class="report-error"> [<a href="${url}" target="_blank">report</a>]</span>') %>
|
<%= html('<span class="report-error"> [<a href="${url}" target="_blank">report</a>]</span>') %>
|
||||||
|
|
||||||
|
isImageHost: (hostname) ->
|
||||||
|
hostname is 'i.4cdn.org' or /^is\d*\.4chan\.org$/.test(hostname)
|
||||||
|
|
||||||
isThisPageLegit: ->
|
isThisPageLegit: ->
|
||||||
# 404 error page or similar.
|
# 404 error page or similar.
|
||||||
unless 'thisPageIsLegit' of Main
|
unless 'thisPageIsLegit' of Main
|
||||||
|
|||||||
@ -34,8 +34,8 @@
|
|||||||
).join('\n');
|
).join('\n');
|
||||||
})()
|
})()
|
||||||
%>
|
%>
|
||||||
// @connect i.4cdn.org
|
// @connect 4chan.org
|
||||||
// @connect is.4chan.org
|
// @connect 4cdn.org
|
||||||
// @connect *
|
// @connect *
|
||||||
<%=
|
<%=
|
||||||
meta.grants.map(function(grant) {
|
meta.grants.map(function(grant) {
|
||||||
|
|||||||
@ -14,7 +14,8 @@ CrossOrigin =
|
|||||||
# XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310
|
# XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310
|
||||||
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
|
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
|
||||||
<% if (type === 'crx') { %>
|
<% if (type === 'crx') { %>
|
||||||
if url.split('/')[...3].join('/') in ["#{location.protocol}//i.4cdn.org", "#{location.protocol}//is.4chan.org"]
|
parts = url.split '/'
|
||||||
|
if parts[0] is location.protocol and parts[1] is '' and Main.isImageHost(parts[2])
|
||||||
xhr = new XMLHttpRequest()
|
xhr = new XMLHttpRequest()
|
||||||
xhr.open 'GET', url, true
|
xhr.open 'GET', url, true
|
||||||
xhr.setRequestHeader key, value for key, value of headers
|
xhr.setRequestHeader key, value for key, value of headers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user