Simplify usage of Redirect.navigate.
This commit is contained in:
parent
e2a55997ce
commit
eb116cf476
@ -95,11 +95,13 @@ Redirect =
|
||||
location.protocol is 'http:' or
|
||||
Conf['Except Archives from Encryption']
|
||||
|
||||
navigate: (URL, alternative) ->
|
||||
if URL and (
|
||||
Redirect.securityCheck(URL) or
|
||||
confirm "Redirect to #{URL}?\n\nYour connection will not be encrypted."
|
||||
navigate: (dest, data, alternative) ->
|
||||
Redirect.init() unless Redirect.data
|
||||
url = Redirect.to dest, data
|
||||
if url and (
|
||||
Redirect.securityCheck(url) or
|
||||
confirm "Redirect to #{url}?\n\nYour connection will not be encrypted."
|
||||
)
|
||||
location.replace URL
|
||||
location.replace url
|
||||
else if alternative
|
||||
location.replace alternative
|
||||
|
||||
@ -78,20 +78,17 @@ Main =
|
||||
if /\/imgboard\.php$/.test(location.pathname) and (match = location.search.match /\bres=(\d+)/)
|
||||
$.ready ->
|
||||
if $.id('errmsg')?.textContent is 'Error: Specified thread does not exist.'
|
||||
Redirect.init()
|
||||
Redirect.navigate Redirect.to 'thread',
|
||||
Redirect.navigate 'thread',
|
||||
boardID: g.BOARD.ID
|
||||
postID: +match[1]
|
||||
return
|
||||
when 'i.4cdn.org'
|
||||
$.asap (-> d.readyState isnt 'loading'), ->
|
||||
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
|
||||
Redirect.init()
|
||||
pathname = location.pathname.split '/'
|
||||
URL = Redirect.to 'file',
|
||||
Redirect.navigate 'file',
|
||||
boardID: g.BOARD.ID
|
||||
filename: pathname[pathname.length - 1]
|
||||
Redirect.navigate URL
|
||||
else if video = $ 'video'
|
||||
if Conf['Volume in New Tab']
|
||||
Volume.setup video
|
||||
@ -169,11 +166,11 @@ Main =
|
||||
if g.VIEW is 'thread'
|
||||
ThreadWatcher.set404 g.BOARD.ID, g.THREADID, ->
|
||||
if Conf['404 Redirect']
|
||||
href = Redirect.to 'thread',
|
||||
Redirect.navigate 'thread',
|
||||
boardID: g.BOARD.ID
|
||||
threadID: g.THREADID
|
||||
postID: +location.hash.match /\d+/ # post number or 0
|
||||
Redirect.navigate href, "/#{g.BOARD}/"
|
||||
, "/#{g.BOARD}/"
|
||||
return
|
||||
|
||||
# 4chan Pass Link
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user