Add Catalog Links toggle.
This commit is contained in:
parent
fdaee4641e
commit
c307874b10
@ -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'],
|
||||||
@ -5155,6 +5156,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 cutoff, hiddenThreads, id, key, now, path, pathname, settings, temp, timestamp, val, _ref;
|
var cutoff, hiddenThreads, id, key, now, path, pathname, settings, temp, timestamp, val, _ref;
|
||||||
@ -5165,6 +5226,8 @@
|
|||||||
if (temp === 'res') {
|
if (temp === 'res') {
|
||||||
g.REPLY = true;
|
g.REPLY = true;
|
||||||
g.THREAD_ID = pathname[2];
|
g.THREAD_ID = pathname[2];
|
||||||
|
} else if (temp === 'catalog') {
|
||||||
|
g.CATALOG = true;
|
||||||
}
|
}
|
||||||
for (key in Conf) {
|
for (key in Conf) {
|
||||||
val = Conf[key];
|
val = Conf[key];
|
||||||
@ -5341,6 +5404,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Favicon.init();
|
Favicon.init();
|
||||||
|
if (Conf['Catalog Links']) {
|
||||||
|
CatalogLinks.init();
|
||||||
|
}
|
||||||
if (Conf['Quick Reply']) {
|
if (Conf['Quick Reply']) {
|
||||||
QR.init();
|
QR.init();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
master
|
master
|
||||||
|
- noface
|
||||||
|
Add Catalog Links toggle.
|
||||||
|
|
||||||
2.36.3
|
2.36.3
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
|||||||
@ -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']
|
||||||
@ -4171,6 +4172,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
|
||||||
@ -4181,6 +4224,8 @@ Main =
|
|||||||
if temp is 'res'
|
if temp is 'res'
|
||||||
g.REPLY = true
|
g.REPLY = true
|
||||||
g.THREAD_ID = pathname[2]
|
g.THREAD_ID = pathname[2]
|
||||||
|
else if temp is 'catalog'
|
||||||
|
g.CATALOG = true
|
||||||
|
|
||||||
# Load values from localStorage.
|
# Load values from localStorage.
|
||||||
for key, val of Conf
|
for key, val of Conf
|
||||||
@ -4335,6 +4380,9 @@ Main =
|
|||||||
$.addClass a, 'current'
|
$.addClass a, 'current'
|
||||||
Favicon.init()
|
Favicon.init()
|
||||||
|
|
||||||
|
if Conf['Catalog Links']
|
||||||
|
CatalogLinks.init()
|
||||||
|
|
||||||
# Major features.
|
# Major features.
|
||||||
if Conf['Quick Reply']
|
if Conf['Quick Reply']
|
||||||
QR.init()
|
QR.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user