Update for 4cdn, maybe fix issues like #219?
This commit is contained in:
parent
bfa4a65b68
commit
4735b8dae5
8
LICENSE
8
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 4chan X - Version 1.2.44 - 2013-12-06
|
||||
* 4chan X - Version 1.2.44 - 2014-01-07
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||
@ -8,11 +8,11 @@
|
||||
* http://zixaphir.github.io/appchan-x/
|
||||
* 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com>
|
||||
* https://github.com/aeosynth/4chan-x
|
||||
* 4chan x Copyright © 2012-2013 Nicolas Stepien <stepien.nicolas@gmail.com>
|
||||
* 4chan x Copyright © 2012-2014 Nicolas Stepien <stepien.nicolas@gmail.com>
|
||||
* https://4chan-x.just-believe.in/
|
||||
* 4chan x Copyright © 2013-2013 Jordan Bates <saudrapsmann@gmail.com>
|
||||
* 4chan x Copyright © 2013-2014 Jordan Bates <saudrapsmann@gmail.com>
|
||||
* http://seaweedchan.github.io/4chan-x/
|
||||
* 4chan x Copyright © 2012-2013 ihavenoface
|
||||
* 4chan x Copyright © 2012-2014 ihavenoface
|
||||
* http://ihavenoface.github.io/4chan-x/
|
||||
* 4chan SS Copyright © 2011-2013 Ahodesuka
|
||||
* https://github.com/ahodesuka/4chan-Style-Script/
|
||||
|
||||
@ -6,10 +6,10 @@
|
||||
// @namespace 4chan-X
|
||||
// @description Cross-browser userscript for maximum lurking on 4chan.
|
||||
// @license MIT; https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||
// @match *://api.4chan.org/*
|
||||
// @match *://boards.4chan.org/*
|
||||
// @match *://images.4chan.org/*
|
||||
// @match *://sys.4chan.org/*
|
||||
// @match *://a.4cdn.org/*
|
||||
// @match *://i.4cdn.org/*
|
||||
// @grant GM_getValue
|
||||
// @grant GM_setValue
|
||||
// @grant GM_deleteValue
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@
|
||||
},
|
||||
"content_scripts": [{
|
||||
"js": ["script.js"],
|
||||
"matches": ["*://api.4chan.org/*","*://boards.4chan.org/*","*://images.4chan.org/*","*://sys.4chan.org/*"],
|
||||
"matches": ["*://boards.4chan.org/*","*://sys.4chan.org/*","*://a.4cdn.org/*","*://i.4cdn.org/*"],
|
||||
"all_frames": true,
|
||||
"run_at": "document_start"
|
||||
}],
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -9,10 +9,11 @@
|
||||
"buildsPath": "builds/",
|
||||
"mainBranch": "master",
|
||||
"matches": [
|
||||
"*://api.4chan.org/*",
|
||||
"*://boards.4chan.org/*",
|
||||
"*://images.4chan.org/*",
|
||||
"*://sys.4chan.org/*"
|
||||
"*://sys.4chan.org/*",
|
||||
"*://a.4cdn.org/*",
|
||||
"*://i.4cdn.org/*"
|
||||
|
||||
],
|
||||
"files": {
|
||||
"metajs": "4chan-X.meta.js",
|
||||
|
||||
@ -43,7 +43,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
|
||||
|
||||
@ -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
|
||||
@ -63,7 +63,7 @@ Build =
|
||||
} = o
|
||||
isOP = postID is threadID
|
||||
|
||||
staticPath = '//static.4chan.org/image/'
|
||||
staticPath = '//s.4cdn.org/image/'
|
||||
|
||||
if email
|
||||
emailStart = '<a href="mailto:' + email + '" class="useremail">'
|
||||
|
||||
@ -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,
|
||||
@ -198,7 +198,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'
|
||||
|
||||
@ -42,12 +42,12 @@ Main =
|
||||
g.THREADID = +pathname[3]
|
||||
|
||||
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 ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains d.title
|
||||
Redirect.init()
|
||||
|
||||
@ -430,7 +430,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
|
||||
|
||||
@ -73,7 +73,7 @@ class DataBoard
|
||||
@save()
|
||||
|
||||
ajaxClean: (boardID) ->
|
||||
$.cache "//api.4chan.org/#{boardID}/threads.json", (e) =>
|
||||
$.cache "//a.4cdn.org/#{boardID}/threads.json", (e) =>
|
||||
return if e.target.status isnt 200
|
||||
board = @data.boards[boardID]
|
||||
threads = {}
|
||||
|
||||
@ -133,7 +133,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 = if nameNode = $ 'span', fileText
|
||||
nameNode.title or nameNode.textContent
|
||||
else
|
||||
|
||||
@ -137,7 +137,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]
|
||||
@ -148,8 +148,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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -38,7 +38,7 @@ ExpandThread =
|
||||
thread.isExpanded = 'loading'
|
||||
[posts, files] = a.textContent.match /\d+/g
|
||||
a.textContent = ExpandThread.text '...', posts, files
|
||||
$.cache "//api.4chan.org/#{thread.board}/res/#{thread}.json", ->
|
||||
$.cache "//a.4cdn.org/#{thread.board}/res/#{thread}.json", ->
|
||||
ExpandThread.parse @, thread, a
|
||||
|
||||
when 'loading'
|
||||
|
||||
@ -53,7 +53,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: ->
|
||||
|
||||
@ -199,7 +199,7 @@ ThreadUpdater =
|
||||
else
|
||||
ThreadUpdater.set 'timer', 'Update'
|
||||
ThreadUpdater.req.abort() if ThreadUpdater.req
|
||||
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, onloadend: ThreadUpdater.cb.load,
|
||||
whenModified: true
|
||||
|
||||
|
||||
@ -108,7 +108,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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user