Merge branch 'master' of https://github.com/MayhemYDG/4chan-x into pull-request
This commit is contained in:
commit
f3149a314b
@ -319,8 +319,9 @@
|
|||||||
return $.on(d, 'DOMContentLoaded', cb);
|
return $.on(d, 'DOMContentLoaded', cb);
|
||||||
},
|
},
|
||||||
sync: function(key, cb) {
|
sync: function(key, cb) {
|
||||||
|
key = Main.namespace + key;
|
||||||
return $.on(window, 'storage', function(e) {
|
return $.on(window, 'storage', function(e) {
|
||||||
if (e.key === ("" + Main.namespace + key)) {
|
if (e.key === key) {
|
||||||
return cb(JSON.parse(e.newValue));
|
return cb(JSON.parse(e.newValue));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1043,7 +1044,10 @@
|
|||||||
ThreadHiding = {
|
ThreadHiding = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var a, hiddenThreads, thread, _i, _len, _ref;
|
var a, hiddenThreads, thread, _i, _len, _ref;
|
||||||
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
|
hiddenThreads = ThreadHiding.sync();
|
||||||
|
if (g.CATALOG) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_ref = $$('.thread');
|
_ref = $$('.thread');
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
thread = _ref[_i];
|
thread = _ref[_i];
|
||||||
@ -1059,6 +1063,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
sync: function() {
|
||||||
|
var hiddenThreads, hiddenThreadsCatalog, id;
|
||||||
|
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
|
||||||
|
hiddenThreadsCatalog = JSON.parse(localStorage.getItem("4chan-hide-t-" + g.BOARD));
|
||||||
|
if (g.CATALOG) {
|
||||||
|
for (id in hiddenThreads) {
|
||||||
|
hiddenThreadsCatalog[id] = true;
|
||||||
|
}
|
||||||
|
localStorage.setItem("4chan-hide-t-" + g.BOARD, JSON.stringify(hiddenThreadsCatalog));
|
||||||
|
} else {
|
||||||
|
for (id in hiddenThreadsCatalog) {
|
||||||
|
if (!(id in hiddenThreads)) {
|
||||||
|
hiddenThreads[id] = Date.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
|
||||||
|
}
|
||||||
|
return hiddenThreads;
|
||||||
|
},
|
||||||
cb: function() {
|
cb: function() {
|
||||||
return ThreadHiding.toggle($.x('ancestor::div[parent::div[@class="board"]]', this));
|
return ThreadHiding.toggle($.x('ancestor::div[parent::div[@class="board"]]', this));
|
||||||
},
|
},
|
||||||
@ -4199,7 +4222,10 @@
|
|||||||
FileInfo.node(post);
|
FileInfo.node(post);
|
||||||
}
|
}
|
||||||
if (Conf['Resurrect Quotes']) {
|
if (Conf['Resurrect Quotes']) {
|
||||||
return Quotify.node(post);
|
Quotify.node(post);
|
||||||
|
}
|
||||||
|
if (Conf['Anonymize']) {
|
||||||
|
return Anonymize.node(post);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.on(this, 'mousemove', UI.hover);
|
$.on(this, 'mousemove', UI.hover);
|
||||||
@ -5218,16 +5244,18 @@
|
|||||||
|
|
||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var cutoff, hiddenThreads, id, key, now, path, pathname, settings, temp, timestamp, val, _ref;
|
var key, path, pathname, settings, temp, val;
|
||||||
Main.flatten(null, Config);
|
Main.flatten(null, Config);
|
||||||
path = location.pathname;
|
path = location.pathname;
|
||||||
pathname = path.slice(1).split('/');
|
pathname = path.slice(1).split('/');
|
||||||
g.BOARD = pathname[0], temp = pathname[1];
|
g.BOARD = pathname[0], temp = pathname[1];
|
||||||
if (temp === 'res') {
|
switch (temp) {
|
||||||
g.REPLY = true;
|
case 'res':
|
||||||
g.THREAD_ID = pathname[2];
|
g.REPLY = true;
|
||||||
} else if (temp === 'catalog') {
|
g.THREAD_ID = pathname[2];
|
||||||
g.CATALOG = true;
|
break;
|
||||||
|
case 'catalog':
|
||||||
|
g.CATALOG = true;
|
||||||
}
|
}
|
||||||
for (key in Conf) {
|
for (key in Conf) {
|
||||||
val = Conf[key];
|
val = Conf[key];
|
||||||
@ -5275,6 +5303,22 @@
|
|||||||
settings.disableAll = true;
|
settings.disableAll = true;
|
||||||
localStorage.setItem('4chan-settings', JSON.stringify(settings));
|
localStorage.setItem('4chan-settings', JSON.stringify(settings));
|
||||||
}
|
}
|
||||||
|
if (g.CATALOG) {
|
||||||
|
return $.ready(Main.catalog);
|
||||||
|
} else {
|
||||||
|
return Main.features();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
catalog: function() {
|
||||||
|
if (Conf['Catalog Links']) {
|
||||||
|
CatalogLinks.init();
|
||||||
|
}
|
||||||
|
if (Conf['Thread Hiding']) {
|
||||||
|
return ThreadHiding.init();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
features: function() {
|
||||||
|
var cutoff, hiddenThreads, id, now, timestamp, _ref;
|
||||||
Options.init();
|
Options.init();
|
||||||
if (Conf['Quick Reply'] && Conf['Hide Original Post Form']) {
|
if (Conf['Quick Reply'] && Conf['Hide Original Post Form']) {
|
||||||
Main.css += '#postForm { display: none; }';
|
Main.css += '#postForm { display: none; }';
|
||||||
@ -5377,9 +5421,9 @@
|
|||||||
if (Conf['Indicate Cross-thread Quotes']) {
|
if (Conf['Indicate Cross-thread Quotes']) {
|
||||||
QuoteCT.init();
|
QuoteCT.init();
|
||||||
}
|
}
|
||||||
return $.ready(Main.ready);
|
return $.ready(Main.featuresReady);
|
||||||
},
|
},
|
||||||
ready: function() {
|
featuresReady: function() {
|
||||||
var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1;
|
var MutationObserver, a, board, nav, node, nodes, observer, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (/^4chan - 404/.test(d.title)) {
|
if (/^4chan - 404/.test(d.title)) {
|
||||||
if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
|
if (Conf['404 Redirect'] && /^\d+$/.test(g.THREAD_ID)) {
|
||||||
@ -5404,15 +5448,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Favicon.init();
|
Favicon.init();
|
||||||
if (Conf['Catalog Links']) {
|
|
||||||
CatalogLinks.init();
|
|
||||||
}
|
|
||||||
if (Conf['Quick Reply']) {
|
if (Conf['Quick Reply']) {
|
||||||
QR.init();
|
QR.init();
|
||||||
}
|
}
|
||||||
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,6 +1,10 @@
|
|||||||
master
|
master
|
||||||
- noface
|
- noface
|
||||||
Add Catalog Links toggle.
|
Add Catalog Links toggle.
|
||||||
|
Fix Anonymize not working on hovered posts.
|
||||||
|
- Mayhem
|
||||||
|
Added catalog support:
|
||||||
|
Sync thread hiding between index and catalog.
|
||||||
|
|
||||||
2.36.3
|
2.36.3
|
||||||
- Mayhem
|
- Mayhem
|
||||||
|
|||||||
@ -270,8 +270,9 @@ $.extend $,
|
|||||||
fc()
|
fc()
|
||||||
$.on d, 'DOMContentLoaded', cb
|
$.on d, 'DOMContentLoaded', cb
|
||||||
sync: (key, cb) ->
|
sync: (key, cb) ->
|
||||||
|
key = Main.namespace + key
|
||||||
$.on window, 'storage', (e) ->
|
$.on window, 'storage', (e) ->
|
||||||
cb JSON.parse e.newValue if e.key is "#{Main.namespace}#{key}"
|
cb JSON.parse e.newValue if e.key is key
|
||||||
id: (id) ->
|
id: (id) ->
|
||||||
d.getElementById id
|
d.getElementById id
|
||||||
formData: (arg) ->
|
formData: (arg) ->
|
||||||
@ -833,7 +834,8 @@ ExpandThread =
|
|||||||
|
|
||||||
ThreadHiding =
|
ThreadHiding =
|
||||||
init: ->
|
init: ->
|
||||||
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
hiddenThreads = ThreadHiding.sync()
|
||||||
|
return if g.CATALOG
|
||||||
for thread in $$ '.thread'
|
for thread in $$ '.thread'
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
className: 'hide_thread_button'
|
className: 'hide_thread_button'
|
||||||
@ -846,6 +848,20 @@ ThreadHiding =
|
|||||||
ThreadHiding.hide thread
|
ThreadHiding.hide thread
|
||||||
return
|
return
|
||||||
|
|
||||||
|
sync: ->
|
||||||
|
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
||||||
|
hiddenThreadsCatalog = JSON.parse localStorage.getItem "4chan-hide-t-#{g.BOARD}"
|
||||||
|
if g.CATALOG
|
||||||
|
for id of hiddenThreads
|
||||||
|
hiddenThreadsCatalog[id] = true
|
||||||
|
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify hiddenThreadsCatalog
|
||||||
|
else
|
||||||
|
for id of hiddenThreadsCatalog
|
||||||
|
unless id of hiddenThreads
|
||||||
|
hiddenThreads[id] = Date.now()
|
||||||
|
$.set "hiddenThreads/#{g.BOARD}/", hiddenThreads
|
||||||
|
hiddenThreads
|
||||||
|
|
||||||
cb: ->
|
cb: ->
|
||||||
ThreadHiding.toggle $.x 'ancestor::div[parent::div[@class="board"]]', @
|
ThreadHiding.toggle $.x 'ancestor::div[parent::div[@class="board"]]', @
|
||||||
|
|
||||||
@ -3449,6 +3465,8 @@ QuotePreview =
|
|||||||
FileInfo.node post
|
FileInfo.node post
|
||||||
if Conf['Resurrect Quotes']
|
if Conf['Resurrect Quotes']
|
||||||
Quotify.node post
|
Quotify.node post
|
||||||
|
if Conf['Anonymize']
|
||||||
|
Anonymize.node post
|
||||||
|
|
||||||
$.on @, 'mousemove', UI.hover
|
$.on @, 'mousemove', UI.hover
|
||||||
$.on @, 'mouseout click', QuotePreview.mouseout
|
$.on @, 'mouseout click', QuotePreview.mouseout
|
||||||
@ -4197,20 +4215,20 @@ CatalogLinks =
|
|||||||
while a.href and split = a.href.split '/'
|
while a.href and split = a.href.split '/'
|
||||||
unless /^rs|status/.test split[2]
|
unless /^rs|status/.test split[2]
|
||||||
if (isDead = split[3] is 'f') and g.CATALOG or split[4] is 'catalog'
|
if (isDead = split[3] is 'f') and g.CATALOG or split[4] is 'catalog'
|
||||||
a.href = a.href.replace /catalog$/, ''
|
a.href = a.href.replace /catalog$/, ''
|
||||||
a.title = a.title.replace /\ -\ Catalog$/, ''
|
a.title = a.title.replace /\ -\ Catalog$/, ''
|
||||||
else if not isDead
|
else if not isDead
|
||||||
a.href += 'catalog'
|
a.href += 'catalog'
|
||||||
a.title += ' - Catalog'
|
a.title += ' - Catalog'
|
||||||
a = a.nextElementSibling
|
a = a.nextElementSibling
|
||||||
|
|
||||||
if /On$/.test (el = a.parentNode.lastChild.firstElementChild).textContent
|
if /On$/.test (el = a.parentNode.lastChild.firstElementChild).textContent
|
||||||
el.textContent = 'Catalog Off'
|
el.textContent = 'Catalog Off'
|
||||||
el.title = 'Turn Catalog Links off.'
|
el.title = 'Turn Catalog Links off.'
|
||||||
$.set 'CatalogIsToggled', true
|
$.set 'CatalogIsToggled', true
|
||||||
else
|
else
|
||||||
el.textContent = 'Catalog On'
|
el.textContent = 'Catalog On'
|
||||||
el.title = 'Turn Catalog Links on.'
|
el.title = 'Turn Catalog Links on.'
|
||||||
$.delete 'CatalogIsToggled'
|
$.delete 'CatalogIsToggled'
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -4221,11 +4239,12 @@ Main =
|
|||||||
path = location.pathname
|
path = location.pathname
|
||||||
pathname = path[1..].split '/'
|
pathname = path[1..].split '/'
|
||||||
[g.BOARD, temp] = pathname
|
[g.BOARD, temp] = pathname
|
||||||
if temp is 'res'
|
switch temp
|
||||||
g.REPLY = true
|
when 'res'
|
||||||
g.THREAD_ID = pathname[2]
|
g.REPLY = true
|
||||||
else if temp is 'catalog'
|
g.THREAD_ID = pathname[2]
|
||||||
g.CATALOG = true
|
when 'catalog'
|
||||||
|
g.CATALOG = true
|
||||||
|
|
||||||
# Load values from localStorage.
|
# Load values from localStorage.
|
||||||
for key, val of Conf
|
for key, val of Conf
|
||||||
@ -4258,6 +4277,19 @@ Main =
|
|||||||
settings.disableAll = true
|
settings.disableAll = true
|
||||||
localStorage.setItem '4chan-settings', JSON.stringify settings
|
localStorage.setItem '4chan-settings', JSON.stringify settings
|
||||||
|
|
||||||
|
if g.CATALOG
|
||||||
|
$.ready Main.catalog
|
||||||
|
else
|
||||||
|
Main.features()
|
||||||
|
|
||||||
|
catalog: ->
|
||||||
|
if Conf['Catalog Links']
|
||||||
|
CatalogLinks.init()
|
||||||
|
|
||||||
|
if Conf['Thread Hiding']
|
||||||
|
ThreadHiding.init()
|
||||||
|
|
||||||
|
features: ->
|
||||||
Options.init()
|
Options.init()
|
||||||
|
|
||||||
if Conf['Quick Reply'] and Conf['Hide Original Post Form']
|
if Conf['Quick Reply'] and Conf['Hide Original Post Form']
|
||||||
@ -4359,9 +4391,9 @@ Main =
|
|||||||
if Conf['Indicate Cross-thread Quotes']
|
if Conf['Indicate Cross-thread Quotes']
|
||||||
QuoteCT.init()
|
QuoteCT.init()
|
||||||
|
|
||||||
$.ready Main.ready
|
$.ready Main.featuresReady
|
||||||
|
|
||||||
ready: ->
|
featuresReady: ->
|
||||||
if /^4chan - 404/.test d.title
|
if /^4chan - 404/.test d.title
|
||||||
if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID
|
if Conf['404 Redirect'] and /^\d+$/.test g.THREAD_ID
|
||||||
location.href =
|
location.href =
|
||||||
@ -4380,9 +4412,6 @@ 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()
|
||||||
@ -4390,6 +4419,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