Merge branch 'master' into v3

This commit is contained in:
Nicolas Stepien 2012-10-25 11:34:52 +02:00
commit 37687b5bef
5 changed files with 129 additions and 88 deletions

View File

@ -20,7 +20,7 @@
// @icon https://github.com/MayhemYDG/4chan-x/raw/stable/img/icon.gif // @icon https://github.com/MayhemYDG/4chan-x/raw/stable/img/icon.gif
// ==/UserScript== // ==/UserScript==
/* 4chan X Alpha - Version 3.0.0 - 2012-10-17 /* 4chan X Alpha - Version 3.0.0 - 2012-10-25
* http://mayhemydg.github.com/4chan-x/ * http://mayhemydg.github.com/4chan-x/
* *
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com> * Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
@ -702,7 +702,7 @@
case 'mu': case 'mu':
case 'soc': case 'soc':
case 'w': case 'w':
return "//archive.rebeccablacktech.com/" + board + "/full_image/" + filename; return "//rbt.asia/" + board + "/full_image/" + filename;
case 'an': case 'an':
case 'fit': case 'fit':
case 'k': case 'k':
@ -734,12 +734,9 @@
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, url;
if (postID) { board = data.board;
postID = postID.match(/\d+/)[0];
}
path = threadID ? "" + board + "/thread/" + threadID : "" + board + "/post/" + postID;
switch ("" + board) { switch ("" + board) {
case 'a': case 'a':
case 'co': case 'co':
@ -754,41 +751,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 '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 'g':
case 'mu': case 'mu':
case 'soc': case 'soc':
case 'w': case 'w':
url = "//archive.rebeccablacktech.com/" + path; url = Redirect.path('//rbt.asia', 'fuuka', data);
if (threadID && postID) {
url += "#p" + postID;
}
break; break;
case 'an': case 'an':
case 'fit': case 'fit':
@ -797,23 +779,38 @@
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 (data.threadID) {
url = "//boards.4chan.org/" + board + "/"; url = "//boards.4chan.org/" + board + "/";
} }
} }
return url || ''; return url || '';
},
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;
} }
}; };
@ -1198,7 +1195,11 @@
if (post = g.posts[quoteID]) { if (post = g.posts[quoteID]) {
if (post.isDead) { if (post.isDead) {
a = $.el('a', { a = $.el('a', {
href: Redirect.thread(board, 0, ID), href: Redirect.to({
board: board,
threadID: 0,
postID: ID
}),
className: 'quotelink deadlink', className: 'quotelink deadlink',
textContent: "" + quote + "\u00A0(Dead)", textContent: "" + quote + "\u00A0(Dead)",
target: '_blank' target: '_blank'
@ -1215,7 +1216,11 @@
} }
} else { } else {
a = $.el('a', { a = $.el('a', {
href: Redirect.thread(board, 0, ID), href: Redirect.to({
board: board,
threadID: 0,
postID: ID
}),
className: 'deadlink', className: 'deadlink',
target: '_blank', target: '_blank',
textContent: "" + quote + "\u00A0(Dead)" textContent: "" + quote + "\u00A0(Dead)"
@ -1703,7 +1708,7 @@
}, },
createFunc: function(format) { createFunc: function(format) {
var code; var code;
code = format.replace(/%([BKlLMnNprs])/g, function(s, c) { code = format.replace(/%(.)/g, function(s, c) {
if (c in FileInfo.formatters) { if (c in FileInfo.formatters) {
return "' + FileInfo.formatters." + c + ".call(post) + '"; return "' + FileInfo.formatters." + c + ".call(post) + '";
} else { } else {
@ -1730,6 +1735,12 @@
}); });
}, },
formatters: { formatters: {
t: function() {
return this.file.URL.match(/\d+\..+$/)[0];
},
T: function() {
return "<a href=" + FileInfo.data.link + " target=_blank>" + (FileInfo.formatters.t.call(this)) + "</a>";
},
l: function() { l: function() {
return "<a href=" + this.file.URL + " target=_blank>" + (FileInfo.formatters.n.call(this)) + "</a>"; return "<a href=" + this.file.URL + " target=_blank>" + (FileInfo.formatters.n.call(this)) + "</a>";
}, },
@ -2776,7 +2787,11 @@
var boardChild, posts, thread, threadChild, threads, _i, _j, _len, _len1, _ref, _ref1; var boardChild, posts, thread, threadChild, threads, _i, _j, _len, _len1, _ref, _ref1;
if (d.title === '4chan - 404 Not Found') { if (d.title === '4chan - 404 Not Found') {
if (Conf['404 Redirect'] && g.REPLY) { if (Conf['404 Redirect'] && g.REPLY) {
location.href = Redirect.thread(g.BOARD, g.THREAD, location.hash); location.href = Redirect.to({
board: g.BOARD,
threadID: g.THREAD,
postID: location.hash
});
} }
return; return;
} }

View File

@ -8,6 +8,12 @@ alpha
master master
2.36.1
- noface
The Menu now has search links for Archivers.
- Mayhem
Added possibility to display unix timestamps with File Info Formatting.
2.36.0 2.36.0
- Mayhem - Mayhem
Added thread creation QR cooldown. Added thread creation QR cooldown.

View File

@ -1 +1 @@
postMessage({version:'2.36.0'},'*') postMessage({version:'2.36.1'},'*')

View File

@ -12,11 +12,9 @@ Redirect =
when 'diy', 'sci' when 'diy', 'sci'
"//archive.installgentoo.net/#{board}/full_image/#{filename}" "//archive.installgentoo.net/#{board}/full_image/#{filename}"
when 'cgl', 'g', 'mu', 'soc', 'w' when 'cgl', 'g', 'mu', 'soc', 'w'
"//archive.rebeccablacktech.com/#{board}/full_image/#{filename}" "//rbt.asia/#{board}/full_image/#{filename}"
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x' when 'an', 'fit', 'k', 'mlp', 'r9k', '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'
@ -25,47 +23,58 @@ Redirect =
"//nsfw.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}" "//nsfw.foolz.us/_/api/chan/post/?board=#{board}&num=#{postID}"
# for fuuka-based archives: # for fuuka-based archives:
# https://github.com/eksopl/fuuka/issues/27 # https://github.com/eksopl/fuuka/issues/27
thread: (board, threadID, postID) -> to: (data) ->
# keep the number only, if the location.hash was sent f.e. {board} = data
switch "#{board}"
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz'
url = Redirect.path '//archive.foolz.us', 'foolfuuka', data
when 'u', 'kuku'
url = Redirect.path '//nsfw.foolz.us', 'foolfuuka', data
when 'ck', 'lit'
url = Redirect.path '//fuuka.warosu.org', 'fuuka', data
when 'diy', 'sci'
url = Redirect.path '//archive.installgentoo.net', 'fuuka', data
when 'cgl', 'g', 'mu', 'soc', 'w'
url = Redirect.path '//rbt.asia', 'fuuka', data
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x'
url = Redirect.path 'http://archive.heinessen.com', 'fuuka', data
else
if data.threadID
url = "//boards.4chan.org/#{board}/"
url or ''
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 postID = postID.match(/\d+/)[0] if postID
path = path =
if threadID if threadID
"#{board}/thread/#{threadID}" "#{board}/thread/#{threadID}"
else else
"#{board}/post/#{postID}" "#{board}/post/#{postID}"
switch "#{board}" if threadID and postID
when 'a', 'co', 'jp', 'm', 'q', 'sp', 'tg', 'tv', 'v', 'vg', 'wsg', 'dev', 'foolz' path +=
url = "//archive.foolz.us/#{path}/" if archiver is 'foolfuuka'
if threadID and postID "##{postID}"
url += "##{postID}" else
when 'u', 'kuku' "#p#{postID}"
url = "//nsfw.foolz.us/#{path}/" "#{base}/#{path}"
if threadID and postID
url += "##{postID}"
when 'ck', 'lit'
url = "//fuuka.warosu.org/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'diy', 'g', 'sci'
url = "//archive.installgentoo.net/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'cgl', 'mu', 'soc', 'w'
url = "//archive.rebeccablacktech.com/#{path}"
if threadID and postID
url += "#p#{postID}"
when 'an', 'fit', 'k', 'mlp', 'r9k', 'toy', 'x'
url = "http://archive.heinessen.com/#{path}"
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
if threadID
url = "//boards.4chan.org/#{board}/"
url or ''
Build = Build =
spoilerRange: {} spoilerRange: {}
@ -553,7 +562,10 @@ Quotify =
if post = g.posts[quoteID] if post = g.posts[quoteID]
if post.isDead if post.isDead
a = $.el 'a', a = $.el 'a',
href: Redirect.thread board, 0, ID href: Redirect.to
board: board
threadID: 0
postID: ID
className: 'quotelink deadlink' className: 'quotelink deadlink'
textContent: "#{quote}\u00A0(Dead)" textContent: "#{quote}\u00A0(Dead)"
target: '_blank' target: '_blank'
@ -569,7 +581,10 @@ Quotify =
textContent: quote textContent: quote
else else
a = $.el 'a', a = $.el 'a',
href: Redirect.thread board, 0, ID href: Redirect.to
board: board
threadID: 0
postID: ID
className: 'deadlink' className: 'deadlink'
target: '_blank' target: '_blank'
textContent: "#{quote}\u00A0(Dead)" textContent: "#{quote}\u00A0(Dead)"
@ -934,7 +949,7 @@ FileInfo =
return if !@file or @isClone return if !@file or @isClone
@file.text.innerHTML = FileInfo.funk FileInfo, @ @file.text.innerHTML = FileInfo.funk FileInfo, @
createFunc: (format) -> createFunc: (format) ->
code = format.replace /%([BKlLMnNprs])/g, (s, c) -> code = format.replace /%(.)/g, (s, c) ->
if c of FileInfo.formatters if c of FileInfo.formatters
"' + FileInfo.formatters.#{c}.call(post) + '" "' + FileInfo.formatters.#{c}.call(post) + '"
else else
@ -955,6 +970,8 @@ FileInfo =
name.replace /<|>/g, (c) -> name.replace /<|>/g, (c) ->
c is '<' and '&lt;' or '&gt;' c is '<' and '&lt;' or '&gt;'
formatters: formatters:
t: -> @file.URL.match(/\d+\..+$/)[0]
T: -> "<a href=#{FileInfo.data.link} target=_blank>#{FileInfo.formatters.t.call @}</a>"
l: -> "<a href=#{@file.URL} target=_blank>#{FileInfo.formatters.n.call @}</a>" l: -> "<a href=#{@file.URL} target=_blank>#{FileInfo.formatters.n.call @}</a>"
L: -> "<a href=#{@file.URL} target=_blank>#{FileInfo.formatters.N.call @}</a>" L: -> "<a href=#{@file.URL} target=_blank>#{FileInfo.formatters.N.call @}</a>"
n: -> n: ->

View File

@ -459,7 +459,10 @@ Main =
initFeaturesReady: -> initFeaturesReady: ->
if d.title is '4chan - 404 Not Found' if d.title is '4chan - 404 Not Found'
if Conf['404 Redirect'] and g.REPLY if Conf['404 Redirect'] and g.REPLY
location.href = Redirect.thread g.BOARD, g.THREAD, location.hash location.href = Redirect.to
board: g.BOARD
threadID: g.THREAD
postID: location.hash
return return
return unless $.id 'navtopright' return unless $.id 'navtopright'