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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -8,11 +8,11 @@
|
|||||||
* http://zixaphir.github.io/appchan-x/
|
* http://zixaphir.github.io/appchan-x/
|
||||||
* 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com>
|
* 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com>
|
||||||
* https://github.com/aeosynth/4chan-x
|
* 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/
|
* 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/
|
* http://seaweedchan.github.io/4chan-x/
|
||||||
* 4chan x Copyright © 2012-2013 ihavenoface
|
* 4chan x Copyright © 2012-2014 ihavenoface
|
||||||
* http://ihavenoface.github.io/4chan-x/
|
* http://ihavenoface.github.io/4chan-x/
|
||||||
* 4chan SS Copyright © 2011-2013 Ahodesuka
|
* 4chan SS Copyright © 2011-2013 Ahodesuka
|
||||||
* https://github.com/ahodesuka/4chan-Style-Script/
|
* https://github.com/ahodesuka/4chan-Style-Script/
|
||||||
|
|||||||
@ -6,10 +6,10 @@
|
|||||||
// @namespace 4chan-X
|
// @namespace 4chan-X
|
||||||
// @description Cross-browser userscript for maximum lurking on 4chan.
|
// @description Cross-browser userscript for maximum lurking on 4chan.
|
||||||
// @license MIT; https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
// @license MIT; https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
// @match *://api.4chan.org/*
|
|
||||||
// @match *://boards.4chan.org/*
|
// @match *://boards.4chan.org/*
|
||||||
// @match *://images.4chan.org/*
|
|
||||||
// @match *://sys.4chan.org/*
|
// @match *://sys.4chan.org/*
|
||||||
|
// @match *://a.4cdn.org/*
|
||||||
|
// @match *://i.4cdn.org/*
|
||||||
// @grant GM_getValue
|
// @grant GM_getValue
|
||||||
// @grant GM_setValue
|
// @grant GM_setValue
|
||||||
// @grant GM_deleteValue
|
// @grant GM_deleteValue
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"js": ["script.js"],
|
"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,
|
"all_frames": true,
|
||||||
"run_at": "document_start"
|
"run_at": "document_start"
|
||||||
}],
|
}],
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -9,10 +9,11 @@
|
|||||||
"buildsPath": "builds/",
|
"buildsPath": "builds/",
|
||||||
"mainBranch": "master",
|
"mainBranch": "master",
|
||||||
"matches": [
|
"matches": [
|
||||||
"*://api.4chan.org/*",
|
|
||||||
"*://boards.4chan.org/*",
|
"*://boards.4chan.org/*",
|
||||||
"*://images.4chan.org/*",
|
"*://sys.4chan.org/*",
|
||||||
"*://sys.4chan.org/*"
|
"*://a.4cdn.org/*",
|
||||||
|
"*://i.4cdn.org/*"
|
||||||
|
|
||||||
],
|
],
|
||||||
"files": {
|
"files": {
|
||||||
"metajs": "4chan-X.meta.js",
|
"metajs": "4chan-X.meta.js",
|
||||||
|
|||||||
@ -43,7 +43,7 @@ ThreadHiding =
|
|||||||
# We need to clean hidden threads on the catalog ourselves,
|
# We need to clean hidden threads on the catalog ourselves,
|
||||||
# otherwise if we don't visit the catalog regularly
|
# otherwise if we don't visit the catalog regularly
|
||||||
# it will pollute the localStorage and our data.
|
# 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
|
return unless @status is 200
|
||||||
threads = {}
|
threads = {}
|
||||||
for page in JSON.parse @response
|
for page in JSON.parse @response
|
||||||
|
|||||||
@ -36,14 +36,14 @@ Build =
|
|||||||
name: data.filename + data.ext
|
name: data.filename + data.ext
|
||||||
timestamp: "#{data.tim}#{data.ext}"
|
timestamp: "#{data.tim}#{data.ext}"
|
||||||
url: if boardID is 'f'
|
url: if boardID is 'f'
|
||||||
"//images.4channel.org/#{boardID}/src/#{data.filename}#{data.ext}"
|
"//i.4cdn.org/#{boardID}/src/#{data.filename}#{data.ext}"
|
||||||
else
|
else
|
||||||
"//images.4chan.org/#{boardID}/src/#{data.tim}#{data.ext}"
|
"//i.4cdn.org/#{boardID}/src/#{data.tim}#{data.ext}"
|
||||||
height: data.h
|
height: data.h
|
||||||
width: data.w
|
width: data.w
|
||||||
MD5: data.md5
|
MD5: data.md5
|
||||||
size: data.fsize
|
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
|
theight: data.tn_h
|
||||||
twidth: data.tn_w
|
twidth: data.tn_w
|
||||||
isSpoiler: !!data.spoiler
|
isSpoiler: !!data.spoiler
|
||||||
@ -63,7 +63,7 @@ Build =
|
|||||||
} = o
|
} = o
|
||||||
isOP = postID is threadID
|
isOP = postID is threadID
|
||||||
|
|
||||||
staticPath = '//static.4chan.org/image/'
|
staticPath = '//s.4cdn.org/image/'
|
||||||
|
|
||||||
if email
|
if email
|
||||||
emailStart = '<a href="mailto:' + email + '" class="useremail">'
|
emailStart = '<a href="mailto:' + email + '" class="useremail">'
|
||||||
|
|||||||
@ -70,7 +70,7 @@ Get =
|
|||||||
|
|
||||||
root.textContent = "Loading post No.#{postID}..."
|
root.textContent = "Loading post No.#{postID}..."
|
||||||
if threadID
|
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
|
Get.fetchedPost @, boardID, threadID, postID, root, context
|
||||||
else if url = Redirect.to 'post', {boardID, postID}
|
else if url = Redirect.to 'post', {boardID, postID}
|
||||||
$.cache url,
|
$.cache url,
|
||||||
@ -198,7 +198,7 @@ Get =
|
|||||||
width: data.media.media_w
|
width: data.media.media_w
|
||||||
MD5: data.media.media_hash
|
MD5: data.media.media_hash
|
||||||
size: data.media.media_size
|
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
|
theight: data.media.preview_h
|
||||||
twidth: data.media.preview_w
|
twidth: data.media.preview_w
|
||||||
isSpoiler: data.media.spoiler is '1'
|
isSpoiler: data.media.spoiler is '1'
|
||||||
|
|||||||
@ -42,12 +42,12 @@ Main =
|
|||||||
g.THREADID = +pathname[3]
|
g.THREADID = +pathname[3]
|
||||||
|
|
||||||
switch location.hostname
|
switch location.hostname
|
||||||
when 'api.4chan.org'
|
when 'a.4cdn.org'
|
||||||
return
|
return
|
||||||
when 'sys.4chan.org'
|
when 'sys.4chan.org'
|
||||||
Report.init()
|
Report.init()
|
||||||
return
|
return
|
||||||
when 'images.4chan.org'
|
when 'i.4cdn.org'
|
||||||
$.ready ->
|
$.ready ->
|
||||||
if Conf['404 Redirect'] and ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains d.title
|
if Conf['404 Redirect'] and ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains d.title
|
||||||
Redirect.init()
|
Redirect.init()
|
||||||
|
|||||||
@ -430,7 +430,7 @@ Settings =
|
|||||||
data =
|
data =
|
||||||
isReply: true
|
isReply: true
|
||||||
file:
|
file:
|
||||||
URL: '//images.4chan.org/g/src/1334437723720.jpg'
|
URL: '//i.4cdn.org/g/src/1334437723720.jpg'
|
||||||
name: 'd9bb2efc98dd0df141a94399ff5880b7.jpg'
|
name: 'd9bb2efc98dd0df141a94399ff5880b7.jpg'
|
||||||
size: '276 KB'
|
size: '276 KB'
|
||||||
sizeInBytes: 276 * 1024
|
sizeInBytes: 276 * 1024
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class DataBoard
|
|||||||
@save()
|
@save()
|
||||||
|
|
||||||
ajaxClean: (boardID) ->
|
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
|
return if e.target.status isnt 200
|
||||||
board = @data.boards[boardID]
|
board = @data.boards[boardID]
|
||||||
threads = {}
|
threads = {}
|
||||||
|
|||||||
@ -133,7 +133,7 @@ class Post
|
|||||||
@file.thumbURL = if that.isArchived
|
@file.thumbURL = if that.isArchived
|
||||||
thumb.src
|
thumb.src
|
||||||
else
|
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
|
@file.name = if nameNode = $ 'span', fileText
|
||||||
nameNode.title or nameNode.textContent
|
nameNode.title or nameNode.textContent
|
||||||
else
|
else
|
||||||
|
|||||||
@ -137,7 +137,7 @@ ImageExpand =
|
|||||||
ImageExpand.contract post
|
ImageExpand.contract post
|
||||||
|
|
||||||
src = @src.split '/'
|
src = @src.split '/'
|
||||||
if src[2] is 'images.4chan.org'
|
if src[2] is 'i.4cdn.org'
|
||||||
URL = Redirect.to 'file',
|
URL = Redirect.to 'file',
|
||||||
boardID: src[3]
|
boardID: src[3]
|
||||||
filename: src[5]
|
filename: src[5]
|
||||||
@ -148,8 +148,8 @@ ImageExpand =
|
|||||||
return
|
return
|
||||||
|
|
||||||
timeoutID = setTimeout ImageExpand.expand, 10000, post
|
timeoutID = setTimeout ImageExpand.expand, 10000, post
|
||||||
# XXX CORS for images.4chan.org WHEN?
|
# XXX CORS for i.4cdn.org WHEN?
|
||||||
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
|
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
|
||||||
return if @status isnt 200
|
return if @status isnt 200
|
||||||
for postObj in JSON.parse(@response).posts
|
for postObj in JSON.parse(@response).posts
|
||||||
break if postObj.no is post.ID
|
break if postObj.no is post.ID
|
||||||
|
|||||||
@ -27,7 +27,7 @@ ImageHover =
|
|||||||
post = g.posts[@dataset.fullID]
|
post = g.posts[@dataset.fullID]
|
||||||
|
|
||||||
src = @src.split '/'
|
src = @src.split '/'
|
||||||
if src[2] is 'images.4chan.org'
|
if src[2] is 'i.4cdn.org'
|
||||||
URL = Redirect.to 'file',
|
URL = Redirect.to 'file',
|
||||||
boardID: src[3]
|
boardID: src[3]
|
||||||
filename: src[5].replace /\?.+$/, ''
|
filename: src[5].replace /\?.+$/, ''
|
||||||
@ -38,8 +38,8 @@ ImageHover =
|
|||||||
return
|
return
|
||||||
|
|
||||||
timeoutID = setTimeout (=> @src = post.file.URL + '?' + Date.now()), 3000
|
timeoutID = setTimeout (=> @src = post.file.URL + '?' + Date.now()), 3000
|
||||||
# XXX CORS for images.4chan.org WHEN?
|
# XXX CORS for i.4cdn.org WHEN?
|
||||||
$.ajax "//api.4chan.org/#{post.board}/res/#{post.thread}.json", onload: ->
|
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
|
||||||
return if @status isnt 200
|
return if @status isnt 200
|
||||||
for postObj in JSON.parse(@response).posts
|
for postObj in JSON.parse(@response).posts
|
||||||
break if postObj.no is post.ID
|
break if postObj.no is post.ID
|
||||||
|
|||||||
@ -38,7 +38,7 @@ ExpandThread =
|
|||||||
thread.isExpanded = 'loading'
|
thread.isExpanded = 'loading'
|
||||||
[posts, files] = a.textContent.match /\d+/g
|
[posts, files] = a.textContent.match /\d+/g
|
||||||
a.textContent = ExpandThread.text '...', posts, files
|
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
|
ExpandThread.parse @, thread, a
|
||||||
|
|
||||||
when 'loading'
|
when 'loading'
|
||||||
|
|||||||
@ -53,7 +53,7 @@ ThreadStats =
|
|||||||
$.addClass ThreadStats.pageCountEl, 'warning'
|
$.addClass ThreadStats.pageCountEl, 'warning'
|
||||||
return
|
return
|
||||||
setTimeout ThreadStats.fetchPage, 2 * $.MINUTE
|
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
|
whenModified: true
|
||||||
|
|
||||||
onThreadsLoad: ->
|
onThreadsLoad: ->
|
||||||
|
|||||||
@ -199,7 +199,7 @@ ThreadUpdater =
|
|||||||
else
|
else
|
||||||
ThreadUpdater.set 'timer', 'Update'
|
ThreadUpdater.set 'timer', 'Update'
|
||||||
ThreadUpdater.req.abort() if ThreadUpdater.req
|
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,
|
ThreadUpdater.req = $.ajax url, onloadend: ThreadUpdater.cb.load,
|
||||||
whenModified: true
|
whenModified: true
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,7 @@ ThreadWatcher =
|
|||||||
return if data.isDead
|
return if data.isDead
|
||||||
{fetchCount} = ThreadWatcher
|
{fetchCount} = ThreadWatcher
|
||||||
fetchCount.fetching++
|
fetchCount.fetching++
|
||||||
$.ajax "//api.4chan.org/#{boardID}/res/#{threadID}.json",
|
$.ajax "//a.4cdn.org/#{boardID}/res/#{threadID}.json",
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
fetchCount.fetched++
|
fetchCount.fetched++
|
||||||
if fetchCount.fetched is fetchCount.fetching
|
if fetchCount.fetched is fetchCount.fetching
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user