From 19c7e73d140d7f8874a0421d35bf1aa4cfa083af Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 24 Mar 2019 04:42:43 -0700 Subject: [PATCH] Get rid of more API URLs spread about the codebase. --- src/General/Build.Test.coffee | 2 +- src/Miscellaneous/ExpandComment.coffee | 2 +- src/Monitoring/ThreadUpdater.coffee | 2 +- src/classes/Fetcher.coffee | 4 ++-- src/site/SW.yotsuba.coffee | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/General/Build.Test.coffee b/src/General/Build.Test.coffee index 12945f106..ec0651b05 100644 --- a/src/General/Build.Test.coffee +++ b/src/General/Build.Test.coffee @@ -65,7 +65,7 @@ Build.Test = testOne: (post) -> Build.Test.postsRemaining++ - $.cache "#{location.protocol}//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", -> + $.cache Site.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), -> return unless @response {posts} = @response Build.spoilerRange[post.board.ID] = posts[0].custom_spoiler diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index 4adf5eda4..3e8da0ef9 100644 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -26,7 +26,7 @@ ExpandComment = return return if not (a = $ '.abbr > a', post.nodes.comment) a.textContent = "Post No.#{post} Loading..." - $.cache "#{location.protocol}//a.4cdn.org#{a.pathname.split(/\/+/).splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post + $.cache Site.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), -> ExpandComment.parse @, a, post contract: (post) -> return unless post.nodes.shortComment diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index bfaac34e5..99e16b8d3 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -138,7 +138,7 @@ ThreadUpdater = ThreadUpdater.setInterval() when 404 # XXX workaround for 4chan sending false 404s - $.ajax "#{location.protocol}//a.4cdn.org/#{ThreadUpdater.thread.board}/catalog.json", onloadend: -> + $.ajax Site.urls.catalogJSON({boardID: ThreadUpdater.thread.board.ID}), onloadend: -> if @status is 200 confirmed = true for page in @response diff --git a/src/classes/Fetcher.coffee b/src/classes/Fetcher.coffee index a396bbca1..693fb2856 100644 --- a/src/classes/Fetcher.coffee +++ b/src/classes/Fetcher.coffee @@ -16,7 +16,7 @@ class Fetcher @root.textContent = "Loading post No.#{@postID}..." if @threadID that = @ - $.cache "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", ({isCached}) -> + $.cache Site.urls.threadJSON({boardID: @boardID, threadID: @threadID}), ({isCached}) -> that.fetchedPost @, isCached else @archivedPost() @@ -81,7 +81,7 @@ class Fetcher if post.no isnt @postID # Cached requests can be stale and must be rechecked. if isCached - api = "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json" + api = Site.urls.threadJSON({boardID: @boardID, threadID: @threadID}) $.cleanCache (url) -> url is api that = @ $.cache api, -> diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index 2aa84bba3..97648f5e6 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -98,7 +98,7 @@ SW.yotsuba = if g.BOARD.ID is 'f' and thread.OP.file {file} = thread.OP - $.ajax "#{location.protocol}//a.4cdn.org/f/thread/#{thread}.json", + $.ajax Site.urls.threadJSON({boardID: 'f', threadID: thread.ID}), timeout: $.MINUTE onloadend: -> if @response