More merging

This commit is contained in:
Zixaphir 2015-01-09 19:38:31 -07:00
parent 7ecbb84af5
commit f158c839aa
6 changed files with 211 additions and 85 deletions

View File

@ -115,7 +115,7 @@
'use strict'; 'use strict';
(function() { (function() {
var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation, var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
__slice = [].slice, __slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty, __hasProp = {}.hasOwnProperty,
@ -12673,16 +12673,19 @@
Menu = { Menu = {
init: function() { init: function() {
var a; var _ref;
if (!Conf['Menu']) { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'])) {
return; return;
} }
a = $.el('a', { this.button = $.el('a', {
className: 'menu-button', className: 'menu-button',
innerHTML: '<i class="fa fa-bars"></i>', innerHTML: '<i class="fa fa-bars"></i>',
href: 'javascript:;' href: 'javascript:;'
}); });
this.menu = new UI.Menu(); $.extend(this.button, {
innerHTML: "<i class=\"fa fa-angle-down\"></i>"
});
this.menu = new UI.Menu('post');
Post.callbacks.push({ Post.callbacks.push({
name: 'Menu', name: 'Menu',
cb: this.node cb: this.node
@ -12694,39 +12697,27 @@
}, },
node: function() { node: function() {
if (this.isClone) { if (this.isClone) {
$.on($('.menu-button', this.nodes.info), 'click', Menu.toggle); Menu.makeButton(this, $('.menu-button', this.nodes.info));
return; return;
} }
return $.add(this.nodes.info, Menu.makeButton()); return $.add(this.nodes.info, Menu.makeButton(this));
}, },
catalogNode: function() { catalogNode: function() {
return $.add(this.nodes.thumb, Menu.makeButton()); return $.after(this.nodes.icons, Menu.makeButton(this.thread.OP));
}, },
makeButton: (function() { makeButton: function(post, button) {
var a; button || (button = Menu.button.cloneNode(true));
a = $.el('a', { $.on(button, 'click', function(e) {
className: 'menu-button', return Menu.menu.toggle(e, this, post);
innerHTML: '<i class=fa>\uf107</i>',
href: 'javascript:;'
}); });
return function() { return button;
var clone;
clone = a.cloneNode(true);
$.on(clone, 'click', Menu.toggle);
return clone;
};
})(),
toggle: function(e) {
var fullID;
fullID = $.x('ancestor::*[@data-full-i-d][1]', this).dataset.fullID;
return Menu.menu.toggle(e, this, g.posts[fullID]);
} }
}; };
ReportLink = { ReportLink = {
init: function() { init: function() {
var a; var a, _ref;
if (!Conf['Menu'] || !Conf['Report Link']) { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Report Link'])) {
return; return;
} }
a = $.el('a', { a = $.el('a', {
@ -12749,7 +12740,7 @@
post = ReportLink.post; post = ReportLink.post;
url = "//sys.4chan.org/" + post.board + "/imgboard.php?mode=report&no=" + post; url = "//sys.4chan.org/" + post.board + "/imgboard.php?mode=report&no=" + post;
id = Date.now(); id = Date.now();
set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200"; set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=285";
return window.open(url, id, set); return window.open(url, id, set);
} }
}; };
@ -14367,6 +14358,7 @@
var btn, entry, psa; var btn, entry, psa;
$.off(d, '4chanXInitFinished', PSAHiding.setup); $.off(d, '4chanXInitFinished', PSAHiding.setup);
if (!(psa = $.id('globalMessage'))) { if (!(psa = $.id('globalMessage'))) {
$.rmClass(doc, 'hide-announcement');
return; return;
} }
entry = { entry = {
@ -14383,11 +14375,12 @@
Header.menu.addEntry(entry); Header.menu.addEntry(entry);
$.on(entry.el, 'click', PSAHiding.toggle); $.on(entry.el, 'click', PSAHiding.toggle);
PSAHiding.btn = btn = $.el('span', { PSAHiding.btn = btn = $.el('span', {
innerHTML: '[<a href=javascript:;>Dismiss</a>]',
title: 'Mark announcement as read and hide.', title: 'Mark announcement as read and hide.',
className: 'hide-announcement', className: 'hide-announcement',
href: 'javascript:;', href: 'javascript:;'
textContent: '[ - ]' });
$.extend(btn, {
innerHTML: "[<a href=\"javascript:;\">Dismiss</a>]"
}); });
$.on(btn, 'click', PSAHiding.toggle); $.on(btn, 'click', PSAHiding.toggle);
$.get('hiddenPSA', 0, function(_arg) { $.get('hiddenPSA', 0, function(_arg) {
@ -14420,6 +14413,64 @@
} }
}; };
AntiAutoplay = {
init: function() {
var audio, _i, _len, _ref;
if (!Conf['Disable Autoplaying Sounds']) {
return;
}
$.addClass(doc, 'anti-autoplay');
_ref = $$('audio[autoplay]', doc);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
audio = _ref[_i];
this.stop(audio);
}
window.addEventListener('loadstart', ((function(_this) {
return function(e) {
return _this.stop(e.target);
};
})(this)), true);
Post.callbacks.push({
name: 'Disable Autoplaying Sounds',
cb: this.node
});
CatalogThread.callbacks.push({
name: 'Disable Autoplaying Sounds',
cb: this.node
});
return $.ready((function(_this) {
return function() {
return _this.process(d.body);
};
})(this));
},
stop: function(audio) {
if (!audio.autoplay) {
return;
}
audio.pause();
audio.autoplay = false;
if (audio.controls) {
return;
}
audio.controls = true;
return $.addClass(audio, 'controls-added');
},
node: function() {
return AntiAutoplay.process(this.nodes.root);
},
process: function(root) {
var iframe, _i, _len, _ref, _results;
_ref = $$('iframe[src*="youtube"][src*="autoplay=1"]', root);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
iframe = _ref[_i];
_results.push(iframe.src = iframe.src.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', ''));
}
return _results;
}
};
CatalogLinks = { CatalogLinks = {
init: function() { init: function() {
var el, input; var el, input;

View File

@ -88,7 +88,7 @@
'use strict'; 'use strict';
(function() { (function() {
var $, $$, Anonymize, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation, var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Rice, Sauce, Settings, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
__slice = [].slice, __slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty, __hasProp = {}.hasOwnProperty,
@ -12695,16 +12695,19 @@
Menu = { Menu = {
init: function() { init: function() {
var a; var _ref;
if (!Conf['Menu']) { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'])) {
return; return;
} }
a = $.el('a', { this.button = $.el('a', {
className: 'menu-button', className: 'menu-button',
innerHTML: '<i class="fa fa-bars"></i>', innerHTML: '<i class="fa fa-bars"></i>',
href: 'javascript:;' href: 'javascript:;'
}); });
this.menu = new UI.Menu(); $.extend(this.button, {
innerHTML: "<i class=\"fa fa-angle-down\"></i>"
});
this.menu = new UI.Menu('post');
Post.callbacks.push({ Post.callbacks.push({
name: 'Menu', name: 'Menu',
cb: this.node cb: this.node
@ -12716,39 +12719,27 @@
}, },
node: function() { node: function() {
if (this.isClone) { if (this.isClone) {
$.on($('.menu-button', this.nodes.info), 'click', Menu.toggle); Menu.makeButton(this, $('.menu-button', this.nodes.info));
return; return;
} }
return $.add(this.nodes.info, Menu.makeButton()); return $.add(this.nodes.info, Menu.makeButton(this));
}, },
catalogNode: function() { catalogNode: function() {
return $.add(this.nodes.thumb, Menu.makeButton()); return $.after(this.nodes.icons, Menu.makeButton(this.thread.OP));
}, },
makeButton: (function() { makeButton: function(post, button) {
var a; button || (button = Menu.button.cloneNode(true));
a = $.el('a', { $.on(button, 'click', function(e) {
className: 'menu-button', return Menu.menu.toggle(e, this, post);
innerHTML: '<i class=fa>\uf107</i>',
href: 'javascript:;'
}); });
return function() { return button;
var clone;
clone = a.cloneNode(true);
$.on(clone, 'click', Menu.toggle);
return clone;
};
})(),
toggle: function(e) {
var fullID;
fullID = $.x('ancestor::*[@data-full-i-d][1]', this).dataset.fullID;
return Menu.menu.toggle(e, this, g.posts[fullID]);
} }
}; };
ReportLink = { ReportLink = {
init: function() { init: function() {
var a; var a, _ref;
if (!Conf['Menu'] || !Conf['Report Link']) { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && Conf['Menu'] && Conf['Report Link'])) {
return; return;
} }
a = $.el('a', { a = $.el('a', {
@ -12771,7 +12762,7 @@
post = ReportLink.post; post = ReportLink.post;
url = "//sys.4chan.org/" + post.board + "/imgboard.php?mode=report&no=" + post; url = "//sys.4chan.org/" + post.board + "/imgboard.php?mode=report&no=" + post;
id = Date.now(); id = Date.now();
set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200"; set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=285";
return window.open(url, id, set); return window.open(url, id, set);
} }
}; };
@ -14388,6 +14379,7 @@
var btn, entry, psa; var btn, entry, psa;
$.off(d, '4chanXInitFinished', PSAHiding.setup); $.off(d, '4chanXInitFinished', PSAHiding.setup);
if (!(psa = $.id('globalMessage'))) { if (!(psa = $.id('globalMessage'))) {
$.rmClass(doc, 'hide-announcement');
return; return;
} }
entry = { entry = {
@ -14404,11 +14396,12 @@
Header.menu.addEntry(entry); Header.menu.addEntry(entry);
$.on(entry.el, 'click', PSAHiding.toggle); $.on(entry.el, 'click', PSAHiding.toggle);
PSAHiding.btn = btn = $.el('span', { PSAHiding.btn = btn = $.el('span', {
innerHTML: '[<a href=javascript:;>Dismiss</a>]',
title: 'Mark announcement as read and hide.', title: 'Mark announcement as read and hide.',
className: 'hide-announcement', className: 'hide-announcement',
href: 'javascript:;', href: 'javascript:;'
textContent: '[ - ]' });
$.extend(btn, {
innerHTML: "[<a href=\"javascript:;\">Dismiss</a>]"
}); });
$.on(btn, 'click', PSAHiding.toggle); $.on(btn, 'click', PSAHiding.toggle);
$.get('hiddenPSA', 0, function(_arg) { $.get('hiddenPSA', 0, function(_arg) {
@ -14441,6 +14434,64 @@
} }
}; };
AntiAutoplay = {
init: function() {
var audio, _i, _len, _ref;
if (!Conf['Disable Autoplaying Sounds']) {
return;
}
$.addClass(doc, 'anti-autoplay');
_ref = $$('audio[autoplay]', doc);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
audio = _ref[_i];
this.stop(audio);
}
window.addEventListener('loadstart', ((function(_this) {
return function(e) {
return _this.stop(e.target);
};
})(this)), true);
Post.callbacks.push({
name: 'Disable Autoplaying Sounds',
cb: this.node
});
CatalogThread.callbacks.push({
name: 'Disable Autoplaying Sounds',
cb: this.node
});
return $.ready((function(_this) {
return function() {
return _this.process(d.body);
};
})(this));
},
stop: function(audio) {
if (!audio.autoplay) {
return;
}
audio.pause();
audio.autoplay = false;
if (audio.controls) {
return;
}
audio.controls = true;
return $.addClass(audio, 'controls-added');
},
node: function() {
return AntiAutoplay.process(this.nodes.root);
},
process: function(root) {
var iframe, _i, _len, _ref, _results;
_ref = $$('iframe[src*="youtube"][src*="autoplay=1"]', root);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
iframe = _ref[_i];
_results.push(iframe.src = iframe.src.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', ''));
}
return _results;
}
};
CatalogLinks = { CatalogLinks = {
init: function() { init: function() {
var el, input; var el, input;

View File

@ -1,13 +1,15 @@
Menu = Menu =
init: -> init: ->
return if !Conf['Menu'] return unless g.VIEW in ['index', 'thread'] and Conf['Menu']
a = $.el 'a', @button = $.el 'a',
className: 'menu-button' className: 'menu-button'
innerHTML: '<i class="fa fa-bars"></i>' innerHTML: '<i class="fa fa-bars"></i>'
href: 'javascript:;' href: 'javascript:;'
@menu = new UI.Menu() $.extend @button, <%= html('<i class="fa fa-angle-down"></i>') %>
@menu = new UI.Menu 'post'
Post.callbacks.push Post.callbacks.push
name: 'Menu' name: 'Menu'
cb: @node cb: @node
@ -18,22 +20,15 @@ Menu =
node: -> node: ->
if @isClone if @isClone
$.on $('.menu-button', @nodes.info), 'click', Menu.toggle Menu.makeButton @, $('.menu-button', @nodes.info)
return return
$.add @nodes.info, Menu.makeButton() $.add @nodes.info, Menu.makeButton @
catalogNode: -> catalogNode: ->
$.add @nodes.thumb, Menu.makeButton() $.after @nodes.icons, Menu.makeButton @thread.OP
makeButton: do -> makeButton: (post, button) ->
a = $.el 'a', button or= Menu.button.cloneNode true
className: 'menu-button' $.on button, 'click', (e) ->
innerHTML: '<i class=fa>\uf107</i>' Menu.menu.toggle e, @, post
href: 'javascript:;' button
->
clone = a.cloneNode true
$.on clone, 'click', Menu.toggle
clone
toggle: (e) ->
fullID = $.x('ancestor::*[@data-full-i-d][1]', @).dataset.fullID
Menu.menu.toggle e, @, g.posts[fullID]

View File

@ -1,6 +1,6 @@
ReportLink = ReportLink =
init: -> init: ->
return if !Conf['Menu'] or !Conf['Report Link'] return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Report Link']
a = $.el 'a', a = $.el 'a',
className: 'report-link' className: 'report-link'
@ -17,5 +17,5 @@ ReportLink =
{post} = ReportLink {post} = ReportLink
url = "//sys.4chan.org/#{post.board}/imgboard.php?mode=report&no=#{post}" url = "//sys.4chan.org/#{post.board}/imgboard.php?mode=report&no=#{post}"
id = Date.now() id = Date.now()
set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200" set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=285"
window.open url, id, set window.open url, id, set

View File

@ -8,6 +8,7 @@ PSAHiding =
$.off d, '4chanXInitFinished', PSAHiding.setup $.off d, '4chanXInitFinished', PSAHiding.setup
unless psa = $.id 'globalMessage' unless psa = $.id 'globalMessage'
$.rmClass doc, 'hide-announcement'
return return
entry = entry =
@ -21,11 +22,11 @@ PSAHiding =
$.on entry.el, 'click', PSAHiding.toggle $.on entry.el, 'click', PSAHiding.toggle
PSAHiding.btn = btn = $.el 'span', PSAHiding.btn = btn = $.el 'span',
innerHTML: '[<a href=javascript:;>Dismiss</a>]'
title: 'Mark announcement as read and hide.' title: 'Mark announcement as read and hide.'
className: 'hide-announcement' className: 'hide-announcement'
href: 'javascript:;' href: 'javascript:;'
textContent: '[ - ]'
$.extend btn, <%= html('[<a href="javascript:;">Dismiss</a>]') %>
$.on btn, 'click', PSAHiding.toggle $.on btn, 'click', PSAHiding.toggle

View File

@ -0,0 +1,28 @@
AntiAutoplay =
init: ->
return if !Conf['Disable Autoplaying Sounds']
$.addClass doc, 'anti-autoplay'
@stop audio for audio in $$ 'audio[autoplay]', doc
window.addEventListener 'loadstart', ((e) => @stop e.target), true
Post.callbacks.push
name: 'Disable Autoplaying Sounds'
cb: @node
CatalogThread.callbacks.push
name: 'Disable Autoplaying Sounds'
cb: @node
$.ready => @process d.body
stop: (audio) ->
return unless audio.autoplay
audio.pause()
audio.autoplay = false
return if audio.controls
audio.controls = true
$.addClass audio, 'controls-added'
node: ->
AntiAutoplay.process @nodes.root
process: (root) ->
for iframe in $$ 'iframe[src*="youtube"][src*="autoplay=1"]', root
iframe.src = iframe.src.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '')