Support 4cdn.

This commit is contained in:
Mayhem 2013-11-21 23:08:10 +01:00
parent 16a21fd087
commit 985afb2a1a
17 changed files with 28 additions and 27 deletions

View File

@ -1,4 +1,5 @@
- **New option**: `Auto-hide header on scroll`.
- Added support for `4cdn.org`.
## 3.13.0 - *2013-11-16*

View File

@ -9,10 +9,10 @@
"buildsPath": "builds/",
"mainBranch": "v3",
"matches": [
"*://api.4chan.org/*",
"*://boards.4chan.org/*",
"*://images.4chan.org/*",
"*://sys.4chan.org/*"
"*://sys.4chan.org/*",
"*://a.4cdn.org/*",
"*://i.4cdn.org/*"
],
"min": {
"chrome": "29",

View File

@ -58,7 +58,7 @@ ThreadHiding =
# We need to clean hidden threads on the catalog ourselves,
# otherwise if we don't visit the catalog regularly
# it will pollute the localStorage and our data.
$.cache "//api.4chan.org/#{g.BOARD}/threads.json", ->
$.cache "//a.4cdn.org/#{g.BOARD}/threads.json", ->
return unless @status is 200
threads = {}
for page in JSON.parse @response

View File

@ -36,14 +36,14 @@ Build =
name: data.filename + data.ext
timestamp: "#{data.tim}#{data.ext}"
url: if boardID is 'f'
"//images.4channel.org/#{boardID}/src/#{data.filename}#{data.ext}"
"//i.4cdn.org/#{boardID}/src/#{data.filename}#{data.ext}"
else
"//images.4chan.org/#{boardID}/src/#{data.tim}#{data.ext}"
"//i.4cdn.org/#{boardID}/src/#{data.tim}#{data.ext}"
height: data.h
width: data.w
MD5: data.md5
size: data.fsize
turl: "//thumbs.4chan.org/#{boardID}/thumb/#{data.tim}s.jpg"
turl: "//t.4cdn.org/#{boardID}/thumb/#{data.tim}s.jpg"
theight: data.tn_h
twidth: data.tn_w
isSpoiler: !!data.spoiler
@ -59,7 +59,7 @@ Build =
} = o
isOP = postID is threadID
staticPath = '//static.4chan.org/image/'
staticPath = '//s.4cdn.org/image/'
gifIcon = if window.devicePixelRatio >= 2
'@2x.gif'
else

View File

@ -69,7 +69,7 @@ class DataBoard
@save()
ajaxClean: (boardID) ->
$.cache "//api.4chan.org/#{boardID}/threads.json", (e) =>
$.cache "//a.4cdn.org/#{boardID}/threads.json", (e) =>
if e.target.status isnt 200
@delete boardID if e.target.status is 404
return

View File

@ -70,7 +70,7 @@ Get =
root.textContent = "Loading post No.#{postID}..."
if threadID
$.cache "//api.4chan.org/#{boardID}/res/#{threadID}.json", ->
$.cache "//a.4cdn.org/#{boardID}/res/#{threadID}.json", ->
Get.fetchedPost @, boardID, threadID, postID, root, context
else if url = Redirect.to 'post', {boardID, postID}
$.cache url,
@ -222,7 +222,7 @@ Get =
width: data.media.media_w
MD5: data.media.media_hash
size: data.media.media_size
turl: data.media.thumb_link or "//thumbs.4chan.org/#{boardID}/thumb/#{data.media.preview_orig}"
turl: data.media.thumb_link or "//t.4cdn.org/#{boardID}/thumb/#{data.media.preview_orig}"
theight: data.media.preview_h
twidth: data.media.preview_w
isSpoiler: data.media.spoiler is '1'

View File

@ -188,7 +188,7 @@ Index =
return unless Index.req and !Index.notice
Index.notice = new Notice 'info', 'Refreshing index...'
), 5 * $.SECOND - (Date.now() - now)
Index.req = $.ajax "//api.4chan.org/#{g.BOARD}/catalog.json",
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
onabort: Index.load
onloadend: Index.load
,

View File

@ -38,12 +38,12 @@ Main =
initFeatures: ->
switch location.hostname
when 'api.4chan.org'
when 'a.4cdn.org'
return
when 'sys.4chan.org'
Report.init()
return
when 'images.4chan.org'
when 'i.4cdn.org'
$.ready ->
if Conf['404 Redirect'] and d.title is '4chan - 404 Not Found'
Redirect.init()

View File

