Update Main.coffee
This commit is contained in:
parent
6080ae3fe5
commit
f86ea6d328
@ -18286,6 +18286,11 @@
|
|||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var db, flatten, pathname, _i, _len, _ref, _ref1;
|
var db, flatten, pathname, _i, _len, _ref, _ref1;
|
||||||
|
if (location.hostname === 'www.google.com') {
|
||||||
|
return $.ready(function() {
|
||||||
|
return Captcha.noscript.initFrame();
|
||||||
|
});
|
||||||
|
}
|
||||||
g.threads = new SimpleDict;
|
g.threads = new SimpleDict;
|
||||||
g.posts = new SimpleDict;
|
g.posts = new SimpleDict;
|
||||||
pathname = location.pathname.split('/');
|
pathname = location.pathname.split('/');
|
||||||
@ -18300,6 +18305,8 @@
|
|||||||
return 'thread';
|
return 'thread';
|
||||||
case 'catalog':
|
case 'catalog':
|
||||||
return 'catalog';
|
return 'catalog';
|
||||||
|
case 'archive':
|
||||||
|
return 'archive';
|
||||||
default:
|
default:
|
||||||
return 'index';
|
return 'index';
|
||||||
}
|
}
|
||||||
@ -18357,7 +18364,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
initFeatures: function() {
|
initFeatures: function() {
|
||||||
var href, init, _ref;
|
var err, feature, href, name, pathname, _i, _len, _ref, _ref1, _ref2;
|
||||||
Favicon.el.type = 'image/x-icon';
|
Favicon.el.type = 'image/x-icon';
|
||||||
href = Favicon.el.href;
|
href = Favicon.el.href;
|
||||||
Favicon.SFW = /ws\.ico$/.test(href);
|
Favicon.SFW = /ws\.ico$/.test(href);
|
||||||
@ -18371,6 +18378,8 @@
|
|||||||
Main.setThemeString();
|
Main.setThemeString();
|
||||||
Main.setMascotString();
|
Main.setMascotString();
|
||||||
switch (location.hostname) {
|
switch (location.hostname) {
|
||||||
|
case 'a.4cdn.org':
|
||||||
|
return;
|
||||||
case '4chan.org':
|
case '4chan.org':
|
||||||
case 'www.4chan.org':
|
case 'www.4chan.org':
|
||||||
g.TYPE = 'sfw';
|
g.TYPE = 'sfw';
|
||||||
@ -18397,99 +18406,38 @@
|
|||||||
return location.replace(URL);
|
return location.replace(URL);
|
||||||
}
|
}
|
||||||
} else if (Conf['Loop in New Tab'] && (video = $('video'))) {
|
} else if (Conf['Loop in New Tab'] && (video = $('video'))) {
|
||||||
Video.configure(video);
|
video.loop = true;
|
||||||
if (!video.controls) {
|
video.controls = false;
|
||||||
return $.on(video, 'click', function() {
|
video.play();
|
||||||
if (video.paused) {
|
return ImageCommon.addControls(video);
|
||||||
return video.play();
|
|
||||||
} else {
|
|
||||||
return video.pause();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
init = function(name, feature) {
|
if (Conf['Normalize URL'] && g.VIEW === 'thread') {
|
||||||
var err;
|
pathname = location.pathname.split('/');
|
||||||
|
if (pathname[2] !== 'thread' || pathname.length > 4) {
|
||||||
|
pathname[2] = 'thread';
|
||||||
|
history.replaceState(null, '', pathname.slice(0, 4).join('/') + location.hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ref1 = Main.features;
|
||||||
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||||
|
_ref2 = _ref1[_i], name = _ref2[0], feature = _ref2[1];
|
||||||
try {
|
try {
|
||||||
return feature.init();
|
feature.init();
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
return Main.handleErrors({
|
Main.handleErrors({
|
||||||
message: "\"" + name + "\" initialization crashed.",
|
message: "\"" + name + "\" initialization crashed.",
|
||||||
error: err
|
error: err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
init('Style', Style);
|
|
||||||
init('Mascots', MascotTools);
|
|
||||||
init('Rice', Rice);
|
|
||||||
init('Announcements', GlobalMessage);
|
|
||||||
init('Polyfill', Polyfill);
|
|
||||||
init('Redirect', Redirect);
|
|
||||||
init('Header', Header);
|
|
||||||
init('Catalog Links', CatalogLinks);
|
|
||||||
init('Settings', Settings);
|
|
||||||
init('Index Generator', Index);
|
|
||||||
init('Announcement Hiding', PSAHiding);
|
|
||||||
init('Fourchan thingies', Fourchan);
|
|
||||||
init('Color User IDs', IDColor);
|
|
||||||
init('Custom CSS', CustomCSS);
|
|
||||||
init('Linkify', Linkify);
|
|
||||||
init('Reveal Spoilers', RemoveSpoilers);
|
|
||||||
init('Resurrect Quotes', Quotify);
|
|
||||||
init('Filter', Filter);
|
|
||||||
init('Reply Hiding Buttons', PostHiding);
|
|
||||||
init('Recursive', Recursive);
|
|
||||||
init('Strike-through Quotes', QuoteStrikeThrough);
|
|
||||||
init('Quick Reply', QR);
|
|
||||||
init('Menu', Menu);
|
|
||||||
init('Report Link', ReportLink);
|
|
||||||
init('Reply Hiding (Menu)', PostHiding.menu);
|
|
||||||
init('Delete Link', DeleteLink);
|
|
||||||
init('Filter (Menu)', Filter.menu);
|
|
||||||
init('Download Link', DownloadLink);
|
|
||||||
init('Archive Link', ArchiveLink);
|
|
||||||
init('Quote Inlining', QuoteInline);
|
|
||||||
init('Quote Previewing', QuotePreview);
|
|
||||||
init('Quote Backlinks', QuoteBacklink);
|
|
||||||
init('Quote Markers', QuoteMarkers);
|
|
||||||
init('Anonymize', Anonymize);
|
|
||||||
init('Time Formatting', Time);
|
|
||||||
init('Relative Post Dates', RelativeDates);
|
|
||||||
init('File Info Formatting', FileInfo);
|
|
||||||
init('Fappe Tyme', FappeTyme);
|
|
||||||
init('Gallery', Gallery);
|
|
||||||
init('Gallery (menu)', Gallery.menu);
|
|
||||||
init('Sauce', Sauce);
|
|
||||||
init('Image Expansion', ImageExpand);
|
|
||||||
init('Image Expansion (Menu)', ImageExpand.menu);
|
|
||||||
init('Reveal Spoiler Thumbnails', RevealSpoilers);
|
|
||||||
init('Image Loading', ImageLoader);
|
|
||||||
init('Image Hover', ImageHover);
|
|
||||||
init('Thread Expansion', ExpandThread);
|
|
||||||
init('Comment Expansion', ExpandComment);
|
|
||||||
init('Thread Excerpt', ThreadExcerpt);
|
|
||||||
init('Favicon', Favicon);
|
|
||||||
init('Unread', Unread);
|
|
||||||
init('Quote Threading', QuoteThreading);
|
|
||||||
init('Thread Stats', ThreadStats);
|
|
||||||
init('Thread Updater', ThreadUpdater);
|
|
||||||
init('Thread Watcher', ThreadWatcher);
|
|
||||||
init('Thread Watcher (Menu)', ThreadWatcher.menu);
|
|
||||||
init('Mark New IPs', MarkNewIPs);
|
|
||||||
init('Index Navigation', Nav);
|
|
||||||
init('Keybinds', Keybinds);
|
|
||||||
init('Show Dice Roll', Dice);
|
|
||||||
init('Banner', Banner);
|
|
||||||
init('Navigate', Navigate);
|
|
||||||
init('Flash Features', Flash);
|
|
||||||
return $.ready(Main.initReady);
|
return $.ready(Main.initReady);
|
||||||
},
|
},
|
||||||
initReady: function() {
|
initReady: function() {
|
||||||
var GMver, err, href, i, passLink, styleSelector, test, v, _i, _len, _ref, _ref1;
|
var GMver, err, href, i, passLink, styleSelector, v, _i, _len, _ref, _ref1;
|
||||||
if ((_ref = d.title) === '4chan - Temporarily Offline' || _ref === '4chan - 404 Not Found') {
|
if ((_ref = d.title) === '4chan - Temporarily Offline' || _ref === '4chan - 404 Not Found') {
|
||||||
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
|
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
|
||||||
href = Redirect.to('thread', {
|
href = Redirect.to('thread', {
|
||||||
@ -18520,20 +18468,17 @@
|
|||||||
rel: "stylesheet"
|
rel: "stylesheet"
|
||||||
}));
|
}));
|
||||||
$.event('4chanXInitFinished');
|
$.event('4chanXInitFinished');
|
||||||
test = $.el('span');
|
if (Conf['Show Support Message']) {
|
||||||
$.addClass(test, 'a', 'b');
|
GMver = GM_info.version.split('.');
|
||||||
if (test.className !== 'a b' && Conf['Show Support Message']) {
|
_ref1 = "1.14".split('.');
|
||||||
new Notice('warning', "Your version of Firefox is outdated (v26 minimum) and appchan x may not operate correctly.", 30);
|
for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
|
||||||
}
|
v = _ref1[i];
|
||||||
GMver = GM_info.version.split('.');
|
if (v === GMver[i]) {
|
||||||
_ref1 = "1.14".split('.');
|
continue;
|
||||||
for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
|
}
|
||||||
v = _ref1[i];
|
(v < GMver[i]) || new Notice('warning', "Your version of Greasemonkey is outdated (v" + GM_info.version + " instead of v1.14 minimum) and appchan x may not operate correctly.", 30);
|
||||||
if (v === GMver[i]) {
|
break;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
(v < GMver[i]) || new Notice('warning', "Your version of Greasemonkey is outdated (v" + GM_info.version + " instead of v1.14 minimum) and appchan x may not operate correctly.", 30);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return localStorage.getItem('4chan-settings');
|
return localStorage.getItem('4chan-settings');
|
||||||
@ -18543,7 +18488,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
initThread: function() {
|
initThread: function() {
|
||||||
var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
|
var board, err, errors, m, postRoot, posts, scriptData, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (board = $('.board')) {
|
if (board = $('.board')) {
|
||||||
threads = [];
|
threads = [];
|
||||||
posts = [];
|
posts = [];
|
||||||
@ -18572,6 +18517,12 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
|
if (g.VIEW === 'thread') {
|
||||||
|
scriptData = Get.scriptData();
|
||||||
|
threads[0].postLimit = /\bbumplimit *= *1\b/.test(scriptData);
|
||||||
|
threads[0].fileLimit = /\bimagelimit *= *1\b/.test(scriptData);
|
||||||
|
threads[0].ipCount = (m = scriptData.match(/\bunique_ips *= *(\d+)\b/)) ? +m[1] : void 0;
|
||||||
|
}
|
||||||
Thread.callbacks.execute(threads);
|
Thread.callbacks.execute(threads);
|
||||||
Post.callbacks.execute(posts);
|
Post.callbacks.execute(posts);
|
||||||
}
|
}
|
||||||
@ -18605,7 +18556,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
div = $.el('div', {
|
div = $.el('div', {
|
||||||
innerHTML: "" + errors.length + " errors occurred. [<a href=javascript:;>show</a>]"
|
innerHTML: E(errors.length) + " errors occurred. [<a href=\"javascript:;\">show</a>]"
|
||||||
});
|
});
|
||||||
$.on(div.lastElementChild, 'click', function() {
|
$.on(div.lastElementChild, 'click', function() {
|
||||||
var _ref;
|
var _ref;
|
||||||
@ -18627,7 +18578,7 @@
|
|||||||
textContent: data.message
|
textContent: data.message
|
||||||
});
|
});
|
||||||
error = $.el('div', {
|
error = $.el('div', {
|
||||||
textContent: data.error
|
textContent: "" + (data.error.name || 'Error') + ": " + (data.error.message || 'see console for details')
|
||||||
});
|
});
|
||||||
return [message, error];
|
return [message, error];
|
||||||
},
|
},
|
||||||
@ -18638,6 +18589,13 @@
|
|||||||
}
|
}
|
||||||
return Main.thisPageIsLegit;
|
return Main.thisPageIsLegit;
|
||||||
},
|
},
|
||||||
|
ready: function(cb) {
|
||||||
|
return $.ready(function() {
|
||||||
|
if (Main.isThisPageLegit()) {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
setMascotString: function() {
|
setMascotString: function() {
|
||||||
var type;
|
var type;
|
||||||
type = "Enabled Mascots";
|
type = "Enabled Mascots";
|
||||||
@ -18653,7 +18611,8 @@
|
|||||||
type += "_" + g.TYPE;
|
type += "_" + g.TYPE;
|
||||||
}
|
}
|
||||||
return g.THEMESTRING = type;
|
return g.THEMESTRING = type;
|
||||||
}
|
},
|
||||||
|
features: [['Style', Style], ['Mascots', MascotTools], ['Rice', Rice], ['Announcements', GlobalMessage], ['Polyfill', Polyfill], ['Redirect', Redirect], ['Header', Header], ['Catalog Links', CatalogLinks], ['Settings', Settings], ['Index Generator', Index], ['Disable Autoplay', AntiAutoplay], ['Announcement Hiding', PSAHiding], ['Fourchan thingies', Fourchan], ['Color User IDs', IDColor], ['Custom CSS', CustomCSS], ['Linkify', Linkify], ['Reveal Spoilers', RemoveSpoilers], ['Resurrect Quotes', Quotify], ['Filter', Filter], ['Reply Hiding Buttons', PostHiding], ['Recursive', Recursive], ['Strike-through Quotes', QuoteStrikeThrough], ['Quick Reply', QR], ['Menu', Menu], ['Index Generator (Menu)', Index.menu], ['Report Link', ReportLink], ['Reply Hiding (Menu)', PostHiding.menu], ['Delete Link', DeleteLink], ['Filter (Menu)', Filter.menu], ['Download Link', DownloadLink], ['Archive Link', ArchiveLink], ['Quote Inlining', QuoteInline], ['Quote Previewing', QuotePreview], ['Quote Backlinks', QuoteBacklink], ['Quote Markers', QuoteMarkers], ['Anonymize', Anonymize], ['Time Formatting', Time], ['Relative Post Dates', RelativeDates], ['File Info Formatting', FileInfo], ['Fappe Tyme', FappeTyme], ['Gallery', Gallery], ['Gallery (menu)', Gallery.menu], ['Sauce', Sauce], ['Image Expansion', ImageExpand], ['Image Expansion (Menu)', ImageExpand.menu], ['Reveal Spoiler Thumbnails', RevealSpoilers], ['Image Loading', ImageLoader], ['Image Hover', ImageHover], ['Comment Expansion', ExpandComment], ['Thread Expansion', ExpandThread], ['Thread Excerpt', ThreadExcerpt], ['Favicon', Favicon], ['Unread', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Watcher', ThreadWatcher], ['Thread Watcher (Menu)', ThreadWatcher.menu], ['Mark New IPs', MarkNewIPs], ['Index Navigation', Nav], ['Keybinds', Keybinds], ['Show Dice Roll', Dice], ['Banner', Banner], ['Navigate', Navigate], ['Flash Features', Flash]]
|
||||||
};
|
};
|
||||||
|
|
||||||
Main.init();
|
Main.init();
|
||||||
|
|||||||
@ -18301,6 +18301,11 @@
|
|||||||
Main = {
|
Main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var db, flatten, pathname, _i, _len, _ref, _ref1;
|
var db, flatten, pathname, _i, _len, _ref, _ref1;
|
||||||
|
if (location.hostname === 'www.google.com') {
|
||||||
|
return $.ready(function() {
|
||||||
|
return Captcha.noscript.initFrame();
|
||||||
|
});
|
||||||
|
}
|
||||||
g.threads = new SimpleDict;
|
g.threads = new SimpleDict;
|
||||||
g.posts = new SimpleDict;
|
g.posts = new SimpleDict;
|
||||||
pathname = location.pathname.split('/');
|
pathname = location.pathname.split('/');
|
||||||
@ -18315,6 +18320,8 @@
|
|||||||
return 'thread';
|
return 'thread';
|
||||||
case 'catalog':
|
case 'catalog':
|
||||||
return 'catalog';
|
return 'catalog';
|
||||||
|
case 'archive':
|
||||||
|
return 'archive';
|
||||||
default:
|
default:
|
||||||
return 'index';
|
return 'index';
|
||||||
}
|
}
|
||||||
@ -18372,7 +18379,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
initFeatures: function() {
|
initFeatures: function() {
|
||||||
var href, init, _ref;
|
var err, feature, href, name, pathname, _i, _len, _ref, _ref1, _ref2;
|
||||||
Favicon.el.type = 'image/x-icon';
|
Favicon.el.type = 'image/x-icon';
|
||||||
href = Favicon.el.href;
|
href = Favicon.el.href;
|
||||||
Favicon.SFW = /ws\.ico$/.test(href);
|
Favicon.SFW = /ws\.ico$/.test(href);
|
||||||
@ -18386,6 +18393,8 @@
|
|||||||
Main.setThemeString();
|
Main.setThemeString();
|
||||||
Main.setMascotString();
|
Main.setMascotString();
|
||||||
switch (location.hostname) {
|
switch (location.hostname) {
|
||||||
|
case 'a.4cdn.org':
|
||||||
|
return;
|
||||||
case '4chan.org':
|
case '4chan.org':
|
||||||
case 'www.4chan.org':
|
case 'www.4chan.org':
|
||||||
g.TYPE = 'sfw';
|
g.TYPE = 'sfw';
|
||||||
@ -18412,95 +18421,34 @@
|
|||||||
return location.replace(URL);
|
return location.replace(URL);
|
||||||
}
|
}
|
||||||
} else if (Conf['Loop in New Tab'] && (video = $('video'))) {
|
} else if (Conf['Loop in New Tab'] && (video = $('video'))) {
|
||||||
Video.configure(video);
|
video.loop = true;
|
||||||
if (!video.controls) {
|
video.controls = false;
|
||||||
return $.on(video, 'click', function() {
|
video.play();
|
||||||
if (video.paused) {
|
return ImageCommon.addControls(video);
|
||||||
return video.play();
|
|
||||||
} else {
|
|
||||||
return video.pause();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
init = function(name, feature) {
|
if (Conf['Normalize URL'] && g.VIEW === 'thread') {
|
||||||
var err;
|
pathname = location.pathname.split('/');
|
||||||
|
if (pathname[2] !== 'thread' || pathname.length > 4) {
|
||||||
|
pathname[2] = 'thread';
|
||||||
|
history.replaceState(null, '', pathname.slice(0, 4).join('/') + location.hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ref1 = Main.features;
|
||||||
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||||
|
_ref2 = _ref1[_i], name = _ref2[0], feature = _ref2[1];
|
||||||
try {
|
try {
|
||||||
return feature.init();
|
feature.init();
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
return Main.handleErrors({
|
Main.handleErrors({
|
||||||
message: "\"" + name + "\" initialization crashed.",
|
message: "\"" + name + "\" initialization crashed.",
|
||||||
error: err
|
error: err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
init('Style', Style);
|
|
||||||
init('Mascots', MascotTools);
|
|
||||||
init('Rice', Rice);
|
|
||||||
init('Announcements', GlobalMessage);
|
|
||||||
init('Polyfill', Polyfill);
|
|
||||||
init('Redirect', Redirect);
|
|
||||||
init('Header', Header);
|
|
||||||
init('Catalog Links', CatalogLinks);
|
|
||||||
init('Settings', Settings);
|
|
||||||
init('Index Generator', Index);
|
|
||||||
init('Announcement Hiding', PSAHiding);
|
|
||||||
init('Fourchan thingies', Fourchan);
|
|
||||||
init('Color User IDs', IDColor);
|
|
||||||
init('Custom CSS', CustomCSS);
|
|
||||||
init('Linkify', Linkify);
|
|
||||||
init('Reveal Spoilers', RemoveSpoilers);
|
|
||||||
init('Resurrect Quotes', Quotify);
|
|
||||||
init('Filter', Filter);
|
|
||||||
init('Reply Hiding Buttons', PostHiding);
|
|
||||||
init('Recursive', Recursive);
|
|
||||||
init('Strike-through Quotes', QuoteStrikeThrough);
|
|
||||||
init('Quick Reply', QR);
|
|
||||||
init('Menu', Menu);
|
|
||||||
init('Report Link', ReportLink);
|
|
||||||
init('Reply Hiding (Menu)', PostHiding.menu);
|
|
||||||
init('Delete Link', DeleteLink);
|
|
||||||
init('Filter (Menu)', Filter.menu);
|
|
||||||
init('Download Link', DownloadLink);
|
|
||||||
init('Archive Link', ArchiveLink);
|
|
||||||
init('Quote Inlining', QuoteInline);
|
|
||||||
init('Quote Previewing', QuotePreview);
|
|
||||||
init('Quote Backlinks', QuoteBacklink);
|
|
||||||
init('Quote Markers', QuoteMarkers);
|
|
||||||
init('Anonymize', Anonymize);
|
|
||||||
init('Time Formatting', Time);
|
|
||||||
init('Relative Post Dates', RelativeDates);
|
|
||||||
init('File Info Formatting', FileInfo);
|
|
||||||
init('Fappe Tyme', FappeTyme);
|
|
||||||
init('Gallery', Gallery);
|
|
||||||
init('Gallery (menu)', Gallery.menu);
|
|
||||||
init('Sauce', Sauce);
|
|
||||||
init('Image Expansion', ImageExpand);
|
|
||||||
init('Image Expansion (Menu)', ImageExpand.menu);
|
|
||||||
init('Reveal Spoiler Thumbnails', RevealSpoilers);
|
|
||||||
init('Image Loading', ImageLoader);
|
|
||||||
init('Image Hover', ImageHover);
|
|
||||||
init('Thread Expansion', ExpandThread);
|
|
||||||
init('Comment Expansion', ExpandComment);
|
|
||||||
init('Thread Excerpt', ThreadExcerpt);
|
|
||||||
init('Favicon', Favicon);
|
|
||||||
init('Unread', Unread);
|
|
||||||
init('Quote Threading', QuoteThreading);
|
|
||||||
init('Thread Stats', ThreadStats);
|
|
||||||
init('Thread Updater', ThreadUpdater);
|
|
||||||
init('Thread Watcher', ThreadWatcher);
|
|
||||||
init('Thread Watcher (Menu)', ThreadWatcher.menu);
|
|
||||||
init('Mark New IPs', MarkNewIPs);
|
|
||||||
init('Index Navigation', Nav);
|
|
||||||
init('Keybinds', Keybinds);
|
|
||||||
init('Show Dice Roll', Dice);
|
|
||||||
init('Banner', Banner);
|
|
||||||
init('Navigate', Navigate);
|
|
||||||
init('Flash Features', Flash);
|
|
||||||
return $.ready(Main.initReady);
|
return $.ready(Main.initReady);
|
||||||
},
|
},
|
||||||
initReady: function() {
|
initReady: function() {
|
||||||
@ -18543,7 +18491,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
initThread: function() {
|
initThread: function() {
|
||||||
var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
|
var board, err, errors, m, postRoot, posts, scriptData, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (board = $('.board')) {
|
if (board = $('.board')) {
|
||||||
threads = [];
|
threads = [];
|
||||||
posts = [];
|
posts = [];
|
||||||
@ -18572,6 +18520,12 @@
|
|||||||
if (errors) {
|
if (errors) {
|
||||||
Main.handleErrors(errors);
|
Main.handleErrors(errors);
|
||||||
}
|
}
|
||||||
|
if (g.VIEW === 'thread') {
|
||||||
|
scriptData = Get.scriptData();
|
||||||
|
threads[0].postLimit = /\bbumplimit *= *1\b/.test(scriptData);
|
||||||
|
threads[0].fileLimit = /\bimagelimit *= *1\b/.test(scriptData);
|
||||||
|
threads[0].ipCount = (m = scriptData.match(/\bunique_ips *= *(\d+)\b/)) ? +m[1] : void 0;
|
||||||
|
}
|
||||||
Thread.callbacks.execute(threads);
|
Thread.callbacks.execute(threads);
|
||||||
Post.callbacks.execute(posts);
|
Post.callbacks.execute(posts);
|
||||||
}
|
}
|
||||||
@ -18605,7 +18559,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
div = $.el('div', {
|
div = $.el('div', {
|
||||||
innerHTML: "" + errors.length + " errors occurred. [<a href=javascript:;>show</a>]"
|
innerHTML: E(errors.length) + " errors occurred. [<a href=\"javascript:;\">show</a>]"
|
||||||
});
|
});
|
||||||
$.on(div.lastElementChild, 'click', function() {
|
$.on(div.lastElementChild, 'click', function() {
|
||||||
var _ref;
|
var _ref;
|
||||||
@ -18627,7 +18581,7 @@
|
|||||||
textContent: data.message
|
textContent: data.message
|
||||||
});
|
});
|
||||||
error = $.el('div', {
|
error = $.el('div', {
|
||||||
textContent: data.error
|
textContent: "" + (data.error.name || 'Error') + ": " + (data.error.message || 'see console for details')
|
||||||
});
|
});
|
||||||
return [message, error];
|
return [message, error];
|
||||||
},
|
},
|
||||||
@ -18638,6 +18592,13 @@
|
|||||||
}
|
}
|
||||||
return Main.thisPageIsLegit;
|
return Main.thisPageIsLegit;
|
||||||
},
|
},
|
||||||
|
ready: function(cb) {
|
||||||
|
return $.ready(function() {
|
||||||
|
if (Main.isThisPageLegit()) {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
setMascotString: function() {
|
setMascotString: function() {
|
||||||
var type;
|
var type;
|
||||||
type = "Enabled Mascots";
|
type = "Enabled Mascots";
|
||||||
@ -18653,7 +18614,8 @@
|
|||||||
type += "_" + g.TYPE;
|
type += "_" + g.TYPE;
|
||||||
}
|
}
|
||||||
return g.THEMESTRING = type;
|
return g.THEMESTRING = type;
|
||||||
}
|
},
|
||||||
|
features: [['Style', Style], ['Mascots', MascotTools], ['Rice', Rice], ['Announcements', GlobalMessage], ['Polyfill', Polyfill], ['Redirect', Redirect], ['Header', Header], ['Catalog Links', CatalogLinks], ['Settings', Settings], ['Index Generator', Index], ['Disable Autoplay', AntiAutoplay], ['Announcement Hiding', PSAHiding], ['Fourchan thingies', Fourchan], ['Color User IDs', IDColor], ['Custom CSS', CustomCSS], ['Linkify', Linkify], ['Reveal Spoilers', RemoveSpoilers], ['Resurrect Quotes', Quotify], ['Filter', Filter], ['Reply Hiding Buttons', PostHiding], ['Recursive', Recursive], ['Strike-through Quotes', QuoteStrikeThrough], ['Quick Reply', QR], ['Menu', Menu], ['Index Generator (Menu)', Index.menu], ['Report Link', ReportLink], ['Reply Hiding (Menu)', PostHiding.menu], ['Delete Link', DeleteLink], ['Filter (Menu)', Filter.menu], ['Download Link', DownloadLink], ['Archive Link', ArchiveLink], ['Quote Inlining', QuoteInline], ['Quote Previewing', QuotePreview], ['Quote Backlinks', QuoteBacklink], ['Quote Markers', QuoteMarkers], ['Anonymize', Anonymize], ['Time Formatting', Time], ['Relative Post Dates', RelativeDates], ['File Info Formatting', FileInfo], ['Fappe Tyme', FappeTyme], ['Gallery', Gallery], ['Gallery (menu)', Gallery.menu], ['Sauce', Sauce], ['Image Expansion', ImageExpand], ['Image Expansion (Menu)', ImageExpand.menu], ['Reveal Spoiler Thumbnails', RevealSpoilers], ['Image Loading', ImageLoader], ['Image Hover', ImageHover], ['Comment Expansion', ExpandComment], ['Thread Expansion', ExpandThread], ['Thread Excerpt', ThreadExcerpt], ['Favicon', Favicon], ['Unread', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Watcher', ThreadWatcher], ['Thread Watcher (Menu)', ThreadWatcher.menu], ['Mark New IPs', MarkNewIPs], ['Index Navigation', Nav], ['Keybinds', Keybinds], ['Show Dice Roll', Dice], ['Banner', Banner], ['Navigate', Navigate], ['Flash Features', Flash]]
|
||||||
};
|
};
|
||||||
|
|
||||||
Main.init();
|
Main.init();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
Main =
|
Main =
|
||||||
init: ->
|
init: ->
|
||||||
|
if location.hostname is 'www.google.com'
|
||||||
|
return $.ready -> Captcha.noscript.initFrame()
|
||||||
|
|
||||||
g.threads = new SimpleDict
|
g.threads = new SimpleDict
|
||||||
g.posts = new SimpleDict
|
g.posts = new SimpleDict
|
||||||
|
|
||||||
@ -12,6 +15,8 @@ Main =
|
|||||||
'thread'
|
'thread'
|
||||||
when 'catalog'
|
when 'catalog'
|
||||||
'catalog'
|
'catalog'
|
||||||
|
when 'archive'
|
||||||
|
'archive'
|
||||||
else
|
else
|
||||||
'index'
|
'index'
|
||||||
if g.VIEW is 'catalog'
|
if g.VIEW is 'catalog'
|
||||||
@ -73,6 +78,8 @@ Main =
|
|||||||
Main.setMascotString()
|
Main.setMascotString()
|
||||||
|
|
||||||
switch location.hostname
|
switch location.hostname
|
||||||
|
when 'a.4cdn.org'
|
||||||
|
return
|
||||||
when '4chan.org', 'www.4chan.org'
|
when '4chan.org', 'www.4chan.org'
|
||||||
g.TYPE = 'sfw'
|
g.TYPE = 'sfw'
|
||||||
g.VIEW = 'home'
|
g.VIEW = 'home'
|
||||||
@ -94,14 +101,20 @@ Main =
|
|||||||
filename: pathname[pathname.length - 1]
|
filename: pathname[pathname.length - 1]
|
||||||
location.replace URL if URL
|
location.replace URL if URL
|
||||||
else if Conf['Loop in New Tab'] and video = $ 'video'
|
else if Conf['Loop in New Tab'] and video = $ 'video'
|
||||||
Video.configure video
|
video.loop = true
|
||||||
if !video.controls
|
video.controls = false
|
||||||
$.on video, 'click', ->
|
video.play()
|
||||||
if video.paused then video.play() else video.pause()
|
ImageCommon.addControls video
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if Conf['Normalize URL'] and g.VIEW is 'thread'
|
||||||
|
pathname = location.pathname.split '/'
|
||||||
|
if pathname[2] isnt 'thread' or pathname.length > 4
|
||||||
|
pathname[2] = 'thread'
|
||||||
|
history.replaceState null, '', pathname[0...4].join('/') + location.hash
|
||||||
|
|
||||||
# c.time 'All initializations'
|
# c.time 'All initializations'
|
||||||
init = (name, feature) ->
|
for [name, feature] in Main.features
|
||||||
# c.time "#{name} initialization"
|
# c.time "#{name} initialization"
|
||||||
try
|
try
|
||||||
feature.init()
|
feature.init()
|
||||||
@ -114,70 +127,6 @@ Main =
|
|||||||
|
|
||||||
# c.timeEnd 'All initializations'
|
# c.timeEnd 'All initializations'
|
||||||
|
|
||||||
init 'Style', Style
|
|
||||||
init 'Mascots', MascotTools
|
|
||||||
init 'Rice', Rice
|
|
||||||
init 'Announcements', GlobalMessage
|
|
||||||
init 'Polyfill', Polyfill
|
|
||||||
init 'Redirect', Redirect
|
|
||||||
init 'Header', Header
|
|
||||||
init 'Catalog Links', CatalogLinks
|
|
||||||
init 'Settings', Settings
|
|
||||||
init 'Index Generator', Index
|
|
||||||
init 'Announcement Hiding', PSAHiding
|
|
||||||
init 'Fourchan thingies', Fourchan
|
|
||||||
init 'Color User IDs', IDColor
|
|
||||||
init 'Custom CSS', CustomCSS
|
|
||||||
init 'Linkify', Linkify
|
|
||||||
init 'Reveal Spoilers', RemoveSpoilers
|
|
||||||
init 'Resurrect Quotes', Quotify
|
|
||||||
init 'Filter', Filter
|
|
||||||
init 'Reply Hiding Buttons', PostHiding
|
|
||||||
init 'Recursive', Recursive
|
|
||||||
init 'Strike-through Quotes', QuoteStrikeThrough
|
|
||||||
init 'Quick Reply', QR
|
|
||||||
init 'Menu', Menu
|
|
||||||
init 'Report Link', ReportLink
|
|
||||||
init 'Reply Hiding (Menu)', PostHiding.menu
|
|
||||||
init 'Delete Link', DeleteLink
|
|
||||||
init 'Filter (Menu)', Filter.menu
|
|
||||||
init 'Download Link', DownloadLink
|
|
||||||
init 'Archive Link', ArchiveLink
|
|
||||||
init 'Quote Inlining', QuoteInline
|
|
||||||
init 'Quote Previewing', QuotePreview
|
|
||||||
init 'Quote Backlinks', QuoteBacklink
|
|
||||||
init 'Quote Markers', QuoteMarkers
|
|
||||||
init 'Anonymize', Anonymize
|
|
||||||
init 'Time Formatting', Time
|
|
||||||
init 'Relative Post Dates', RelativeDates
|
|
||||||
init 'File Info Formatting', FileInfo
|
|
||||||
init 'Fappe Tyme', FappeTyme
|
|
||||||
init 'Gallery', Gallery
|
|
||||||
init 'Gallery (menu)', Gallery.menu
|
|
||||||
init 'Sauce', Sauce
|
|
||||||
init 'Image Expansion', ImageExpand
|
|
||||||
init 'Image Expansion (Menu)', ImageExpand.menu
|
|
||||||
init 'Reveal Spoiler Thumbnails', RevealSpoilers
|
|
||||||
init 'Image Loading', ImageLoader
|
|
||||||
init 'Image Hover', ImageHover
|
|
||||||
init 'Thread Expansion', ExpandThread
|
|
||||||
init 'Comment Expansion', ExpandComment
|
|
||||||
init 'Thread Excerpt', ThreadExcerpt
|
|
||||||
init 'Favicon', Favicon
|
|
||||||
init 'Unread', Unread
|
|
||||||
init 'Quote Threading', QuoteThreading
|
|
||||||
init 'Thread Stats', ThreadStats
|
|
||||||
init 'Thread Updater', ThreadUpdater
|
|
||||||
init 'Thread Watcher', ThreadWatcher
|
|
||||||
init 'Thread Watcher (Menu)', ThreadWatcher.menu
|
|
||||||
init 'Mark New IPs', MarkNewIPs
|
|
||||||
init 'Index Navigation', Nav
|
|
||||||
init 'Keybinds', Keybinds
|
|
||||||
init 'Show Dice Roll', Dice
|
|
||||||
init 'Banner', Banner
|
|
||||||
init 'Navigate', Navigate
|
|
||||||
init 'Flash Features', Flash
|
|
||||||
|
|
||||||
$.ready Main.initReady
|
$.ready Main.initReady
|
||||||
|
|
||||||
initReady: ->
|
initReady: ->
|
||||||
@ -214,16 +163,12 @@ Main =
|
|||||||
$.event '4chanXInitFinished'
|
$.event '4chanXInitFinished'
|
||||||
|
|
||||||
<% if (type === 'userscript') { %>
|
<% if (type === 'userscript') { %>
|
||||||
test = $.el 'span'
|
if Conf['Show Support Message']
|
||||||
$.addClass test, 'a', 'b'
|
GMver = GM_info.version.split '.'
|
||||||
if test.className isnt 'a b' and Conf['Show Support Message']
|
for v, i in "<%= meta.min.greasemonkey %>".split '.'
|
||||||
new Notice 'warning', "Your version of Firefox is outdated (v<%= meta.min.firefox %> minimum) and <%= meta.name %> may not operate correctly.", 30
|
continue if v is GMver[i]
|
||||||
|
(v < GMver[i]) or new Notice 'warning', "Your version of Greasemonkey is outdated (v#{GM_info.version} instead of v<%= meta.min.greasemonkey %> minimum) and <%= meta.name %> may not operate correctly.", 30
|
||||||
GMver = GM_info.version.split '.'
|
break
|
||||||
for v, i in "<%= meta.min.greasemonkey %>".split '.'
|
|
||||||
continue if v is GMver[i]
|
|
||||||
(v < GMver[i]) or new Notice 'warning', "Your version of Greasemonkey is outdated (v#{GM_info.version} instead of v<%= meta.min.greasemonkey %> minimum) and <%= meta.name %> may not operate correctly.", 30
|
|
||||||
break
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -251,6 +196,12 @@ Main =
|
|||||||
error: err
|
error: err
|
||||||
Main.handleErrors errors if errors
|
Main.handleErrors errors if errors
|
||||||
|
|
||||||
|
if g.VIEW is 'thread'
|
||||||
|
scriptData = Get.scriptData()
|
||||||
|
threads[0].postLimit = /\bbumplimit *= *1\b/.test scriptData
|
||||||
|
threads[0].fileLimit = /\bimagelimit *= *1\b/.test scriptData
|
||||||
|
threads[0].ipCount = if m = scriptData.match /\bunique_ips *= *(\d+)\b/ then +m[1]
|
||||||
|
|
||||||
Thread.callbacks.execute threads
|
Thread.callbacks.execute threads
|
||||||
Post.callbacks.execute posts
|
Post.callbacks.execute posts
|
||||||
|
|
||||||
@ -275,7 +226,7 @@ Main =
|
|||||||
return
|
return
|
||||||
|
|
||||||
div = $.el 'div',
|
div = $.el 'div',
|
||||||
innerHTML: "#{errors.length} errors occurred. [<a href=javascript:;>show</a>]"
|
<%= html('${errors.length} errors occurred. [<a href="javascript:;">show</a>]') %>
|
||||||
$.on div.lastElementChild, 'click', ->
|
$.on div.lastElementChild, 'click', ->
|
||||||
[@textContent, logs.hidden] = if @textContent is 'show'
|
[@textContent, logs.hidden] = if @textContent is 'show'
|
||||||
['hide', false]
|
['hide', false]
|
||||||
@ -294,7 +245,7 @@ Main =
|
|||||||
message = $.el 'div',
|
message = $.el 'div',
|
||||||
textContent: data.message
|
textContent: data.message
|
||||||
error = $.el 'div',
|
error = $.el 'div',
|
||||||
textContent: data.error
|
textContent: "#{data.error.name or 'Error'}: #{data.error.message or 'see console for details'}"
|
||||||
[message, error]
|
[message, error]
|
||||||
|
|
||||||
isThisPageLegit: ->
|
isThisPageLegit: ->
|
||||||
@ -305,6 +256,10 @@ Main =
|
|||||||
d.title not in ['4chan - Temporarily Offline', '4chan - Error', '504 Gateway Time-out']
|
d.title not in ['4chan - Temporarily Offline', '4chan - Error', '504 Gateway Time-out']
|
||||||
Main.thisPageIsLegit
|
Main.thisPageIsLegit
|
||||||
|
|
||||||
|
ready: (cb) ->
|
||||||
|
$.ready ->
|
||||||
|
cb() if Main.isThisPageLegit()
|
||||||
|
|
||||||
setMascotString: ->
|
setMascotString: ->
|
||||||
type = "Enabled Mascots"
|
type = "Enabled Mascots"
|
||||||
if Conf["NSFW/SFW Mascots"]
|
if Conf["NSFW/SFW Mascots"]
|
||||||
@ -317,4 +272,73 @@ Main =
|
|||||||
type += "_#{g.TYPE}"
|
type += "_#{g.TYPE}"
|
||||||
g.THEMESTRING = type
|
g.THEMESTRING = type
|
||||||
|
|
||||||
|
features: [
|
||||||
|
['Style', Style]
|
||||||
|
['Mascots', MascotTools]
|
||||||
|
['Rice', Rice]
|
||||||
|
['Announcements', GlobalMessage]
|
||||||
|
['Polyfill', Polyfill]
|
||||||
|
['Redirect', Redirect]
|
||||||
|
['Header', Header]
|
||||||
|
['Catalog Links', CatalogLinks]
|
||||||
|
['Settings', Settings]
|
||||||
|
['Index Generator', Index]
|
||||||
|
['Disable Autoplay', AntiAutoplay]
|
||||||
|
['Announcement Hiding', PSAHiding]
|
||||||
|
['Fourchan thingies', Fourchan]
|
||||||
|
['Color User IDs', IDColor]
|
||||||
|
['Custom CSS', CustomCSS]
|
||||||
|
['Linkify', Linkify]
|
||||||
|
['Reveal Spoilers', RemoveSpoilers]
|
||||||
|
['Resurrect Quotes', Quotify]
|
||||||
|
['Filter', Filter]
|
||||||
|
['Reply Hiding Buttons', PostHiding]
|
||||||
|
['Recursive', Recursive]
|
||||||
|
['Strike-through Quotes', QuoteStrikeThrough]
|
||||||
|
['Quick Reply', QR]
|
||||||
|
['Menu', Menu]
|
||||||
|
['Index Generator (Menu)', Index.menu]
|
||||||
|
['Report Link', ReportLink]
|
||||||
|
['Reply Hiding (Menu)', PostHiding.menu]
|
||||||
|
['Delete Link', DeleteLink]
|
||||||
|
['Filter (Menu)', Filter.menu]
|
||||||
|
['Download Link', DownloadLink]
|
||||||
|
['Archive Link', ArchiveLink]
|
||||||
|
['Quote Inlining', QuoteInline]
|
||||||
|
['Quote Previewing', QuotePreview]
|
||||||
|
['Quote Backlinks', QuoteBacklink]
|
||||||
|
['Quote Markers', QuoteMarkers]
|
||||||
|
['Anonymize', Anonymize]
|
||||||
|
['Time Formatting', Time]
|
||||||
|
['Relative Post Dates', RelativeDates]
|
||||||
|
['File Info Formatting', FileInfo]
|
||||||
|
['Fappe Tyme', FappeTyme]
|
||||||
|
['Gallery', Gallery]
|
||||||
|
['Gallery (menu)', Gallery.menu]
|
||||||
|
['Sauce', Sauce]
|
||||||
|
['Image Expansion', ImageExpand]
|
||||||
|
['Image Expansion (Menu)', ImageExpand.menu]
|
||||||
|
['Reveal Spoiler Thumbnails', RevealSpoilers]
|
||||||
|
['Image Loading', ImageLoader]
|
||||||
|
['Image Hover', ImageHover]
|
||||||
|
['Comment Expansion', ExpandComment]
|
||||||
|
['Thread Expansion', ExpandThread]
|
||||||
|
['Thread Excerpt', ThreadExcerpt]
|
||||||
|
['Favicon', Favicon]
|
||||||
|
['Unread', Unread]
|
||||||
|
['Quote Threading', QuoteThreading]
|
||||||
|
['Thread Stats', ThreadStats]
|
||||||
|
['Thread Updater', ThreadUpdater]
|
||||||
|
['Thread Watcher', ThreadWatcher]
|
||||||
|
['Thread Watcher (Menu)', ThreadWatcher.menu]
|
||||||
|
['Mark New IPs', MarkNewIPs]
|
||||||
|
['Index Navigation', Nav]
|
||||||
|
['Keybinds', Keybinds]
|
||||||
|
['Show Dice Roll', Dice]
|
||||||
|
['Banner', Banner]
|
||||||
|
['Navigate', Navigate]
|
||||||
|
['Flash Features', Flash]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
Main.init()
|
Main.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user