Small refactor and changes in archive redirections.
Add hash to the url when possible. Use http when on http and https when on https when the archiver offers this possibility.
This commit is contained in:
parent
0dece34676
commit
be7b1574bd
@ -3487,7 +3487,7 @@
|
|||||||
a.className = 'quotelink';
|
a.className = 'quotelink';
|
||||||
a.setAttribute('onclick', "replyhl('" + id + "');");
|
a.setAttribute('onclick', "replyhl('" + id + "');");
|
||||||
} else {
|
} else {
|
||||||
a.href = Redirect.thread(board, id, 'post');
|
a.href = Redirect.thread(board, 0, id);
|
||||||
a.className = 'deadlink';
|
a.className = 'deadlink';
|
||||||
a.target = '_blank';
|
a.target = '_blank';
|
||||||
}
|
}
|
||||||
@ -3756,17 +3756,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Redirect = {
|
Redirect = {
|
||||||
init: function() {
|
|
||||||
var path, url;
|
|
||||||
url = location.hostname === 'images.4chan.org' ? (path = location.pathname.split('/'), this.image(path[1], path[3])) : /^\d+$/.test(g.THREAD_ID) ? this.thread() : void 0;
|
|
||||||
if (url) {
|
|
||||||
return location.href = url;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
image: function(board, filename) {
|
image: function(board, filename) {
|
||||||
if (!Conf['404 Redirect']) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (board) {
|
switch (board) {
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'jp':
|
case 'jp':
|
||||||
@ -3774,22 +3764,15 @@
|
|||||||
case 'tg':
|
case 'tg':
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'vg':
|
case 'vg':
|
||||||
return "http://archive.foolz.us/" + board + "/full_image/" + filename;
|
return "//archive.foolz.us/" + board + "/full_image/" + filename;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
thread: function(board, id, mode) {
|
thread: function(board, threadID, postID) {
|
||||||
if (board == null) {
|
var path, url;
|
||||||
board = g.BOARD;
|
if (postID) {
|
||||||
}
|
postID = postID.match(/\d+/)[0];
|
||||||
if (id == null) {
|
|
||||||
id = g.THREAD_ID;
|
|
||||||
}
|
|
||||||
if (mode == null) {
|
|
||||||
mode = 'thread';
|
|
||||||
}
|
|
||||||
if (!(Conf['404 Redirect'] || mode === 'post')) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
|
||||||
switch (board) {
|
switch (board) {
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'co':
|
case 'co':
|
||||||
@ -3800,31 +3783,54 @@
|
|||||||
case 'u':
|
case 'u':
|
||||||
case 'v':
|
case 'v':
|
||||||
case 'vg':
|
case 'vg':
|
||||||
return "http://archive.foolz.us/" + board + "/" + mode + "/" + id + "/";
|
url = "//archive.foolz.us/" + path + "/";
|
||||||
|
if (threadID && postID) {
|
||||||
|
url += "#" + postID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'lit':
|
case 'lit':
|
||||||
return "http://fuuka.warosu.org/" + board + "/" + mode + "/" + id;
|
url = "//fuuka.warosu.org/" + path;
|
||||||
|
if (threadID && postID) {
|
||||||
|
url += "#p" + postID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'diy':
|
case 'diy':
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'sci':
|
case 'sci':
|
||||||
return "https://archive.installgentoo.net/" + board + "/" + mode + "/" + id;
|
url = "//archive.installgentoo.net/" + path;
|
||||||
|
if (threadID && postID) {
|
||||||
|
url += "#p" + postID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'cgl':
|
case 'cgl':
|
||||||
case 'mu':
|
case 'mu':
|
||||||
case 'w':
|
case 'w':
|
||||||
return "http://archive.rebeccablacktech.com/" + board + "/" + mode + "/" + id;
|
url = "//archive.rebeccablacktech.com/" + path;
|
||||||
|
if (threadID && postID) {
|
||||||
|
url += "#p" + postID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'an':
|
case 'an':
|
||||||
case 'toy':
|
case 'toy':
|
||||||
case 'x':
|
case 'x':
|
||||||
return "http://archive.xfiles.to/" + board + "/" + mode + "/" + id;
|
url = "http://archive.xfiles.to/" + path;
|
||||||
|
if (threadID && postID) {
|
||||||
|
url += "#p" + postID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
return "https://md401.homelinux.net/4chan/cgi-board.pl/" + board + "/" + mode + "/" + id;
|
url = "https://md401.homelinux.net/4chan/cgi-board.pl/" + path;
|
||||||
|
if (threadID && postID) {
|
||||||
|
url += "#p" + postID;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (mode === 'thread') {
|
if (threadID) {
|
||||||
return "//boards.4chan.org/" + board + "/";
|
url = "//boards.4chan.org/" + board + "/";
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return url || null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4128,8 +4134,13 @@
|
|||||||
return;
|
return;
|
||||||
case 'images.4chan.org':
|
case 'images.4chan.org':
|
||||||
$.ready(function() {
|
$.ready(function() {
|
||||||
if (d.title === '4chan - 404') {
|
var url;
|
||||||
return Redirect.init();
|
if (d.title === '4chan - 404' && Conf['404 Redirect']) {
|
||||||
|
path = location.pathname.split('/');
|
||||||
|
url = Redirect.image(path[1], path[3]);
|
||||||
|
if (url) {
|
||||||
|
return location.href = url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -4229,7 +4240,9 @@
|
|||||||
ready: function() {
|
ready: function() {
|
||||||
var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1;
|
var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (d.title === '4chan - 404') {
|
if (d.title === '4chan - 404') {
|
||||||
Redirect.init();
|
if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
|
||||||
|
location.href = Redirect.thread(g.BOARD, g.THREAD_ID, location.hash);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$.id('navtopr')) {
|
if (!$.id('navtopr')) {
|
||||||
|
|||||||
@ -2658,7 +2658,7 @@ Quotify =
|
|||||||
a.className = 'quotelink'
|
a.className = 'quotelink'
|
||||||
a.setAttribute 'onclick', "replyhl('#{id}');"
|
a.setAttribute 'onclick', "replyhl('#{id}');"
|
||||||
else
|
else
|
||||||
a.href = Redirect.thread board, id, 'post'
|
a.href = Redirect.thread board, 0, id
|
||||||
a.className = 'deadlink'
|
a.className = 'deadlink'
|
||||||
a.target = '_blank'
|
a.target = '_blank'
|
||||||
|
|
||||||
@ -2879,47 +2879,55 @@ Favicon =
|
|||||||
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
|
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
|
||||||
|
|
||||||
Redirect =
|
Redirect =
|
||||||
init: ->
|
|
||||||
url =
|
|
||||||
if location.hostname is 'images.4chan.org'
|
|
||||||
path = location.pathname.split '/'
|
|
||||||
@image path[1], path[3]
|
|
||||||
else if /^\d+$/.test g.THREAD_ID
|
|
||||||
@thread()
|
|
||||||
location.href = url if url
|
|
||||||
image: (board, filename) ->
|
image: (board, filename) ->
|
||||||
# Do not use g.BOARD, the image url can originate from a cross-quote.
|
# Do not use g.BOARD, the image url can originate from a cross-quote.
|
||||||
return unless Conf['404 Redirect']
|
|
||||||
switch board
|
switch board
|
||||||
when 'a', 'jp', 'm', 'tg', 'u', 'vg'
|
when 'a', 'jp', 'm', 'tg', 'u', 'vg'
|
||||||
"http://archive.foolz.us/#{board}/full_image/#{filename}"
|
"//archive.foolz.us/#{board}/full_image/#{filename}"
|
||||||
# these will work whenever https://github.com/eksopl/fuuka/issues/23 is done
|
# these will work whenever https://github.com/eksopl/fuuka/issues/23 is done
|
||||||
# when 'cgl', 'g', 'w'
|
# when 'cgl', 'g', 'w'
|
||||||
# "http://archive.rebeccablacktech.com/#{board}/full_image/#{filename}"
|
# "//archive.rebeccablacktech.com/#{board}/full_image/#{filename}"
|
||||||
# when 'an', 'toy', 'x'
|
# when 'an', 'toy', 'x'
|
||||||
# "http://archive.xfiles.to/#{board}/full_image/#{filename}"
|
# "http://archive.xfiles.to/#{board}/full_image/#{filename}"
|
||||||
# when 'e'
|
# when 'e'
|
||||||
# "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}"
|
# "https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}"
|
||||||
thread: (board=g.BOARD, id=g.THREAD_ID, mode='thread') ->
|
thread: (board, threadID, postID) ->
|
||||||
return unless Conf['404 Redirect'] or mode is 'post'
|
# keep the number only if the location.hash was sent f.e.
|
||||||
|
postID = postID.match(/\d+/)[0] if postID
|
||||||
|
path =
|
||||||
|
if threadID
|
||||||
|
"#{board}/thread/#{threadID}"
|
||||||
|
else
|
||||||
|
"#{board}/post/#{postID}"
|
||||||
switch board
|
switch board
|
||||||
when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg'
|
when 'a', 'co', 'jp', 'm', 'tg', 'tv', 'u', 'v', 'vg'
|
||||||
"http://archive.foolz.us/#{board}/#{mode}/#{id}/"
|
url = "//archive.foolz.us/#{path}/"
|
||||||
|
if threadID and postID
|
||||||
|
url += "##{postID}"
|
||||||
when 'lit'
|
when 'lit'
|
||||||
"http://fuuka.warosu.org/#{board}/#{mode}/#{id}"
|
url = "//fuuka.warosu.org/#{path}"
|
||||||
|
if threadID and postID
|
||||||
|
url += "#p#{postID}"
|
||||||
when 'diy', 'g', 'k', 'sci'
|
when 'diy', 'g', 'k', 'sci'
|
||||||
"https://archive.installgentoo.net/#{board}/#{mode}/#{id}"
|
url = "//archive.installgentoo.net/#{path}"
|
||||||
|
if threadID and postID
|
||||||
|
url += "#p#{postID}"
|
||||||
when 'cgl', 'mu', 'w'
|
when 'cgl', 'mu', 'w'
|
||||||
"http://archive.rebeccablacktech.com/#{board}/#{mode}/#{id}"
|
url = "//archive.rebeccablacktech.com/#{path}"
|
||||||
|
if threadID and postID
|
||||||
|
url += "#p#{postID}"
|
||||||
when 'an', 'toy', 'x'
|
when 'an', 'toy', 'x'
|
||||||
"http://archive.xfiles.to/#{board}/#{mode}/#{id}"
|
url = "http://archive.xfiles.to/#{path}"
|
||||||
|
if threadID and postID
|
||||||
|
url += "#p#{postID}"
|
||||||
when 'e'
|
when 'e'
|
||||||
"https://md401.homelinux.net/4chan/cgi-board.pl/#{board}/#{mode}/#{id}"
|
url = "https://md401.homelinux.net/4chan/cgi-board.pl/#{path}"
|
||||||
|
if threadID and postID
|
||||||
|
url += "#p#{postID}"
|
||||||
else
|
else
|
||||||
if mode is 'thread'
|
if threadID
|
||||||
"//boards.4chan.org/#{board}/"
|
url = "//boards.4chan.org/#{board}/"
|
||||||
else
|
url or null
|
||||||
null
|
|
||||||
|
|
||||||
ImageHover =
|
ImageHover =
|
||||||
init: ->
|
init: ->
|
||||||
@ -3130,7 +3138,11 @@ Main =
|
|||||||
window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value
|
window.location = 'javascript:Recaptcha.reload()' if e.keyCode is 8 and not e.target.value
|
||||||
return
|
return
|
||||||
when 'images.4chan.org'
|
when 'images.4chan.org'
|
||||||
$.ready -> Redirect.init() if d.title is '4chan - 404'
|
$.ready ->
|
||||||
|
if d.title is '4chan - 404' and Conf['404 Redirect']
|
||||||
|
path = location.pathname.split '/'
|
||||||
|
url = Redirect.image path[1], path[3]
|
||||||
|
location.href = url if url
|
||||||
return
|
return
|
||||||
|
|
||||||
$.ready Options.init
|
$.ready Options.init
|
||||||
@ -3224,7 +3236,8 @@ Main =
|
|||||||
|
|
||||||
ready: ->
|
ready: ->
|
||||||
if d.title is '4chan - 404'
|
if d.title is '4chan - 404'
|
||||||
Redirect.init()
|
if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID
|
||||||
|
location.href = Redirect.thread g.BOARD, g.THREAD_ID, location.hash
|
||||||
return
|
return
|
||||||
unless $.id 'navtopr'
|
unless $.id 'navtopr'
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user