mv namespace, version into Main
This commit is contained in:
parent
99fdde3633
commit
1e74512ac5
@ -73,7 +73,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, AutoGif, Conf, Config, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, ImageExpand, ImageHover, Keybinds, Main, NAMESPACE, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportButton, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Threading, Time, TitlePost, UI, Unread, Updater, VERSION, Watcher, flatten, _base;
|
var $, $$, Anonymize, AutoGif, Conf, Config, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, ImageExpand, ImageHover, Keybinds, Main, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportButton, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Threading, Time, TitlePost, UI, Unread, Updater, Watcher, flatten, _base;
|
||||||
|
|
||||||
Config = {
|
Config = {
|
||||||
main: {
|
main: {
|
||||||
@ -215,7 +215,7 @@
|
|||||||
el.className = 'reply dialog';
|
el.className = 'reply dialog';
|
||||||
el.innerHTML = html;
|
el.innerHTML = html;
|
||||||
el.id = id;
|
el.id = id;
|
||||||
el.style.cssText = (saved = localStorage["" + NAMESPACE + id + ".position"]) ? saved : position;
|
el.style.cssText = (saved = localStorage["" + Main.namespace + id + ".position"]) ? saved : position;
|
||||||
el.querySelector('.move').addEventListener('mousedown', UI.dragstart, false);
|
el.querySelector('.move').addEventListener('mousedown', UI.dragstart, false);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
@ -248,7 +248,7 @@
|
|||||||
dragend: function() {
|
dragend: function() {
|
||||||
var el;
|
var el;
|
||||||
el = UI.el;
|
el = UI.el;
|
||||||
localStorage["" + NAMESPACE + el.id + ".position"] = el.style.cssText;
|
localStorage["" + Main.namespace + el.id + ".position"] = el.style.cssText;
|
||||||
$.d.removeEventListener('mousemove', UI.drag, false);
|
$.d.removeEventListener('mousemove', UI.drag, false);
|
||||||
return $.d.removeEventListener('mouseup', UI.dragend, false);
|
return $.d.removeEventListener('mouseup', UI.dragend, false);
|
||||||
},
|
},
|
||||||
@ -294,10 +294,6 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NAMESPACE = '4chan_x.';
|
|
||||||
|
|
||||||
VERSION = '2.29.1';
|
|
||||||
|
|
||||||
$.extend($, {
|
$.extend($, {
|
||||||
SECOND: 1000,
|
SECOND: 1000,
|
||||||
MINUTE: 60 * $.SECOND,
|
MINUTE: 60 * $.SECOND,
|
||||||
@ -317,7 +313,9 @@
|
|||||||
},
|
},
|
||||||
sync: function(key, cb) {
|
sync: function(key, cb) {
|
||||||
return $.on(window, 'storage', function(e) {
|
return $.on(window, 'storage', function(e) {
|
||||||
if (e.key === ("" + NAMESPACE + key)) return cb(JSON.parse(e.newValue));
|
if (e.key === ("" + Main.namespace + key)) {
|
||||||
|
return cb(JSON.parse(e.newValue));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
id: function(id) {
|
id: function(id) {
|
||||||
@ -487,12 +485,12 @@
|
|||||||
|
|
||||||
$.extend($, typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null ? {
|
$.extend($, typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null ? {
|
||||||
"delete": function(name) {
|
"delete": function(name) {
|
||||||
name = NAMESPACE + name;
|
name = Main.namespace + name;
|
||||||
return GM_deleteValue(name);
|
return GM_deleteValue(name);
|
||||||
},
|
},
|
||||||
get: function(name, defaultValue) {
|
get: function(name, defaultValue) {
|
||||||
var value;
|
var value;
|
||||||
name = NAMESPACE + name;
|
name = Main.namespace + name;
|
||||||
if (value = GM_getValue(name)) {
|
if (value = GM_getValue(name)) {
|
||||||
return JSON.parse(value);
|
return JSON.parse(value);
|
||||||
} else {
|
} else {
|
||||||
@ -500,18 +498,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
set: function(name, value) {
|
set: function(name, value) {
|
||||||
name = NAMESPACE + name;
|
name = Main.namespace + name;
|
||||||
localStorage[name] = JSON.stringify(value);
|
localStorage[name] = JSON.stringify(value);
|
||||||
return GM_setValue(name, JSON.stringify(value));
|
return GM_setValue(name, JSON.stringify(value));
|
||||||
}
|
}
|
||||||
} : {
|
} : {
|
||||||
"delete": function(name) {
|
"delete": function(name) {
|
||||||
name = NAMESPACE + name;
|
name = Main.namespace + name;
|
||||||
return delete localStorage[name];
|
return delete localStorage[name];
|
||||||
},
|
},
|
||||||
get: function(name, defaultValue) {
|
get: function(name, defaultValue) {
|
||||||
var value;
|
var value;
|
||||||
name = NAMESPACE + name;
|
name = Main.namespace + name;
|
||||||
if (value = localStorage[name]) {
|
if (value = localStorage[name]) {
|
||||||
return JSON.parse(value);
|
return JSON.parse(value);
|
||||||
} else {
|
} else {
|
||||||
@ -519,7 +517,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
set: function(name, value) {
|
set: function(name, value) {
|
||||||
name = NAMESPACE + name;
|
name = Main.namespace + name;
|
||||||
return localStorage[name] = JSON.stringify(value);
|
return localStorage[name] = JSON.stringify(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2134,7 +2132,7 @@
|
|||||||
innerHTML: '<div id=optionsbar>\
|
innerHTML: '<div id=optionsbar>\
|
||||||
<div id=credits>\
|
<div id=credits>\
|
||||||
<a target=_blank href=http://mayhemydg.github.com/4chan-x/>4chan X</a>\
|
<a target=_blank href=http://mayhemydg.github.com/4chan-x/>4chan X</a>\
|
||||||
| <a target=_blank href=https://raw.github.com/mayhemydg/4chan-x/master/changelog>' + VERSION + '</a>\
|
| <a target=_blank href=https://raw.github.com/mayhemydg/4chan-x/master/changelog>' + Main.version + '</a>\
|
||||||
| <a target=_blank href=http://mayhemydg.github.com/4chan-x/#bug-report>Issues</a>\
|
| <a target=_blank href=http://mayhemydg.github.com/4chan-x/#bug-report>Issues</a>\
|
||||||
</div>\
|
</div>\
|
||||||
<div>\
|
<div>\
|
||||||
@ -3896,7 +3894,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$.id('navtopr')) return;
|
if (!$.id('navtopr')) return;
|
||||||
$.addClass($.d.body, "chanx_" + (VERSION.split('.')[1]));
|
$.addClass($.d.body, "chanx_" + (Main.version.split('.')[1]));
|
||||||
$.addClass($.d.body, $.engine);
|
$.addClass($.d.body, $.engine);
|
||||||
_ref = ['navtop', 'navbot'];
|
_ref = ['navtop', 'navbot'];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
@ -3987,7 +3985,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
version = data.version;
|
version = data.version;
|
||||||
if (version && version !== VERSION && confirm('An updated version of 4chan X is available, would you like to install it now?')) {
|
if (version && version !== Main.version && confirm('An updated version of 4chan X is available, would you like to install it now?')) {
|
||||||
return window.location = "https://raw.github.com/mayhemydg/4chan-x/" + version + "/4chan_x.user.js";
|
return window.location = "https://raw.github.com/mayhemydg/4chan-x/" + version + "/4chan_x.user.js";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -4021,7 +4019,7 @@
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
alert("4chan X (" + VERSION + ") error: " + err.message + "\nhttp://mayhemydg.github.com/4chan-x/#bug-report\n\n" + err.stack);
|
alert("4chan X (" + Main.version + ") error: " + err.message + "\nhttp://mayhemydg.github.com/4chan-x/#bug-report\n\n" + err.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4044,6 +4042,8 @@
|
|||||||
target = e.target;
|
target = e.target;
|
||||||
if (target.nodeName === 'TABLE') return Main.node([Main.preParse(target)]);
|
if (target.nodeName === 'TABLE') return Main.node([Main.preParse(target)]);
|
||||||
},
|
},
|
||||||
|
namespace: '4chan_x.',
|
||||||
|
version: '2.29.1',
|
||||||
callbacks: [],
|
callbacks: [],
|
||||||
css: '\
|
css: '\
|
||||||
/* dialog styling */\
|
/* dialog styling */\
|
||||||
|
|||||||
@ -173,7 +173,7 @@ UI =
|
|||||||
el.className = 'reply dialog'
|
el.className = 'reply dialog'
|
||||||
el.innerHTML = html
|
el.innerHTML = html
|
||||||
el.id = id
|
el.id = id
|
||||||
el.style.cssText = if saved = localStorage["#{NAMESPACE}#{id}.position"] then saved else position
|
el.style.cssText = if saved = localStorage["#{Main.namespace}#{id}.position"] then saved else position
|
||||||
el.querySelector('.move').addEventListener 'mousedown', UI.dragstart, false
|
el.querySelector('.move').addEventListener 'mousedown', UI.dragstart, false
|
||||||
el
|
el
|
||||||
dragstart: (e) ->
|
dragstart: (e) ->
|
||||||
@ -215,7 +215,7 @@ UI =
|
|||||||
#var a, b;
|
#var a, b;
|
||||||
#a = (b = c.b, c).a;
|
#a = (b = c.b, c).a;
|
||||||
{el} = UI
|
{el} = UI
|
||||||
localStorage["#{NAMESPACE}#{el.id}.position"] = el.style.cssText
|
localStorage["#{Main.namespace}#{el.id}.position"] = el.style.cssText
|
||||||
$.d.removeEventListener 'mousemove', UI.drag, false
|
$.d.removeEventListener 'mousemove', UI.drag, false
|
||||||
$.d.removeEventListener 'mouseup', UI.dragend, false
|
$.d.removeEventListener 'mouseup', UI.dragend, false
|
||||||
hover: (e) ->
|
hover: (e) ->
|
||||||
@ -258,9 +258,6 @@ $.extend = (object, properties) ->
|
|||||||
object[key] = val
|
object[key] = val
|
||||||
return
|
return
|
||||||
|
|
||||||
NAMESPACE = '4chan_x.'
|
|
||||||
VERSION = '2.29.1'
|
|
||||||
|
|
||||||
$.extend $,
|
$.extend $,
|
||||||
SECOND: 1000
|
SECOND: 1000
|
||||||
MINUTE: 60*$.SECOND
|
MINUTE: 60*$.SECOND
|
||||||
@ -282,7 +279,7 @@ $.extend $,
|
|||||||
$.on $.d, 'DOMContentLoaded', cb
|
$.on $.d, 'DOMContentLoaded', cb
|
||||||
sync: (key, cb) ->
|
sync: (key, cb) ->
|
||||||
$.on window, 'storage', (e) ->
|
$.on window, 'storage', (e) ->
|
||||||
cb JSON.parse e.newValue if e.key is "#{NAMESPACE}#{key}"
|
cb JSON.parse e.newValue if e.key is "#{Main.namespace}#{key}"
|
||||||
id: (id) ->
|
id: (id) ->
|
||||||
$.d.getElementById id
|
$.d.getElementById id
|
||||||
ajax: (url, callbacks, opts={}) ->
|
ajax: (url, callbacks, opts={}) ->
|
||||||
@ -421,31 +418,31 @@ $.cache.requests = {}
|
|||||||
$.extend $,
|
$.extend $,
|
||||||
if GM_deleteValue?
|
if GM_deleteValue?
|
||||||
delete: (name) ->
|
delete: (name) ->
|
||||||
name = NAMESPACE + name
|
name = Main.namespace + name
|
||||||
GM_deleteValue name
|
GM_deleteValue name
|
||||||
get: (name, defaultValue) ->
|
get: (name, defaultValue) ->
|
||||||
name = NAMESPACE + name
|
name = Main.namespace + name
|
||||||
if value = GM_getValue name
|
if value = GM_getValue name
|
||||||
JSON.parse value
|
JSON.parse value
|
||||||
else
|
else
|
||||||
defaultValue
|
defaultValue
|
||||||
set: (name, value) ->
|
set: (name, value) ->
|
||||||
name = NAMESPACE + name
|
name = Main.namespace + name
|
||||||
# for `storage` events
|
# for `storage` events
|
||||||
localStorage[name] = JSON.stringify value
|
localStorage[name] = JSON.stringify value
|
||||||
GM_setValue name, JSON.stringify value
|
GM_setValue name, JSON.stringify value
|
||||||
else
|
else
|
||||||
delete: (name) ->
|
delete: (name) ->
|
||||||
name = NAMESPACE + name
|
name = Main.namespace + name
|
||||||
delete localStorage[name]
|
delete localStorage[name]
|
||||||
get: (name, defaultValue) ->
|
get: (name, defaultValue) ->
|
||||||
name = NAMESPACE + name
|
name = Main.namespace + name
|
||||||
if value = localStorage[name]
|
if value = localStorage[name]
|
||||||
JSON.parse value
|
JSON.parse value
|
||||||
else
|
else
|
||||||
defaultValue
|
defaultValue
|
||||||
set: (name, value) ->
|
set: (name, value) ->
|
||||||
name = NAMESPACE + name
|
name = Main.namespace + name
|
||||||
localStorage[name] = JSON.stringify value
|
localStorage[name] = JSON.stringify value
|
||||||
|
|
||||||
$$ = (selector, root=$.d.body) ->
|
$$ = (selector, root=$.d.body) ->
|
||||||
@ -1787,7 +1784,7 @@ Options =
|
|||||||
innerHTML: '<div id=optionsbar>
|
innerHTML: '<div id=optionsbar>
|
||||||
<div id=credits>
|
<div id=credits>
|
||||||
<a target=_blank href=http://mayhemydg.github.com/4chan-x/>4chan X</a>
|
<a target=_blank href=http://mayhemydg.github.com/4chan-x/>4chan X</a>
|
||||||
| <a target=_blank href=https://raw.github.com/mayhemydg/4chan-x/master/changelog>' + VERSION + '</a>
|
| <a target=_blank href=https://raw.github.com/mayhemydg/4chan-x/master/changelog>' + Main.version + '</a>
|
||||||
| <a target=_blank href=http://mayhemydg.github.com/4chan-x/#bug-report>Issues</a>
|
| <a target=_blank href=http://mayhemydg.github.com/4chan-x/#bug-report>Issues</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -3279,7 +3276,7 @@ Main =
|
|||||||
return
|
return
|
||||||
unless $.id 'navtopr'
|
unless $.id 'navtopr'
|
||||||
return
|
return
|
||||||
$.addClass $.d.body, "chanx_#{VERSION.split('.')[1]}"
|
$.addClass $.d.body, "chanx_#{Main.version.split('.')[1]}"
|
||||||
$.addClass $.d.body, $.engine
|
$.addClass $.d.body, $.engine
|
||||||
for nav in ['navtop', 'navbot']
|
for nav in ['navtop', 'navbot']
|
||||||
$.addClass $("a[href$='/#{Main.BOARD}/']", $.id nav), 'current'
|
$.addClass $("a[href$='/#{Main.BOARD}/']", $.id nav), 'current'
|
||||||
@ -3355,7 +3352,7 @@ Main =
|
|||||||
QR.message.receive data
|
QR.message.receive data
|
||||||
return
|
return
|
||||||
{version} = data
|
{version} = data
|
||||||
if version and version isnt VERSION and confirm 'An updated version of 4chan X is available, would you like to install it now?'
|
if version and version isnt Main.version and confirm 'An updated version of 4chan X is available, would you like to install it now?'
|
||||||
window.location = "https://raw.github.com/mayhemydg/4chan-x/#{version}/4chan_x.user.js"
|
window.location = "https://raw.github.com/mayhemydg/4chan-x/#{version}/4chan_x.user.js"
|
||||||
|
|
||||||
preParse: (node) ->
|
preParse: (node) ->
|
||||||
@ -3378,7 +3375,7 @@ Main =
|
|||||||
try
|
try
|
||||||
callback node for node in nodes
|
callback node for node in nodes
|
||||||
catch err
|
catch err
|
||||||
alert "4chan X (#{VERSION}) error: #{err.message}\nhttp://mayhemydg.github.com/4chan-x/#bug-report\n\n#{err.stack}" if notify
|
alert "4chan X (#{Main.version}) error: #{err.message}\nhttp://mayhemydg.github.com/4chan-x/#bug-report\n\n#{err.stack}" if notify
|
||||||
return
|
return
|
||||||
observer: (mutations) ->
|
observer: (mutations) ->
|
||||||
nodes = []
|
nodes = []
|
||||||
@ -3390,6 +3387,8 @@ Main =
|
|||||||
{target} = e
|
{target} = e
|
||||||
Main.node [Main.preParse target] if target.nodeName is 'TABLE'
|
Main.node [Main.preParse target] if target.nodeName is 'TABLE'
|
||||||
|
|
||||||
|
namespace: '4chan_x.'
|
||||||
|
version: '2.29.1'
|
||||||
callbacks: []
|
callbacks: []
|
||||||
css: '
|
css: '
|
||||||
/* dialog styling */
|
/* dialog styling */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user