WebExtensions doesn't like protocol relative URLs in AJAX requests.
This commit is contained in:
parent
a09d3e846d
commit
c41c6d412b
@ -4,7 +4,7 @@ BoardConfig =
|
|||||||
init: ->
|
init: ->
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
unless now - 2 * $.HOUR < (Conf['boardConfig'].lastChecked or 0) <= now
|
unless now - 2 * $.HOUR < (Conf['boardConfig'].lastChecked or 0) <= now
|
||||||
$.ajax '//a.4cdn.org/boards.json',
|
$.ajax "#{location.protocol}//a.4cdn.org/boards.json",
|
||||||
onloadend: @load
|
onloadend: @load
|
||||||
else
|
else
|
||||||
@set Conf['boardConfig'].boards
|
@set Conf['boardConfig'].boards
|
||||||
|
|||||||
@ -65,7 +65,7 @@ Build.Test =
|
|||||||
|
|
||||||
testOne: (post) ->
|
testOne: (post) ->
|
||||||
Build.Test.postsRemaining++
|
Build.Test.postsRemaining++
|
||||||
$.cache "//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", ->
|
$.cache "#{location.protocol}//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", ->
|
||||||
{posts} = @response
|
{posts} = @response
|
||||||
Build.spoilerRange[post.board.ID] = posts[0].custom_spoiler
|
Build.spoilerRange[post.board.ID] = posts[0].custom_spoiler
|
||||||
for postData in posts
|
for postData in posts
|
||||||
|
|||||||
@ -591,7 +591,7 @@ Index =
|
|||||||
location.reload()
|
location.reload()
|
||||||
return
|
return
|
||||||
|
|
||||||
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
|
Index.req = $.ajax "#{location.protocol}//a.4cdn.org/#{g.BOARD}/catalog.json",
|
||||||
onabort: Index.load
|
onabort: Index.load
|
||||||
onloadend: Index.load
|
onloadend: Index.load
|
||||||
,
|
,
|
||||||
|
|||||||
@ -54,7 +54,7 @@ ImageCommon =
|
|||||||
clearTimeout timeoutID if delay?
|
clearTimeout timeoutID if delay?
|
||||||
cb URL
|
cb URL
|
||||||
|
|
||||||
$.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
|
$.ajax "#{location.protocol}//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
|
||||||
post.kill !post.isClone if @status is 404
|
post.kill !post.isClone if @status is 404
|
||||||
return redirect() if @status isnt 200
|
return redirect() if @status isnt 200
|
||||||
for postObj in @response.posts
|
for postObj in @response.posts
|
||||||
|
|||||||
@ -376,7 +376,7 @@ Embedding =
|
|||||||
$.el 'iframe',
|
$.el 'iframe',
|
||||||
src: "https://w.soundcloud.com/player/?visual=true&show_comments=false&url=https%3A%2F%2Fsoundcloud.com%2F#{encodeURIComponent a.dataset.uid}"
|
src: "https://w.soundcloud.com/player/?visual=true&show_comments=false&url=https%3A%2F%2Fsoundcloud.com%2F#{encodeURIComponent a.dataset.uid}"
|
||||||
title:
|
title:
|
||||||
api: (uid) -> "//soundcloud.com/oembed?format=json&url=https%3A%2F%2Fsoundcloud.com%2F#{encodeURIComponent uid}"
|
api: (uid) -> "#{location.protocol}//soundcloud.com/oembed?format=json&url=https%3A%2F%2Fsoundcloud.com%2F#{encodeURIComponent uid}"
|
||||||
text: (_) -> _.title
|
text: (_) -> _.title
|
||||||
,
|
,
|
||||||
key: 'StrawPoll'
|
key: 'StrawPoll'
|
||||||
|
|||||||
@ -26,7 +26,7 @@ ExpandComment =
|
|||||||
return
|
return
|
||||||
return if not (a = $ '.abbr > a', post.nodes.comment)
|
return if not (a = $ '.abbr > a', post.nodes.comment)
|
||||||
a.textContent = "Post No.#{post} Loading..."
|
a.textContent = "Post No.#{post} Loading..."
|
||||||
$.cache "//a.4cdn.org#{a.pathname.split(/\/+/).splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post
|
$.cache "#{location.protocol}//a.4cdn.org#{a.pathname.split(/\/+/).splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post
|
||||||
|
|
||||||
contract: (post) ->
|
contract: (post) ->
|
||||||
return unless post.nodes.shortComment
|
return unless post.nodes.shortComment
|
||||||
|
|||||||
@ -43,7 +43,7 @@ ExpandThread =
|
|||||||
expand: (thread, a) ->
|
expand: (thread, a) ->
|
||||||
ExpandThread.statuses[thread] = status = {}
|
ExpandThread.statuses[thread] = status = {}
|
||||||
a.textContent = Build.summaryText '...', a.textContent.match(/\d+/g)...
|
a.textContent = Build.summaryText '...', a.textContent.match(/\d+/g)...
|
||||||
status.req = $.cache "//a.4cdn.org/#{thread.board}/thread/#{thread}.json", ->
|
status.req = $.cache "#{location.protocol}//a.4cdn.org/#{thread.board}/thread/#{thread}.json", ->
|
||||||
delete status.req
|
delete status.req
|
||||||
ExpandThread.parse @, thread, a
|
ExpandThread.parse @, thread, a
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ ThreadStats =
|
|||||||
$.addClass ThreadStats.pageCountEl, 'warning'
|
$.addClass ThreadStats.pageCountEl, 'warning'
|
||||||
return
|
return
|
||||||
ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 2 * $.MINUTE
|
ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 2 * $.MINUTE
|
||||||
$.ajax "//a.4cdn.org/#{ThreadStats.thread.board}/threads.json", onload: ThreadStats.onThreadsLoad,
|
$.ajax "#{location.protocol}//a.4cdn.org/#{ThreadStats.thread.board}/threads.json", onload: ThreadStats.onThreadsLoad,
|
||||||
whenModified: 'ThreadStats'
|
whenModified: 'ThreadStats'
|
||||||
|
|
||||||
onThreadsLoad: ->
|
onThreadsLoad: ->
|
||||||
|
|||||||
@ -138,7 +138,7 @@ ThreadUpdater =
|
|||||||
ThreadUpdater.setInterval()
|
ThreadUpdater.setInterval()
|
||||||
when 404
|
when 404
|
||||||
# XXX workaround for 4chan sending false 404s
|
# XXX workaround for 4chan sending false 404s
|
||||||
$.ajax "//a.4cdn.org/#{ThreadUpdater.thread.board}/catalog.json", onloadend: ->
|
$.ajax "#{location.protocol}//a.4cdn.org/#{ThreadUpdater.thread.board}/catalog.json", onloadend: ->
|
||||||
if @status is 200
|
if @status is 200
|
||||||
confirmed = true
|
confirmed = true
|
||||||
for page in @response
|
for page in @response
|
||||||
@ -231,7 +231,7 @@ ThreadUpdater =
|
|||||||
clearTimeout ThreadUpdater.timeoutID
|
clearTimeout ThreadUpdater.timeoutID
|
||||||
ThreadUpdater.set 'timer', '...', 'loading'
|
ThreadUpdater.set 'timer', '...', 'loading'
|
||||||
ThreadUpdater.req?.abort()
|
ThreadUpdater.req?.abort()
|
||||||
ThreadUpdater.req = $.ajax "//a.4cdn.org/#{ThreadUpdater.thread.board}/thread/#{ThreadUpdater.thread}.json",
|
ThreadUpdater.req = $.ajax "#{location.protocol}//a.4cdn.org/#{ThreadUpdater.thread.board}/thread/#{ThreadUpdater.thread}.json",
|
||||||
onloadend: ThreadUpdater.cb.load
|
onloadend: ThreadUpdater.cb.load
|
||||||
timeout: $.MINUTE
|
timeout: $.MINUTE
|
||||||
,
|
,
|
||||||
|
|||||||
@ -211,7 +211,7 @@ ThreadWatcher =
|
|||||||
if ThreadWatcher.requests.length is 0
|
if ThreadWatcher.requests.length is 0
|
||||||
ThreadWatcher.status.textContent = '...'
|
ThreadWatcher.status.textContent = '...'
|
||||||
$.addClass ThreadWatcher.refreshButton, 'fa-spin'
|
$.addClass ThreadWatcher.refreshButton, 'fa-spin'
|
||||||
req = $.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json",
|
req = $.ajax "#{location.protocol}//a.4cdn.org/#{boardID}/thread/#{threadID}.json",
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
ThreadWatcher.parseStatus.call @, thread
|
ThreadWatcher.parseStatus.call @, thread
|
||||||
timeout: $.MINUTE
|
timeout: $.MINUTE
|
||||||
|
|||||||
@ -91,9 +91,9 @@ class DataBoard
|
|||||||
return
|
return
|
||||||
|
|
||||||
ajaxClean: (boardID) ->
|
ajaxClean: (boardID) ->
|
||||||
$.cache "//a.4cdn.org/#{boardID}/threads.json", (e1) =>
|
$.cache "#{location.protocol}//a.4cdn.org/#{boardID}/threads.json", (e1) =>
|
||||||
return unless e1.target.status in [200, 404]
|
return unless e1.target.status in [200, 404]
|
||||||
$.cache "//a.4cdn.org/#{boardID}/archive.json", (e2) =>
|
$.cache "#{location.protocol}//a.4cdn.org/#{boardID}/archive.json", (e2) =>
|
||||||
return unless e2.target.status in [200, 404]
|
return unless e2.target.status in [200, 404]
|
||||||
@ajaxCleanParse boardID, e1.target.response, e2.target.response
|
@ajaxCleanParse boardID, e1.target.response, e2.target.response
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class Fetcher
|
|||||||
|
|
||||||
@root.textContent = "Loading post No.#{@postID}..."
|
@root.textContent = "Loading post No.#{@postID}..."
|
||||||
if @threadID
|
if @threadID
|
||||||
$.cache "//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", (e, isCached) =>
|
$.cache "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", (e, isCached) =>
|
||||||
@fetchedPost e.target, isCached
|
@fetchedPost e.target, isCached
|
||||||
else
|
else
|
||||||
@archivedPost()
|
@archivedPost()
|
||||||
@ -78,7 +78,7 @@ class Fetcher
|
|||||||
if post.no isnt @postID
|
if post.no isnt @postID
|
||||||
# Cached requests can be stale and must be rechecked.
|
# Cached requests can be stale and must be rechecked.
|
||||||
if isCached
|
if isCached
|
||||||
api = "//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json"
|
api = "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json"
|
||||||
$.cleanCache (url) -> url is api
|
$.cleanCache (url) -> url is api
|
||||||
$.cache api, (e) =>
|
$.cache api, (e) =>
|
||||||
@fetchedPost e.target, false
|
@fetchedPost e.target, false
|
||||||
|
|||||||
@ -315,7 +315,7 @@ Main =
|
|||||||
threads[0].ipCount = if m = scriptData.match /\bunique_ips *= *(\d+)\b/ then +m[1]
|
threads[0].ipCount = if m = scriptData.match /\bunique_ips *= *(\d+)\b/ then +m[1]
|
||||||
|
|
||||||
if g.BOARD.ID is 'f' and g.VIEW is 'thread'
|
if g.BOARD.ID is 'f' and g.VIEW is 'thread'
|
||||||
$.ajax "//a.4cdn.org/f/thread/#{g.THREADID}.json",
|
$.ajax "#{location.protocol}//a.4cdn.org/f/thread/#{g.THREADID}.json",
|
||||||
timeout: $.MINUTE
|
timeout: $.MINUTE
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
if @response and posts[0].file
|
if @response and posts[0].file
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user