Update foolz archives redirection, close #71. Get #79 done, will need testing and foolz archive's support.
This commit is contained in:
parent
eb22d553c3
commit
691395b627
120
4chan_x.user.js
120
4chan_x.user.js
@ -6,6 +6,7 @@
|
|||||||
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
|
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
|
||||||
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
|
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
|
||||||
// @include http://boards.4chan.org/*
|
// @include http://boards.4chan.org/*
|
||||||
|
// @include http://images.4chan.org/*
|
||||||
// @include http://sys.4chan.org/*
|
// @include http://sys.4chan.org/*
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js
|
// @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js
|
||||||
@ -70,7 +71,7 @@
|
|||||||
config = {
|
config = {
|
||||||
main: {
|
main: {
|
||||||
Enhancing: {
|
Enhancing: {
|
||||||
'404 Redirect': [true, 'Redirect dead threads'],
|
'404 Redirect': [true, 'Redirect dead threads and images'],
|
||||||
'Keybinds': [true, 'Binds actions to keys'],
|
'Keybinds': [true, 'Binds actions to keys'],
|
||||||
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
|
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
|
||||||
'Report Button': [true, 'Add report buttons'],
|
'Report Button': [true, 'Add report buttons'],
|
||||||
@ -2819,49 +2820,61 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
redirect = function() {
|
redirect = {
|
||||||
var url;
|
init: function() {
|
||||||
switch (g.BOARD) {
|
var url;
|
||||||
case 'a':
|
url = location.hostname === 'images.4chan.org' ? redirect.image(g.BOARD, location.pathname.split('/')[3]) : /^\d+$/.test(g.THREAD_ID) ? redirect.thread() : void 0;
|
||||||
case 'jp':
|
if (url) return location.href = url;
|
||||||
case 'm':
|
},
|
||||||
case 'tg':
|
image: function(board, filename) {
|
||||||
case 'tv':
|
switch (board) {
|
||||||
url = "http://oldarchive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
case 'a':
|
||||||
break;
|
case 'jp':
|
||||||
case 'diy':
|
case 'm':
|
||||||
case 'g':
|
case 'tg':
|
||||||
case 'sci':
|
case 'tv':
|
||||||
url = "http://archive.installgentoo.net/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
return "http://archivethumb.foolz.us/board/" + board + "/img/" + filename;
|
||||||
break;
|
}
|
||||||
case '3':
|
},
|
||||||
case 'adv':
|
thread: function() {
|
||||||
case 'an':
|
switch (g.BOARD) {
|
||||||
case 'ck':
|
case 'a':
|
||||||
case 'co':
|
case 'jp':
|
||||||
case 'fa':
|
case 'm':
|
||||||
case 'fit':
|
case 'tg':
|
||||||
case 'int':
|
case 'tv':
|
||||||
case 'k':
|
return "http://archive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||||
case 'mu':
|
case 'diy':
|
||||||
case 'n':
|
case 'g':
|
||||||
case 'o':
|
case 'sci':
|
||||||
case 'p':
|
return "http://archive.installgentoo.net/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||||
case 'po':
|
case '3':
|
||||||
case 'pol':
|
case 'adv':
|
||||||
case 'soc':
|
case 'an':
|
||||||
case 'sp':
|
case 'ck':
|
||||||
case 'toy':
|
case 'co':
|
||||||
case 'trv':
|
case 'fa':
|
||||||
case 'v':
|
case 'fit':
|
||||||
case 'vp':
|
case 'int':
|
||||||
case 'x':
|
case 'k':
|
||||||
url = "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
case 'mu':
|
||||||
break;
|
case 'n':
|
||||||
default:
|
case 'o':
|
||||||
url = "http://boards.4chan.org/" + g.BOARD;
|
case 'p':
|
||||||
|
case 'po':
|
||||||
|
case 'pol':
|
||||||
|
case 'soc':
|
||||||
|
case 'sp':
|
||||||
|
case 'toy':
|
||||||
|
case 'trv':
|
||||||
|
case 'v':
|
||||||
|
case 'vp':
|
||||||
|
case 'x':
|
||||||
|
return "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||||
|
default:
|
||||||
|
return "http://boards.4chan.org/" + g.BOARD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return location.href = url;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
imgHover = {
|
imgHover = {
|
||||||
@ -2973,26 +2986,29 @@
|
|||||||
thumb.hidden = false;
|
thumb.hidden = false;
|
||||||
return $.rm(thumb.nextSibling);
|
return $.rm(thumb.nextSibling);
|
||||||
},
|
},
|
||||||
expand: function(thumb) {
|
expand: function(thumb, url) {
|
||||||
var a, filesize, img, max;
|
var a, filesize, img, max;
|
||||||
a = thumb.parentNode;
|
a = thumb.parentNode;
|
||||||
img = $.el('img', {
|
img = $.el('img', {
|
||||||
src: a.href
|
src: url ? url : a.href
|
||||||
});
|
});
|
||||||
if (engine === 'gecko' && a.parentNode.className !== 'op') {
|
if (engine === 'gecko' && a.parentNode.className !== 'op') {
|
||||||
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent;
|
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent;
|
||||||
max = filesize.match(/(\d+)x/);
|
max = filesize.match(/(\d+)x/);
|
||||||
img.style.maxWidth = "" + max[1] + "px";
|
img.style.maxWidth = "" + max[1] + "px";
|
||||||
}
|
}
|
||||||
$.on(img, 'error', imgExpand.error);
|
if (conf['404 Redirect']) $.on(img, 'error', imgExpand.error);
|
||||||
thumb.hidden = true;
|
thumb.hidden = true;
|
||||||
return $.add(a, img);
|
return $.add(a, img);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
var req, thumb;
|
var req, src, thumb, url;
|
||||||
thumb = this.previousSibling;
|
thumb = this.previousSibling;
|
||||||
imgExpand.contract(thumb);
|
imgExpand.contract(thumb);
|
||||||
if (engine === 'webkit') {
|
src = this.src.split('/');
|
||||||
|
if (url = redirect.image(src[3], src[5])) {
|
||||||
|
return imgExpand.expand(thumb, url);
|
||||||
|
} else if (engine === 'webkit') {
|
||||||
return req = $.ajax(this.src, (function() {
|
return req = $.ajax(this.src, (function() {
|
||||||
if (this.status !== 404) {
|
if (this.status !== 404) {
|
||||||
return setTimeout(imgExpand.retry, 10000, thumb);
|
return setTimeout(imgExpand.retry, 10000, thumb);
|
||||||
@ -3042,7 +3058,7 @@
|
|||||||
pathname = location.pathname.slice(1).split('/');
|
pathname = location.pathname.slice(1).split('/');
|
||||||
g.BOARD = pathname[0], temp = pathname[1];
|
g.BOARD = pathname[0], temp = pathname[1];
|
||||||
if (temp === 'res') {
|
if (temp === 'res') {
|
||||||
g.REPLY = temp;
|
g.REPLY = true;
|
||||||
g.THREAD_ID = pathname[2];
|
g.THREAD_ID = pathname[2];
|
||||||
} else {
|
} else {
|
||||||
g.PAGENUM = parseInt(temp) || 0;
|
g.PAGENUM = parseInt(temp) || 0;
|
||||||
@ -3111,11 +3127,11 @@
|
|||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref;
|
var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref;
|
||||||
$.off(d, 'DOMContentLoaded', Main.onLoad);
|
$.off(d, 'DOMContentLoaded', Main.onLoad);
|
||||||
if (conf['404 Redirect'] && d.title === '4chan - 404' && /^\d+$/.test(g.THREAD_ID)) {
|
if (conf['404 Redirect'] && d.title === '4chan - 404') {
|
||||||
redirect();
|
redirect.init();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$('#navtopr')) return;
|
if (!$('#navtopr') || location.hostname === 'images.4chan.org') return;
|
||||||
$.addClass(d.body, engine);
|
$.addClass(d.body, engine);
|
||||||
$.addStyle(Main.css);
|
$.addStyle(Main.css);
|
||||||
threading.init();
|
threading.init();
|
||||||
|
|||||||
1
Cakefile
1
Cakefile
@ -13,6 +13,7 @@ HEADER = """
|
|||||||
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
|
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
|
||||||
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
|
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
|
||||||
// @include http://boards.4chan.org/*
|
// @include http://boards.4chan.org/*
|
||||||
|
// @include http://images.4chan.org/*
|
||||||
// @include http://sys.4chan.org/*
|
// @include http://sys.4chan.org/*
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js
|
// @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
master
|
master
|
||||||
- mayhem
|
- mayhem
|
||||||
the report button can open multiple popups
|
redirect 404'd pictures to archives when possible
|
||||||
|
the report button can open multiple popups again
|
||||||
add omploader to the list of optional flavors (http://ompldr.org/upload?url1=)
|
add omploader to the list of optional flavors (http://ompldr.org/upload?url1=)
|
||||||
|
update archive redirections
|
||||||
|
|
||||||
2.23.7
|
2.23.7
|
||||||
- mayhem
|
- mayhem
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
config =
|
config =
|
||||||
main:
|
main:
|
||||||
Enhancing:
|
Enhancing:
|
||||||
'404 Redirect': [true, 'Redirect dead threads']
|
'404 Redirect': [true, 'Redirect dead threads and images']
|
||||||
'Keybinds': [true, 'Binds actions to keys']
|
'Keybinds': [true, 'Binds actions to keys']
|
||||||
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
|
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
|
||||||
'Report Button': [true, 'Add report buttons']
|
'Report Button': [true, 'Add report buttons']
|
||||||
@ -2216,17 +2216,29 @@ Favicon =
|
|||||||
favicon.href = null
|
favicon.href = null
|
||||||
$.replace favicon, clone
|
$.replace favicon, clone
|
||||||
|
|
||||||
redirect = ->
|
redirect =
|
||||||
switch g.BOARD
|
init: ->
|
||||||
when 'a', 'jp', 'm', 'tg', 'tv'
|
url =
|
||||||
url = "http://oldarchive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
# waiting for https://github.com/FoOlRulez/FoOlFuuka/issues/11
|
||||||
when 'diy', 'g', 'sci'
|
if location.hostname is 'images.4chan.org'
|
||||||
url = "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
redirect.image g.BOARD, location.pathname.split('/')[3]
|
||||||
when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x'
|
else if /^\d+$/.test g.THREAD_ID
|
||||||
url = "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
redirect.thread()
|
||||||
else
|
location.href = url if url
|
||||||
url = "http://boards.4chan.org/#{g.BOARD}"
|
image: (board, filename) -> #board must be given, the image can originate from a cross-quote
|
||||||
location.href = url
|
switch board
|
||||||
|
when 'a', 'jp', 'm', 'tg', 'tv'
|
||||||
|
"http://archivethumb.foolz.us/board/#{board}/img/#{filename}"
|
||||||
|
thread: ->
|
||||||
|
switch g.BOARD
|
||||||
|
when 'a', 'jp', 'm', 'tg', 'tv'
|
||||||
|
"http://archive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||||
|
when 'diy', 'g', 'sci'
|
||||||
|
"http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||||
|
when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x'
|
||||||
|
"http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||||
|
else
|
||||||
|
"http://boards.4chan.org/#{g.BOARD}"
|
||||||
|
|
||||||
imgHover =
|
imgHover =
|
||||||
init: ->
|
init: ->
|
||||||
@ -2303,23 +2315,26 @@ imgExpand =
|
|||||||
thumb.hidden = false
|
thumb.hidden = false
|
||||||
$.rm thumb.nextSibling
|
$.rm thumb.nextSibling
|
||||||
|
|
||||||
expand: (thumb) ->
|
expand: (thumb, url) ->
|
||||||
a = thumb.parentNode
|
a = thumb.parentNode
|
||||||
img = $.el 'img',
|
img = $.el 'img',
|
||||||
src: a.href
|
src: if url then url else a.href
|
||||||
if engine is 'gecko' and a.parentNode.className isnt 'op'
|
if engine is 'gecko' and a.parentNode.className isnt 'op'
|
||||||
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent
|
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent
|
||||||
max = filesize.match /(\d+)x/
|
max = filesize.match /(\d+)x/
|
||||||
img.style.maxWidth = "#{max[1]}px"
|
img.style.maxWidth = "#{max[1]}px"
|
||||||
$.on img, 'error', imgExpand.error
|
$.on img, 'error', imgExpand.error if conf['404 Redirect']
|
||||||
thumb.hidden = true
|
thumb.hidden = true
|
||||||
$.add a, img
|
$.add a, img
|
||||||
|
|
||||||
error: ->
|
error: ->
|
||||||
thumb = @previousSibling
|
thumb = @previousSibling
|
||||||
imgExpand.contract thumb
|
imgExpand.contract thumb
|
||||||
|
src = @src.split '/'
|
||||||
|
if url = redirect.image src[3], src[5]
|
||||||
|
imgExpand.expand thumb, url
|
||||||
#navigator.online is not x-browser/os yet
|
#navigator.online is not x-browser/os yet
|
||||||
if engine is 'webkit'
|
else if engine is 'webkit'
|
||||||
req = $.ajax @src, (->
|
req = $.ajax @src, (->
|
||||||
setTimeout imgExpand.retry, 10000, thumb if @status isnt 404
|
setTimeout imgExpand.retry, 10000, thumb if @status isnt 404
|
||||||
), type: 'head', event: 'onreadystatechange'
|
), type: 'head', event: 'onreadystatechange'
|
||||||
@ -2358,7 +2373,7 @@ Main =
|
|||||||
pathname = location.pathname[1..].split('/')
|
pathname = location.pathname[1..].split('/')
|
||||||
[g.BOARD, temp] = pathname
|
[g.BOARD, temp] = pathname
|
||||||
if temp is 'res'
|
if temp is 'res'
|
||||||
g.REPLY = temp
|
g.REPLY = true
|
||||||
g.THREAD_ID = pathname[2]
|
g.THREAD_ID = pathname[2]
|
||||||
else
|
else
|
||||||
g.PAGENUM = parseInt(temp) or 0
|
g.PAGENUM = parseInt(temp) or 0
|
||||||
@ -2453,10 +2468,10 @@ Main =
|
|||||||
|
|
||||||
onLoad: ->
|
onLoad: ->
|
||||||
$.off d, 'DOMContentLoaded', Main.onLoad
|
$.off d, 'DOMContentLoaded', Main.onLoad
|
||||||
if conf['404 Redirect'] and d.title is '4chan - 404' and /^\d+$/.test g.THREAD_ID
|
if conf['404 Redirect'] and d.title is '4chan - 404'
|
||||||
redirect()
|
redirect.init()
|
||||||
return
|
return
|
||||||
if not $ '#navtopr'
|
if not $('#navtopr') or location.hostname is 'images.4chan.org'
|
||||||
return
|
return
|
||||||
$.addClass d.body, engine
|
$.addClass d.body, engine
|
||||||
$.addStyle Main.css
|
$.addStyle Main.css
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user