Merge branch 'master' of github.com:MayhemYDG/4chan-x into qr
Conflicts: 4chan_x.user.js script.coffee
This commit is contained in:
commit
ee46bafff3
@ -304,6 +304,15 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.extend($, {
|
$.extend($, {
|
||||||
|
onLoad: function(fc) {
|
||||||
|
var cb;
|
||||||
|
if (/interactive|complete/.test(d.readyState)) return fc();
|
||||||
|
cb = function() {
|
||||||
|
$.off(d, 'DOMContentLoaded', cb);
|
||||||
|
return fc();
|
||||||
|
};
|
||||||
|
return $.on(d, 'DOMContentLoaded', cb);
|
||||||
|
},
|
||||||
id: function(id) {
|
id: function(id) {
|
||||||
return d.getElementById(id);
|
return d.getElementById(id);
|
||||||
},
|
},
|
||||||
@ -1604,10 +1613,10 @@
|
|||||||
time: function() {
|
time: function() {
|
||||||
Time.foo();
|
Time.foo();
|
||||||
Time.date = new Date();
|
Time.date = new Date();
|
||||||
return $('#timePreview').textContent = Time.funk(Time);
|
return $.id('timePreview').textContent = Time.funk(Time);
|
||||||
},
|
},
|
||||||
backlink: function() {
|
backlink: function() {
|
||||||
return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789');
|
return $.id('backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789');
|
||||||
},
|
},
|
||||||
favicon: function() {
|
favicon: function() {
|
||||||
Favicon["switch"]();
|
Favicon["switch"]();
|
||||||
@ -2879,7 +2888,7 @@
|
|||||||
|
|
||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, update, _ref;
|
var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, _ref;
|
||||||
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') {
|
||||||
@ -2888,20 +2897,27 @@
|
|||||||
} else {
|
} else {
|
||||||
g.PAGENUM = parseInt(temp) || 0;
|
g.PAGENUM = parseInt(temp) || 0;
|
||||||
}
|
}
|
||||||
|
if (location.hostname === 'sys.4chan.org') {
|
||||||
|
$.onLoad(qr.sys);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (location.hostname === 'images.4chan.org') {
|
||||||
|
if (conf['404 Redirect']) {
|
||||||
|
$.onLoad(function() {
|
||||||
|
if (d.title === '4chan - 404') return redirect.init();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.onLoad(options.init);
|
||||||
$.on(window, 'message', Main.message);
|
$.on(window, 'message', Main.message);
|
||||||
now = Date.now();
|
now = Date.now();
|
||||||
if (conf['Check for Updates'] && $.get('lastUpdate', 0) < now - 6 * HOUR) {
|
if (conf['Check for Updates'] && $.get('lastUpdate', 0) < now - 6 * HOUR) {
|
||||||
update = function() {
|
$.onLoad(function() {
|
||||||
$.off(d, 'DOMContentLoaded', update);
|
|
||||||
return $.add(d.head, $.el('script', {
|
return $.add(d.head, $.el('script', {
|
||||||
src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
||||||
}));
|
}));
|
||||||
};
|
});
|
||||||
if (/interactive|complete/.test(d.readyState)) {
|
|
||||||
update();
|
|
||||||
} else {
|
|
||||||
$.on(d, 'DOMContentLoaded', update);
|
|
||||||
}
|
|
||||||
$.set('lastUpdate', now);
|
$.set('lastUpdate', now);
|
||||||
}
|
}
|
||||||
g.hiddenReplies = $.get("hiddenReplies/" + g.BOARD + "/", {});
|
g.hiddenReplies = $.get("hiddenReplies/" + g.BOARD + "/", {});
|
||||||
@ -2935,20 +2951,15 @@
|
|||||||
if (conf['Quote Backlinks']) quoteBacklink.init();
|
if (conf['Quote Backlinks']) quoteBacklink.init();
|
||||||
if (conf['Indicate OP quote']) quoteOP.init();
|
if (conf['Indicate OP quote']) quoteOP.init();
|
||||||
if (conf['Indicate Cross-thread Quotes']) quoteDR.init();
|
if (conf['Indicate Cross-thread Quotes']) quoteDR.init();
|
||||||
if (/interactive|complete/.test(d.readyState)) {
|
return $.onLoad(Main.onLoad);
|
||||||
return Main.onLoad();
|
|
||||||
} else {
|
|
||||||
return $.on(d, 'DOMContentLoaded', Main.onLoad);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
var callback, node, nodes, _i, _j, _len, _len2, _ref;
|
var callback, node, nodes, _i, _j, _len, _len2, _ref;
|
||||||
$.off(d, 'DOMContentLoaded', Main.onLoad);
|
|
||||||
if (conf['404 Redirect'] && d.title === '4chan - 404') {
|
if (conf['404 Redirect'] && d.title === '4chan - 404') {
|
||||||
redirect.init();
|
redirect.init();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$('#navtopr') || location.hostname === 'images.4chan.org') return;
|
if (!$.id('navtopr')) return;
|
||||||
$.addClass(d.body, engine);
|
$.addClass(d.body, engine);
|
||||||
$.addStyle(Main.css);
|
$.addStyle(Main.css);
|
||||||
threading.init();
|
threading.init();
|
||||||
@ -2982,8 +2993,7 @@
|
|||||||
alert(err);
|
alert(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.on($('form[name=delform]'), 'DOMNodeInserted', Main.node);
|
return $.on($('form[name=delform]'), 'DOMNodeInserted', Main.node);
|
||||||
return options.init();
|
|
||||||
},
|
},
|
||||||
message: function(e) {
|
message: function(e) {
|
||||||
var version;
|
var version;
|
||||||
|
|||||||
@ -221,6 +221,13 @@ $.extend = (object, properties) ->
|
|||||||
object
|
object
|
||||||
|
|
||||||
$.extend $,
|
$.extend $,
|
||||||
|
onLoad: (fc) ->
|
||||||
|
if /interactive|complete/.test d.readyState
|
||||||
|
return fc()
|
||||||
|
cb = ->
|
||||||
|
$.off d, 'DOMContentLoaded', cb
|
||||||
|
fc()
|
||||||
|
$.on d, 'DOMContentLoaded', cb
|
||||||
id: (id) ->
|
id: (id) ->
|
||||||
d.getElementById id
|
d.getElementById id
|
||||||
ajax: (url, cb, opts={}) ->
|
ajax: (url, cb, opts={}) ->
|
||||||
@ -1324,9 +1331,9 @@ options =
|
|||||||
time: ->
|
time: ->
|
||||||
Time.foo()
|
Time.foo()
|
||||||
Time.date = new Date()
|
Time.date = new Date()
|
||||||
$('#timePreview').textContent = Time.funk Time
|
$.id('timePreview').textContent = Time.funk Time
|
||||||
backlink: ->
|
backlink: ->
|
||||||
$('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789'
|
$.id('backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789'
|
||||||
favicon: ->
|
favicon: ->
|
||||||
Favicon.switch()
|
Favicon.switch()
|
||||||
Favicon.update() if g.REPLY and conf['Unread Count']
|
Favicon.update() if g.REPLY and conf['Unread Count']
|
||||||
@ -2282,17 +2289,21 @@ Main =
|
|||||||
else
|
else
|
||||||
g.PAGENUM = parseInt(temp) or 0
|
g.PAGENUM = parseInt(temp) or 0
|
||||||
|
|
||||||
|
if location.hostname is 'sys.4chan.org'
|
||||||
|
$.onLoad qr.sys
|
||||||
|
return
|
||||||
|
if location.hostname is 'images.4chan.org'
|
||||||
|
if conf['404 Redirect']
|
||||||
|
$.onLoad -> redirect.init() if d.title is '4chan - 404'
|
||||||
|
return
|
||||||
|
|
||||||
|
$.onLoad options.init
|
||||||
|
|
||||||
$.on window, 'message', Main.message
|
$.on window, 'message', Main.message
|
||||||
|
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
if conf['Check for Updates'] and $.get('lastUpdate', 0) < now - 6*HOUR
|
if conf['Check for Updates'] and $.get('lastUpdate', 0) < now - 6*HOUR
|
||||||
update = ->
|
$.onLoad -> $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
||||||
$.off d, 'DOMContentLoaded', update
|
|
||||||
$.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
|
|
||||||
if /interactive|complete/.test d.readyState
|
|
||||||
update()
|
|
||||||
else
|
|
||||||
$.on d, 'DOMContentLoaded', update
|
|
||||||
$.set 'lastUpdate', now
|
$.set 'lastUpdate', now
|
||||||
|
|
||||||
g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {}
|
g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {}
|
||||||
@ -2358,17 +2369,13 @@ Main =
|
|||||||
quoteDR.init()
|
quoteDR.init()
|
||||||
|
|
||||||
|
|
||||||
if /interactive|complete/.test d.readyState
|
$.onLoad Main.onLoad
|
||||||
Main.onLoad()
|
|
||||||
else
|
|
||||||
$.on d, 'DOMContentLoaded', Main.onLoad
|
|
||||||
|
|
||||||
onLoad: ->
|
onLoad: ->
|
||||||
$.off d, 'DOMContentLoaded', Main.onLoad
|
|
||||||
if conf['404 Redirect'] and d.title is '4chan - 404'
|
if conf['404 Redirect'] and d.title is '4chan - 404'
|
||||||
redirect.init()
|
redirect.init()
|
||||||
return
|
return
|
||||||
if not $('#navtopr') or location.hostname is 'images.4chan.org'
|
if not $.id 'navtopr'
|
||||||
return
|
return
|
||||||
$.addClass d.body, engine
|
$.addClass d.body, engine
|
||||||
$.addStyle Main.css
|
$.addStyle Main.css
|
||||||
@ -2426,7 +2433,6 @@ Main =
|
|||||||
catch err
|
catch err
|
||||||
alert err
|
alert err
|
||||||
$.on $('form[name=delform]'), 'DOMNodeInserted', Main.node
|
$.on $('form[name=delform]'), 'DOMNodeInserted', Main.node
|
||||||
options.init()
|
|
||||||
|
|
||||||
message: (e) ->
|
message: (e) ->
|
||||||
{version} = e.data
|
{version} = e.data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user