Merge pull request #838 from ihavenoface/pull-request
Add Catalog Links toggle.
This commit is contained in:
commit
2f5f8577ea
@ -81,12 +81,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, ArchiveLink, AutoGif, Build, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
var $, $$, Anonymize, ArchiveLink, AutoGif, Build, CatalogLinks, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
||||||
|
|
||||||
Config = {
|
Config = {
|
||||||
main: {
|
main: {
|
||||||
Enhancing: {
|
Enhancing: {
|
||||||
'Disable 4chan\'s extension': [true, 'Avoid conflicts between 4chan X and 4chan\'s inline extension.'],
|
'Disable 4chan\'s extension': [true, 'Avoid conflicts between 4chan X and 4chan\'s inline extension.'],
|
||||||
|
'Catalog Links': [true, 'Turn Navigation links into links to each board\'s catalog.'],
|
||||||
'404 Redirect': [true, 'Redirect dead threads and images'],
|
'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'],
|
||||||
@ -5186,6 +5187,66 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CatalogLinks = {
|
||||||
|
init: function() {
|
||||||
|
var el, i, nav, _i, _len, _ref;
|
||||||
|
el = $.el('span', {
|
||||||
|
innerHTML: "[<a href=javascript:; title='Toggle Catalog Links " + (!g.CATALOG ? 'on.' : 'off.') + "'>Catalog " + (!g.CATALOG ? 'On' : 'Off') + "</a>]",
|
||||||
|
id: 'toggleCatalog'
|
||||||
|
});
|
||||||
|
_ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
nav = _ref[_i];
|
||||||
|
$.on(el.firstElementChild, 'click', this.toggle);
|
||||||
|
$.add($.id(nav), el);
|
||||||
|
el = $.el('span', {
|
||||||
|
innerHTML: el.innerHTML,
|
||||||
|
id: 'toggleCatalogFoot'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if ($.get('CatalogIsToggled')) {
|
||||||
|
i = g.CATALOG ? 0 : 1;
|
||||||
|
while (i < 2) {
|
||||||
|
this.toggle();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (g.CATALOG) {
|
||||||
|
return this.toggle();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggle: function() {
|
||||||
|
var a, el, isDead, nav, split, _i, _len, _ref;
|
||||||
|
_ref = ['boardNavDesktop', 'boardNavDesktopFoot'];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
nav = _ref[_i];
|
||||||
|
a = $.id(nav).firstElementChild;
|
||||||
|
while (a.href && (split = a.href.split('/'))) {
|
||||||
|
if (!/^rs|status/.test(split[2])) {
|
||||||
|
if ((isDead = split[3] === 'f') && g.CATALOG || split[4] === 'catalog') {
|
||||||
|
a.href = a.href.replace(/catalog$/, '');
|
||||||
|
a.title = a.title.replace(/\ -\ Catalog$/, '');
|
||||||
|
} else if (!isDead) {
|
||||||
|
a.href += 'catalog';
|
||||||
|
a.title += ' - Catalog';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a = a.nextElementSibling;
|
||||||
|
}
|
||||||
|
if (/On$/.test((el = a.parentNode.lastChild.firstElementChild).textContent)) {
|
||||||
|
el.textContent = 'Catalog Off';
|
||||||
|
el.title = 'Turn Catalog Links off.';
|
||||||
|
$.set('CatalogIsToggled', true);
|
||||||
|
} else {
|
||||||
|
el.textContent = 'Catalog On';
|
||||||
|
el.title = 'Turn Catalog Links on.';
|
||||||
|
$["delete"]('CatalogIsToggled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var key, path, pathname, settings, temp, val;
|
var key, path, pathname, settings, temp, val;
|
||||||
@ -5254,6 +5315,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
catalog: function() {
|
catalog: function() {
|
||||||
|
if (Conf['Catalog Links']) {
|
||||||
|
CatalogLinks.init();
|
||||||
|
}
|
||||||
if (Conf['Thread Hiding']) {
|
if (Conf['Thread Hiding']) {
|
||||||
return ThreadHiding.init();
|
return ThreadHiding.init();
|
||||||
}
|
}
|
||||||
@ -5395,6 +5459,9 @@
|
|||||||
if (Conf['Image Expansion']) {
|
if (Conf['Image Expansion']) {
|
||||||
ImageExpand.init();
|
ImageExpand.init();
|
||||||
}
|
}
|
||||||
|
if (Conf['Catalog Links']) {
|
||||||
|
CatalogLinks.init();
|
||||||
|
}
|
||||||
if (Conf['Thread Watcher']) {
|
if (Conf['Thread Watcher']) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
return Watcher.init();
|
return Watcher.init();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
master
|
master
|
||||||
- noface
|
- noface
|
||||||
|
Add Catalog Links toggle.
|
||||||
Fix Anonymize not working on hovered posts.
|
Fix Anonymize not working on hovered posts.
|
||||||
- Mayhem
|
- Mayhem
|
||||||
Added catalog support:
|
Added catalog support:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ Config =
|
|||||||
main:
|
main:
|
||||||
Enhancing:
|
Enhancing:
|
||||||
'Disable 4chan\'s extension': [true, 'Avoid conflicts between 4chan X and 4chan\'s inline extension.']
|
'Disable 4chan\'s extension': [true, 'Avoid conflicts between 4chan X and 4chan\'s inline extension.']
|
||||||
|
'Catalog Links': [true, 'Turn Navigation links into links to each board\'s catalog.']
|
||||||
'404 Redirect': [true, 'Redirect dead threads and images']
|
'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']
|
||||||
@ -4193,6 +4194,48 @@ ImageExpand =
|
|||||||
resize: ->
|
resize: ->
|
||||||
ImageExpand.style.textContent = ".fitheight img[data-md5] + img {max-height:#{d.documentElement.clientHeight}px;}"
|
ImageExpand.style.textContent = ".fitheight img[data-md5] + img {max-height:#{d.documentElement.clientHeight}px;}"
|
||||||
|
|
||||||
|
CatalogLinks =
|
||||||
|
init: ->
|
||||||
|
el = $.el 'span',
|
||||||
|
innerHTML:
|
||||||
|
"[<a href=javascript:; title='Toggle Catalog Links #{unless g.CATALOG then 'on.' else 'off.'}'>Catalog #{unless g.CATALOG then 'On' else 'Off'}</a>]"
|
||||||
|
id: 'toggleCatalog'
|
||||||
|
for nav in ['boardNavDesktop', 'boardNavDesktopFoot']
|
||||||
|
$.on el.firstElementChild, 'click', @toggle
|
||||||
|
$.add $.id(nav), el
|
||||||
|
el = $.el 'span', innerHTML: el.innerHTML, id: 'toggleCatalogFoot'
|
||||||
|
|
||||||
|
if $.get 'CatalogIsToggled'
|
||||||
|
i = if g.CATALOG then 0 else 1
|
||||||
|
while i < 2
|
||||||
|
@toggle()
|
||||||
|
i++
|
||||||
|
return
|
||||||
|
@toggle() if g.CATALOG
|
||||||
|
|
||||||
|
toggle: ->
|
||||||
|
for nav in ['boardNavDesktop', 'boardNavDesktopFoot']
|
||||||
|
a = $.id(nav).firstElementChild
|
||||||
|
while a.href and split = a.href.split '/'
|
||||||
|
unless /^rs|status/.test split[2]
|
||||||
|
if (isDead = split[3] is 'f') and g.CATALOG or split[4] is 'catalog'
|
||||||
|
a.href = a.href.replace /catalog$/, ''
|
||||||
|
a.title = a.title.replace /\ -\ Catalog$/, ''
|
||||||
|
else if not isDead
|
||||||
|
a.href += 'catalog'
|
||||||
|
a.title += ' - Catalog'
|
||||||
|
a = a.nextElementSibling
|
||||||
|
|
||||||
|
if /On$/.test (el = a.parentNode.lastChild.firstElementChild).textContent
|
||||||
|
el.textContent = 'Catalog Off'
|
||||||
|
el.title = 'Turn Catalog Links off.'
|
||||||
|
$.set 'CatalogIsToggled', true
|
||||||
|
else
|
||||||
|
el.textContent = 'Catalog On'
|
||||||
|
el.title = 'Turn Catalog Links on.'
|
||||||
|
$.delete 'CatalogIsToggled'
|
||||||
|
return
|
||||||
|
|
||||||
Main =
|
Main =
|
||||||
init: ->
|
init: ->
|
||||||
Main.flatten null, Config
|
Main.flatten null, Config
|
||||||
@ -4244,6 +4287,9 @@ Main =
|
|||||||
Main.features()
|
Main.features()
|
||||||
|
|
||||||
catalog: ->
|
catalog: ->
|
||||||
|
if Conf['Catalog Links']
|
||||||
|
CatalogLinks.init()
|
||||||
|
|
||||||
if Conf['Thread Hiding']
|
if Conf['Thread Hiding']
|
||||||
ThreadHiding.init()
|
ThreadHiding.init()
|
||||||
|
|
||||||
@ -4377,6 +4423,9 @@ Main =
|
|||||||
if Conf['Image Expansion']
|
if Conf['Image Expansion']
|
||||||
ImageExpand.init()
|
ImageExpand.init()
|
||||||
|
|
||||||
|
if Conf['Catalog Links']
|
||||||
|
CatalogLinks.init()
|
||||||
|
|
||||||
if Conf['Thread Watcher']
|
if Conf['Thread Watcher']
|
||||||
setTimeout -> Watcher.init()
|
setTimeout -> Watcher.init()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user