@ -127,7 +127,7 @@ class Post
@file.thumbURL = if that.isArchived
thumb.src
else
"#{location.protocol}//thumbs.4chan.org/#{@board}/thumb/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
"#{location.protocol}//t.4cdn.org/#{@board}/thumb/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
@file.name = $('span[title]', fileInfo).title
<% if (type === 'crx') { %>
# replace %22 with quotes, see:

View File

@ -353,7 +353,7 @@ Settings =
data =
isReply: true
file:
URL: '//images.4chan.org/g/src/1334437723720.jpg'
URL: '//i.4cdn.org/g/src/1334437723720.jpg'
name: 'd9bb2efc98dd0df141a94399ff5880b7.jpg'
size: '276 KB'
sizeInBytes: 276 * 1024

View File

@ -27,7 +27,7 @@ class Thread
$.rm $ ".#{typeLC}Icon", @OP.nodes.info
return
icon = $.el 'img',
src: "//static.4chan.org/image/#{typeLC}#{if window.devicePixelRatio >= 2 then '@2x' else ''}.gif"
src: "//s.4cdn.org/image/#{typeLC}#{if window.devicePixelRatio >= 2 then '@2x' else ''}.gif"
alt: type
title: type
className: "#{typeLC}Icon"

View File

@ -121,7 +121,7 @@ ImageExpand =
ImageExpand.contract post
src = @src.split '/'
if src[2] is 'images.4chan.org'
if src[2] is 'i.4cdn.org'
URL = Redirect.to 'file',
boardID: src[3]
filename: src[5].replace /\?.+$/, ''
@ -132,8 +132,8 @@ ImageExpand =
return
timeoutID = setTimeout ImageExpand.expand, 10000, post
# XXX CORS for images.4chan.org WHEN?
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
# XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
return if @status isnt 200
for postObj in JSON.parse(@response).posts
break if postObj.no is post.ID

View File

@ -27,7 +27,7 @@ ImageHover =
post = g.posts[@dataset.fullID]
src = @src.split '/'
if src[2] is 'images.4chan.org'
if src[2] is 'i.4cdn.org'
URL = Redirect.to 'file',
boardID: src[3]
filename: src[5].replace /\?.+$/, ''
@ -38,8 +38,8 @@ ImageHover =
return
timeoutID = setTimeout (=> @src = post.file.URL + '?' + Date.now()), 3000
# XXX CORS for images.4chan.org WHEN?
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
# XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
return if @status isnt 200
for postObj in JSON.parse(@response).posts
break if postObj.no is post.ID

View File

@ -39,7 +39,7 @@ ExpandThread =
expand: (thread, a, threadRoot) ->
ExpandThread.statuses[thread] = status = {}
a.textContent = ExpandThread.text '...', a.textContent.match(/\d+/g)...
status.req = $.cache "//api.4chan.org/#{thread.board}/res/#{thread}.json", ->
status.req = $.cache "//a.4cdn.org/#{thread.board}/res/#{thread}.json", ->
delete status.req
ExpandThread.parse @, thread, a
contract: (thread, a, threadRoot) ->

View File

@ -37,7 +37,7 @@ ThreadStats =
$.addClass ThreadStats.pageCountEl, 'warning'
return
setTimeout ThreadStats.fetchPage, 2 * $.MINUTE
$.ajax "//api.4chan.org/#{ThreadStats.thread.board}/threads.json", onload: ThreadStats.onThreadsLoad,
$.ajax "//a.4cdn.org/#{ThreadStats.thread.board}/threads.json", onload: ThreadStats.onThreadsLoad,
whenModified: true
onThreadsLoad: ->
return if @status isnt 200

View File

@ -153,7 +153,7 @@ ThreadUpdater =
ThreadUpdater.count()
ThreadUpdater.set 'timer', '...'
ThreadUpdater.req?.abort()
url = "//api.4chan.org/#{ThreadUpdater.thread.board}/res/#{ThreadUpdater.thread}.json"
url = "//a.4cdn.org/#{ThreadUpdater.thread.board}/res/#{ThreadUpdater.thread}.json"
ThreadUpdater.req = $.ajax url,
onabort: ThreadUpdater.cb.load
onloadend: ThreadUpdater.cb.load

View File

@ -100,7 +100,7 @@ ThreadWatcher =
return if data.isDead
{fetchCount} = ThreadWatcher
fetchCount.fetching++
$.ajax "//api.4chan.org/#{boardID}/res/#{threadID}.json",
$.ajax "//a.4cdn.org/#{boardID}/res/#{threadID}.json",
onloadend: ->
fetchCount.fetched++
if fetchCount.fetched is fetchCount.fetching