Fix an issue where catalog links were affecting external links #773

This commit is contained in:
Zixaphir 2014-07-31 14:04:15 -07:00
parent 9d087ef5d6
commit 8ba4898158
5 changed files with 42 additions and 36 deletions

View File

@ -1,5 +1,5 @@
/*
* appchan x - Version 2.9.32 - 2014-07-30
* appchan x - Version 2.9.32 - 2014-07-31
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -28,7 +28,7 @@
// ==/UserScript==
/*
* appchan x - Version 2.9.32 - 2014-07-30
* appchan x - Version 2.9.32 - 2014-07-31
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -4309,29 +4309,31 @@
as = $$('#full-board-list a[title]', Header.boardList);
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"(\,"[^"]+[^"]")?))*|[^\w@]+/g;
nodes = text.match(re).map(function(t) {
var a, board, boardID, href, m, type, _i, _len;
var a, board, boardID, href, m, match, type, url, _i, _len;
if (/^[^\w@]/.test(t)) {
return $.tn(t);
}
if (/^toggle-all/.test(t)) {
a = $.el('a', {
className: 'show-board-list-button',
textContent: (t.match(/-text:"(.+)"/) || [null, '+'])[1],
textContent: (match = t.match(/-text:"(.+)"/)) ? match[1] : '+',
href: 'javascript:;'
});
$.on(a, 'click', Header.toggleBoardList);
return a;
}
if (/^external/.test(t)) {
a = $.el('a', {
href: (t.match(/\,"(.+)"/) || [null, '+'])[1],
textContent: (t.match(/-text:"(.+)"\,/) || [null, '+'])[1],
className: 'external'
});
if (a.hostname === 'boards.4chan.org' && a.pathname.split('/')[1] === g.BOARD.ID) {
a.className += ' current';
if (url = t.match(/\,"(.+)"/)) {
a = $.el('a', {
textContent: (match = t.match(/-text:"(.+)"\,/)) ? match[1] : '+',
className: 'external',
href: url[1]
});
if (a.hostname === 'boards.4chan.org' && a.pathname.split('/')[1] === g.BOARD.ID) {
a.className += ' current';
}
return a;
}
return a;
}
board = /^current/.test(t) ? g.BOARD.ID : t.match(/^[^-]+/)[0];
boardID = t.split('-')[0];
@ -15048,7 +15050,7 @@
_ref = $$("#board-list a:not(.catalog), #boardNavDesktopFoot a");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
if (((_ref1 = a.hostname) !== 'boards.4chan.org' && _ref1 !== 'catalog.neet.tv' && _ref1 !== '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan')) {
if (((_ref1 = a.hostname) !== 'boards.4chan.org' && _ref1 !== 'catalog.neet.tv' && _ref1 !== '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan') || $.hasClass(a, 'external')) {
continue;
}
a.href = generateURL(board);

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* appchan x - Version 2.9.32 - 2014-07-30
* appchan x - Version 2.9.32 - 2014-07-31
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -4360,29 +4360,31 @@
as = $$('#full-board-list a[title]', Header.boardList);
re = /[\w@]+(-(all|title|replace|full|archive|(mode|sort|text|url):"[^"]+"(\,"[^"]+[^"]")?))*|[^\w@]+/g;
nodes = text.match(re).map(function(t) {
var a, board, boardID, href, m, type, _i, _len;
var a, board, boardID, href, m, match, type, url, _i, _len;
if (/^[^\w@]/.test(t)) {
return $.tn(t);
}
if (/^toggle-all/.test(t)) {
a = $.el('a', {
className: 'show-board-list-button',
textContent: (t.match(/-text:"(.+)"/) || [null, '+'])[1],
textContent: (match = t.match(/-text:"(.+)"/)) ? match[1] : '+',
href: 'javascript:;'
});
$.on(a, 'click', Header.toggleBoardList);
return a;
}
if (/^external/.test(t)) {
a = $.el('a', {
href: (t.match(/\,"(.+)"/) || [null, '+'])[1],
textContent: (t.match(/-text:"(.+)"\,/) || [null, '+'])[1],
className: 'external'
});
if (a.hostname === 'boards.4chan.org' && a.pathname.split('/')[1] === g.BOARD.ID) {
a.className += ' current';
if (url = t.match(/\,"(.+)"/)) {
a = $.el('a', {
textContent: (match = t.match(/-text:"(.+)"\,/)) ? match[1] : '+',
className: 'external',
href: url[1]
});
if (a.hostname === 'boards.4chan.org' && a.pathname.split('/')[1] === g.BOARD.ID) {
a.className += ' current';
}
return a;
}
return a;
}
board = /^current/.test(t) ? g.BOARD.ID : t.match(/^[^-]+/)[0];
boardID = t.split('-')[0];
@ -15059,7 +15061,7 @@
_ref = $$("#board-list a:not(.catalog), #boardNavDesktopFoot a");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
if (((_ref1 = a.hostname) !== 'boards.4chan.org' && _ref1 !== 'catalog.neet.tv' && _ref1 !== '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan')) {
if (((_ref1 = a.hostname) !== 'boards.4chan.org' && _ref1 !== 'catalog.neet.tv' && _ref1 !== '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan') || $.hasClass(a, 'external')) {
continue;
}
a.href = generateURL(board);

View File

@ -151,20 +151,21 @@ Header =
if /^toggle-all/.test t
a = $.el 'a',
className: 'show-board-list-button'
textContent: (t.match(/-text:"(.+)"/) || [null, '+'])[1]
href: 'javascript:;'
className: 'show-board-list-button'
textContent: if match = t.match /-text:"(.+)"/ then match[1] else '+'
href: 'javascript:;'
$.on a, 'click', Header.toggleBoardList
return a
if /^external/.test t
a = $.el 'a',
href: (t.match(/\,"(.+)"/) || [null, '+'])[1]
textContent: (t.match(/-text:"(.+)"\,/) || [null, '+'])[1]
className: 'external'
if a.hostname is 'boards.4chan.org' and a.pathname.split('/')[1] is g.BOARD.ID
a.className += ' current'
return a
if url = t.match /\,"(.+)"/
a = $.el 'a',
textContent: if match = t.match /-text:"(.+)"\,/ then match[1] else '+'
className: 'external'
href: url[1]
if a.hostname is 'boards.4chan.org' and a.pathname.split('/')[1] is g.BOARD.ID
a.className += ' current'
return a
board = if /^current/.test t
g.BOARD.ID

View File

@ -34,7 +34,8 @@ CatalogLinks =
for a in $$ """#board-list a:not(.catalog), #boardNavDesktopFoot a"""
continue if a.hostname not in ['boards.4chan.org', 'catalog.neet.tv', '4index.gropes.us'] or
!(board = a.pathname.split('/')[1]) or
board in ['f', 'status', '4chan']
board in ['f', 'status', '4chan'] or
$.hasClass a, 'external'
# Href is easier than pathname because then we don't have
# conditions where External Catalog has been disabled between switches.