Merge pull request #798 from ihavenoface/pull-request
Add Archivers submenu.
This commit is contained in:
commit
9d013ba80c
145
4chan_x.user.js
145
4chan_x.user.js
@ -4295,7 +4295,11 @@
|
|||||||
a.href = "#p" + id;
|
a.href = "#p" + id;
|
||||||
a.className = 'quotelink';
|
a.className = 'quotelink';
|
||||||
} else {
|
} else {
|
||||||
a.href = Redirect.thread(board, 0, id);
|
a.href = Redirect.to({
|
||||||
|
board: board,
|
||||||
|
threadID: 0,
|
||||||
|
postID: id
|
||||||
|
});
|
||||||
a.className = 'deadlink';
|
a.className = 'deadlink';
|
||||||
a.target = '_blank';
|
a.target = '_blank';
|
||||||
if (Redirect.post(board, id)) {
|
if (Redirect.post(board, id)) {
|
||||||
@ -4500,24 +4504,65 @@
|
|||||||
|
|
||||||
ArchiveLink = {
|
ArchiveLink = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var a;
|
var div, entry, type, _i, _len, _ref;
|
||||||
a = $.el('a', {
|
div = $.el('div', {
|
||||||
className: 'archive_link',
|
textContent: 'Archive'
|
||||||
target: '_blank',
|
|
||||||
textContent: 'Archived post'
|
|
||||||
});
|
});
|
||||||
return Menu.addEntry({
|
entry = {
|
||||||
el: a,
|
el: div,
|
||||||
open: function(post) {
|
open: function(post) {
|
||||||
var href, path;
|
var path;
|
||||||
path = $('a[title="Highlight this post"]', post.el).pathname.split('/');
|
path = $('a[title="Highlight this post"]', post.el).pathname.split('/');
|
||||||
if ((href = Redirect.thread(path[1], path[3], post.ID)) === ("//boards.4chan.org/" + path[1] + "/")) {
|
if ((Redirect.to({
|
||||||
|
board: path[1],
|
||||||
|
threadID: path[3],
|
||||||
|
postID: post.ID
|
||||||
|
})) === ("//boards.4chan.org/" + path[1] + "/")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
a.href = href;
|
post.info = [path[1], path[3]];
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
children: []
|
||||||
|
};
|
||||||
|
_ref = [['Post', 'apost'], ['Name', 'name'], ['Tripcode', 'tripcode'], ['E-mail', 'email'], ['Subject', 'subject'], ['Filename', 'filename'], ['Image MD5', 'md5']];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
type = _ref[_i];
|
||||||
|
entry.children.push(this.createSubEntry(type[0], type[1]));
|
||||||
|
}
|
||||||
|
return Menu.addEntry(entry);
|
||||||
|
},
|
||||||
|
createSubEntry: function(text, type) {
|
||||||
|
var el, open;
|
||||||
|
el = $.el('a', {
|
||||||
|
textContent: text,
|
||||||
|
target: '_blank'
|
||||||
|
});
|
||||||
|
open = function(post) {
|
||||||
|
var value;
|
||||||
|
if (type === 'apost') {
|
||||||
|
el.href = Redirect.to({
|
||||||
|
board: post.info[0],
|
||||||
|
threadID: post.info[1],
|
||||||
|
postID: post.ID
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
value = Filter[type](post);
|
||||||
|
if (!value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return el.href = Redirect.to({
|
||||||
|
board: post.info[0],
|
||||||
|
type: type,
|
||||||
|
value: value,
|
||||||
|
isSearch: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
el: el,
|
||||||
|
open: open
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4737,12 +4782,12 @@
|
|||||||
return "//nsfw.foolz.us/_/api/chan/post/?board=" + board + "&num=" + postID;
|
return "//nsfw.foolz.us/_/api/chan/post/?board=" + board + "&num=" + postID;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
thread: function(board, threadID, postID) {
|
to: function(data) {
|
||||||
var path, url;
|
var board, threadID, url;
|
||||||
if (postID) {
|
if (!data.isSearch) {
|
||||||
postID = postID.match(/\d+/)[0];
|
threadID = data.threadID;
|
||||||
}
|
}
|
||||||
path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
|
board = data.board;
|
||||||
switch (board) {
|
switch (board) {
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'co':
|
case 'co':
|
||||||
@ -4757,41 +4802,26 @@
|
|||||||
case 'wsg':
|
case 'wsg':
|
||||||
case 'dev':
|
case 'dev':
|
||||||
case 'foolz':
|
case 'foolz':
|
||||||
url = "//archive.foolz.us/" + path + "/";
|
url = Redirect.path('//archive.foolz.us', 'foolfuuka', data);
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#" + postID;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'kuku':
|
case 'kuku':
|
||||||
url = "//nsfw.foolz.us/" + path + "/";
|
url = Redirect.path("//nsfw.foolz.us", 'foolfuuka', data);
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#" + postID;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'ck':
|
case 'ck':
|
||||||
case 'lit':
|
case 'lit':
|
||||||
url = "//fuuka.warosu.org/" + path;
|
url = Redirect.path("//fuuka.warosu.org", 'fuuka', data);
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#p" + postID;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'diy':
|
case 'diy':
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'sci':
|
case 'sci':
|
||||||
url = "//archive.installgentoo.net/" + path;
|
url = Redirect.path("//archive.installgentoo.net", 'fuuka', data);
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#p" + postID;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'cgl':
|
case 'cgl':
|
||||||
case 'mu':
|
case 'mu':
|
||||||
case 'soc':
|
case 'soc':
|
||||||
case 'w':
|
case 'w':
|
||||||
url = "//archive.rebeccablacktech.com/" + path;
|
url = Redirect.path("//archive.rebeccablacktech.com", 'fuuka', data);
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#p" + postID;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'an':
|
case 'an':
|
||||||
case 'fit':
|
case 'fit':
|
||||||
@ -4800,16 +4830,7 @@
|
|||||||
case 'r9k':
|
case 'r9k':
|
||||||
case 'toy':
|
case 'toy':
|
||||||
case 'x':
|
case 'x':
|
||||||
url = "http://archive.heinessen.com/" + path;
|
url = Redirect.path("http://archive.heinessen.com", 'fuuka', data);
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#p" + postID;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'e':
|
|
||||||
url = "https://www.cliché.net/4chan/cgi-board.pl/" + path;
|
|
||||||
if (threadID && postID) {
|
|
||||||
url += "#p" + postID;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (threadID) {
|
if (threadID) {
|
||||||
@ -4817,6 +4838,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url || null;
|
return url || null;
|
||||||
|
},
|
||||||
|
path: function(base, archiver, data) {
|
||||||
|
var board, path, postID, threadID, type, value;
|
||||||
|
if (data.isSearch) {
|
||||||
|
board = data.board, type = data.type, value = data.value;
|
||||||
|
type = type === 'name' ? 'username' : type === 'md5' ? 'image' : type;
|
||||||
|
value = encodeURIComponent(value);
|
||||||
|
if (archiver === 'foolfuuka') {
|
||||||
|
return "" + base + "/" + board + "/search/" + type + "/" + value;
|
||||||
|
} else if (type === 'image') {
|
||||||
|
return "" + base + "/" + board + "/?task=search2&search_media_hash=" + value;
|
||||||
|
} else {
|
||||||
|
return "" + base + "/" + board + "/?task=search2&search_" + type + "=" + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
board = data.board, threadID = data.threadID, postID = data.postID;
|
||||||
|
if (postID) {
|
||||||
|
postID = postID.match(/\d+/)[0];
|
||||||
|
}
|
||||||
|
path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
|
||||||
|
if (threadID && postID) {
|
||||||
|
path += archiver === 'foolfuuka' ? "#" + postID : "#p" + postID;
|
||||||
|
}
|
||||||
|
return "" + base + "/" + path;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5262,7 +5307,11 @@
|
|||||||
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 (/^4chan - 404/.test(d.title)) {
|
if (/^4chan - 404/.test(d.title)) {
|
||||||
if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
|
if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
|
||||||
location.href = Redirect.thread(g.BOARD, g.THREAD_ID, location.hash);
|
location.href = Redirect.to({
|
||||||
|
board: g.BOARD,
|
||||||
|
threadID: g.THREAD_ID,
|
||||||
|
postID: location.hash
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
master
|
master
|
||||||
|
- noface
|
||||||
|
The Menu now has search links for Archivers.
|
||||||
|
|
||||||
2.36.0
|
2.36.0
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
|||||||
144
script.coffee
144
script.coffee
@ -3522,7 +3522,11 @@ Quotify =
|
|||||||
a.href = "#p#{id}"
|
a.href = "#p#{id}"
|
||||||
a.className = 'quotelink'
|
a.className = 'quotelink'
|
||||||
else
|
else
|
||||||
a.href = Redirect.thread board, 0, id
|
a.href =
|
||||||
|
Redirect.to
|
||||||
|
board: board
|
||||||
|
threadID: 0
|
||||||
|
postID: id
|
||||||
a.className = 'deadlink'
|
a.className = 'deadlink'
|
||||||
a.target = '_blank'
|
a.target = '_blank'
|
||||||
if Redirect.post board, id
|
if Redirect.post board, id
|
||||||
@ -3696,18 +3700,58 @@ DownloadLink =
|
|||||||
|
|
||||||
ArchiveLink =
|
ArchiveLink =
|
||||||
init: ->
|
init: ->
|
||||||
a = $.el 'a',
|
div = $.el 'div',
|
||||||
className: 'archive_link'
|
textContent: 'Archive'
|
||||||
target: '_blank'
|
|
||||||
textContent: 'Archived post'
|
entry =
|
||||||
Menu.addEntry
|
el: div
|
||||||
el: a
|
|
||||||
open: (post) ->
|
open: (post) ->
|
||||||
path = $('a[title="Highlight this post"]', post.el).pathname.split '/'
|
path = $('a[title="Highlight this post"]', post.el).pathname.split '/'
|
||||||
if (href = Redirect.thread path[1], path[3], post.ID) is "//boards.4chan.org/#{path[1]}/"
|
if (Redirect.to {board: path[1], threadID: path[3], postID: post.ID}) is "//boards.4chan.org/#{path[1]}/"
|
||||||
return false
|
return false
|
||||||
a.href = href
|
post.info = [path[1], path[3]]
|
||||||
true
|
true
|
||||||
|
children: []
|
||||||
|
|
||||||
|
for type in [
|
||||||
|
['Post', 'apost']
|
||||||
|
['Name', 'name']
|
||||||
|
['Tripcode', 'tripcode']
|
||||||
|
['E-mail', 'email']
|
||||||
|
['Subject', 'subject']
|
||||||
|
['Filename', 'filename']
|
||||||
|
['Image MD5', 'md5']
|
||||||
|
]
|
||||||
|
# Add a sub entry for each type.
|
||||||
|
entry.children.push @createSubEntry type[0], type[1]
|
||||||
|
|
||||||
|
Menu.addEntry entry
|
||||||
|
|
||||||
|
createSubEntry: (text, type) ->
|
||||||
|
|
||||||
|
el = $.el 'a',
|
||||||
|
textContent: text
|
||||||
|
target: '_blank'
|
||||||
|
|
||||||
|
open = (post) ->
|
||||||
|
if type is 'apost'
|
||||||
|
el.href =
|
||||||
|
Redirect.to
|
||||||
|
board: post.info[0]
|
||||||
|
threadID: post.info[1]
|
||||||
|
postID: post.ID
|
||||||
|
return true
|
||||||
|
value = Filter[type] post
|
||||||
|
# We want to parse the exact same stuff as Filter does already.
|
||||||
|
return false unless value
|
||||||
|
el.href =
|
||||||
|
Redirect.to
|
||||||
|
board: post.info[0]
|
||||||
|
type: type
|
||||||
|
value: value
|
||||||
|
isSearch: true
|
||||||
|
|
||||||
|
return el: el, open: open
|
||||||
|
|
||||||
ThreadStats =
|
ThreadStats =
|
||||||
init: ->
|
init: ->
|
||||||
@ -3865,56 +3909,68 @@ Redirect =
|
|||||||
"//archive.rebeccablacktech.com/#{board}/full_image/#{filename}"
|
"//archive.rebeccablacktech.com/#{board}/full_image/#{filename}"
|
||||||
when 'an', 'k', 'toy', 'x'
|
when 'an', 'k', 'toy', 'x'
|
||||||
"http://archive.heinessen.com/#{board}/full_image/#{filename}"
|
"http://archive.heinessen.com/#{board}/full_image/#{filename}"
|
||||||
# when 'e'
|
|
||||||
# "https://www.cliché.net/4chan/cgi-board.pl/#{board}/full_image/#{filename}"
|
|
||||||
post: (board, postID) ->
|
post: (board, postID) ->
|
||||||
switch board
|
switch board
|
||||||
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz'
|
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz'
|
||||||
"//archive.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
|
"//archive.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
|
||||||
when 'u', 'kuku'
|
when 'u', 'kuku'
|
||||||
"//nsfw.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
|
"//nsfw.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
|
||||||
thread: (board, threadID, postID) ->
|
to: (data) ->
|
||||||
# keep the number only if the location.hash was sent f.e.
|
unless data.isSearch
|
||||||
postID = postID.match(/\d+/)[0] if postID
|
{threadID} = data
|
||||||
path =
|
{board} = data
|
||||||
if threadID
|
|
||||||
"#{board}/thread/#{threadID}"
|
|
||||||
else
|
|
||||||
"#{board}/post/#{postID}"
|
|
||||||
switch board
|
switch board
|
||||||
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz'
|
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz'
|
||||||
url = "//archive.foolz.us/#{path}/"
|
url = Redirect.path '//archive.foolz.us', 'foolfuuka', data
|
||||||
if threadID and postID
|
|
||||||
url += "##{postID}"
|
|
||||||
when 'u', 'kuku'
|
when 'u', 'kuku'
|
||||||
url = "//nsfw.foolz.us/#{path}/"
|
url = Redirect.path "//nsfw.foolz.us", 'foolfuuka', data
|
||||||
if threadID and postID
|
|
||||||
url += "##{postID}"
|
|
||||||
when 'ck', 'lit'
|
when 'ck', 'lit'
|
||||||
url = "//fuuka.warosu.org/#{path}"
|
url = Redirect.path "//fuuka.warosu.org", 'fuuka', data
|
||||||
if threadID and postID
|
|
||||||
url += "#p#{postID}"
|
|
||||||
when 'diy', 'g', 'sci'
|
when 'diy', 'g', 'sci'
|
||||||
url = "//archive.installgentoo.net/#{path}"
|
url = Redirect.path "//archive.installgentoo.net", 'fuuka', data
|
||||||
if threadID and postID
|
|
||||||
url += "#p#{postID}"
|
|
||||||
when 'cgl', 'mu', 'soc', 'w'
|
when 'cgl', 'mu', 'soc', 'w'
|
||||||
url = "//archive.rebeccablacktech.com/#{path}"
|
url = Redirect.path "//archive.rebeccablacktech.com", 'fuuka', data
|
||||||
if threadID and postID
|
|
||||||
url += "#p#{postID}"
|
|
||||||
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x'
|
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x'
|
||||||
url = "http://archive.heinessen.com/#{path}"
|
url = Redirect.path "http://archive.heinessen.com", 'fuuka', data
|
||||||
if threadID and postID
|
|
||||||
url += "#p#{postID}"
|
|
||||||
when 'e'
|
|
||||||
url = "https://www.cliché.net/4chan/cgi-board.pl/#{path}"
|
|
||||||
if threadID and postID
|
|
||||||
url += "#p#{postID}"
|
|
||||||
else
|
else
|
||||||
if threadID
|
if threadID
|
||||||
url = "//boards.4chan.org/#{board}/"
|
url = "//boards.4chan.org/#{board}/"
|
||||||
url or null
|
url or null
|
||||||
|
|
||||||
|
path: (base, archiver, data) ->
|
||||||
|
if data.isSearch
|
||||||
|
{board, type, value} = data
|
||||||
|
type =
|
||||||
|
if type is 'name'
|
||||||
|
'username'
|
||||||
|
else if type is 'md5'
|
||||||
|
'image'
|
||||||
|
else
|
||||||
|
type
|
||||||
|
value = encodeURIComponent value
|
||||||
|
return if archiver is 'foolfuuka'
|
||||||
|
"#{base}/#{board}/search/#{type}/#{value}"
|
||||||
|
else if type is 'image'
|
||||||
|
"#{base}/#{board}/?task=search2&search_media_hash=#{value}"
|
||||||
|
else
|
||||||
|
"#{base}/#{board}/?task=search2&search_#{type}=#{value}"
|
||||||
|
|
||||||
|
{board, threadID, postID} = data
|
||||||
|
# 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}"
|
||||||
|
if threadID and postID
|
||||||
|
path +=
|
||||||
|
if archiver is 'foolfuuka'
|
||||||
|
"##{postID}"
|
||||||
|
else
|
||||||
|
"#p#{postID}"
|
||||||
|
"#{base}/#{path}"
|
||||||
|
|
||||||
ImageHover =
|
ImageHover =
|
||||||
init: ->
|
init: ->
|
||||||
Main.callbacks.push @node
|
Main.callbacks.push @node
|
||||||
@ -4245,7 +4301,11 @@ Main =
|
|||||||
ready: ->
|
ready: ->
|
||||||
if /^4chan - 404/.test d.title
|
if /^4chan - 404/.test d.title
|
||||||
if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID
|
if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID
|
||||||
location.href = Redirect.thread g.BOARD, g.THREAD_ID, location.hash
|
location.href =
|
||||||
|
Redirect.to
|
||||||
|
board: g.BOARD
|
||||||
|
threadID: g.THREAD_ID
|
||||||
|
postID: location.hash
|
||||||
return
|
return
|
||||||
unless $.id 'navtopright'
|
unless $.id 'navtopright'
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user