Fix 4chan/4channel not being correct in certain links.

This commit is contained in:
ccd0 2019-04-08 22:53:41 -07:00
parent c5d01ce6d6
commit 5cb0c1a213

View File

@ -25,11 +25,16 @@ Build =
sameThread: (boardID, threadID) -> sameThread: (boardID, threadID) ->
g.VIEW is 'thread' and g.BOARD.ID is boardID and g.THREADID is +threadID g.VIEW is 'thread' and g.BOARD.ID is boardID and g.THREADID is +threadID
postURL: (boardID, threadID, postID) -> threadURL: (boardID, threadID) ->
if Build.sameThread boardID, threadID if boardID isnt g.BOARD.ID
"#p#{postID}" "//#{BoardConfig.domain(boardID)}/#{boardID}/thread/#{threadID}"
else if g.VIEW isnt 'thread' or +threadID isnt g.THREADID
"/#{boardID}/thread/#{threadID}"
else else
"/#{boardID}/thread/#{threadID}#p#{postID}" ''
postURL: (boardID, threadID, postID) ->
"#{Build.threadURL(boardID, threadID)}#p#{postID}"
parseJSON: (data, boardID, siteID) -> parseJSON: (data, boardID, siteID) ->
o = o =
@ -127,11 +132,12 @@ Build =
capcodePlural = "#{capcodeLong}s" capcodePlural = "#{capcodeLong}s"
capcodeDescription = "a 4chan #{capcodeLong}" capcodeDescription = "a 4chan #{capcodeLong}"
postLink = Build.postURL boardID, threadID, ID url = Build.threadURL boardID, threadID
postLink = "#{url}#p#{ID}"
quoteLink = if Build.sameThread boardID, threadID quoteLink = if Build.sameThread boardID, threadID
"javascript:quote('#{+ID}');" "javascript:quote('#{+ID}');"
else else
"/#{boardID}/thread/#{threadID}#q#{ID}" "#{url}#q#{ID}"
postInfo = <%= readHTML('PostInfo.html') %> postInfo = <%= readHTML('PostInfo.html') %>
@ -159,12 +165,12 @@ Build =
# Fix quotelinks # Fix quotelinks
for quote in $$ '.quotelink', container for quote in $$ '.quotelink', container
href = quote.getAttribute 'href' href = quote.getAttribute 'href'
if (href[0] is '#') and !(Build.sameThread boardID, threadID) if (href[0] is '#')
quote.href = ("/#{boardID}/thread/#{threadID}") + href if !Build.sameThread(boardID, threadID)
else if (match = href.match /^\/([^\/]+)\/thread\/(\d+)/) and (Build.sameThread match[1], match[2]) quote.href = Build.threadURL(boardID, threadID) + href
quote.href = href.match(/(#[^#]*)?$/)[0] or '#' else
else if /^\d+(#|$)/.test(href) and not (g.VIEW is 'thread' and g.BOARD.ID is boardID) # used on /f/ if (match = quote.href.match SW.yotsuba.regexp.quotelink) and (Build.sameThread match[1], match[2])
quote.href = "/#{boardID}/thread/#{href}" quote.href = href.match(/(#[^#]*)?$/)[0] or '#'
container container