Merge branch 'master' of github.com:MayhemYDG/4chan-x into Fx10

This commit is contained in:
Nicolas Stepien 2012-01-09 01:26:21 +01:00
commit 775c1f018f
5 changed files with 72 additions and 88 deletions

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan x // @name 4chan x
// @version 2.24.0 // @version 2.24.2
// @namespace aeosynth // @namespace aeosynth
// @description Adds various features. // @description Adds various features.
// @copyright 2009-2011 James Campos <james.r.campos@gmail.com> // @copyright 2009-2011 James Campos <james.r.campos@gmail.com>
@ -18,7 +18,7 @@
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com> * Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
* Copyright (c) 2012 Nicolas Stepien <stepien.nicolas@gmail.com> * Copyright (c) 2012 Nicolas Stepien <stepien.nicolas@gmail.com>
* http://mayhemydg.github.com/4chan-x/ * http://mayhemydg.github.com/4chan-x/
* 4chan X 2.24.0 * 4chan X 2.24.2
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation
@ -200,7 +200,7 @@
NAMESPACE = '4chan_x.'; NAMESPACE = '4chan_x.';
VERSION = '2.24.0'; VERSION = '2.24.2';
SECOND = 1000; SECOND = 1000;
@ -307,7 +307,7 @@
}; };
$.extend($, { $.extend($, {
onLoad: function(fc) { ready: function(fc) {
var cb; var cb;
if (/interactive|complete/.test(d.readyState)) return fc(); if (/interactive|complete/.test(d.readyState)) return fc();
cb = function() { cb = function() {
@ -1232,12 +1232,12 @@
$.on(a, 'click', options.dialog); $.on(a, 'click', options.dialog);
$.replace(home, a); $.replace(home, a);
if (!$.get('firstrun')) { if (!$.get('firstrun')) {
options.dialog(); $.set('firstrun', true);
return $.set('firstrun', true); return options.dialog();
} }
}, },
dialog: function() { dialog: function() {
var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, option, overlay, ta, time, ul, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref, _ref2, _ref3, _ref4, _ref5; var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4;
dialog = ui.dialog('options', '', '\ dialog = ui.dialog('options', '', '\
<div id=optionsbar>\ <div id=optionsbar>\
<div id=credits>\ <div id=credits>\
@ -1296,11 +1296,11 @@
<div class=error><code>Unread Count</code> is disabled.</div>\ <div class=error><code>Unread Count</code> is disabled.</div>\
Unread favicons<br>\ Unread favicons<br>\
<select name=favicon>\ <select name=favicon>\
<option>ferongr</option>\ <option value=ferongr>ferongr</option>\
<option>xat-</option>\ <option value=xat->xat-</option>\
<option>Mayhem</option>\ <option value=Mayhem>Mayhem</option>\
<option>Original</option>\ <option value=Original>Original</option>\
<option>None</option>\ <option value=None>None</option>\
</select>\ </select>\
<span></span>\ <span></span>\
</div>\ </div>\
@ -1372,27 +1372,20 @@
$.on(time, 'keyup', $.cb.value); $.on(time, 'keyup', $.cb.value);
$.on(time, 'keyup', options.time); $.on(time, 'keyup', options.time);
favicon = $('select', dialog); favicon = $('select', dialog);
_ref3 = favicon.options; favicon.value = conf['favicon'];
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
option = _ref3[_j];
if (option.textContent === conf['favicon']) {
option.selected = true;
break;
}
}
$.on(favicon, 'change', $.cb.value); $.on(favicon, 'change', $.cb.value);
$.on(favicon, 'change', options.favicon); $.on(favicon, 'change', options.favicon);
_ref4 = $$('#keybinds_tab + div input', dialog); _ref3 = $$('#keybinds_tab + div input', dialog);
for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) { for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
input = _ref4[_k]; input = _ref3[_j];
input.type = 'text'; input.type = 'text';
input.value = conf[input.name]; input.value = conf[input.name];
$.on(input, 'keydown', options.keybind); $.on(input, 'keydown', options.keybind);
} }
indicators = {}; indicators = {};
_ref5 = $$('.error', dialog); _ref4 = $$('.error', dialog);
for (_l = 0, _len4 = _ref5.length; _l < _len4; _l++) { for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
indicator = _ref5[_l]; indicator = _ref4[_k];
key = indicator.firstChild.textContent; key = indicator.firstChild.textContent;
indicator.hidden = conf[key]; indicator.hidden = conf[key];
indicators[key] = indicator; indicators[key] = indicator;
@ -2745,7 +2738,7 @@
threadStats.postcountEl.textContent = ++threadStats.posts; threadStats.postcountEl.textContent = ++threadStats.posts;
if ($('img[md5]', root)) { if ($('img[md5]', root)) {
threadStats.imagecountEl.textContent = ++threadStats.images; threadStats.imagecountEl.textContent = ++threadStats.images;
if (threadStats.images > 150) { if (threadStats.images > 151) {
return threadStats.imagecountEl.className = 'error'; return threadStats.imagecountEl.className = 'error';
} }
} }
@ -2754,11 +2747,11 @@
unread = { unread = {
init: function() { init: function() {
unread.replies = [];
d.title = '(0) ' + d.title; d.title = '(0) ' + d.title;
$.on(window, 'scroll', unread.scroll); $.on(window, 'scroll', unread.scroll);
return g.callbacks.push(unread.node); return g.callbacks.push(unread.node);
}, },
replies: [],
node: function(root) { node: function(root) {
if (root.hidden || root.className) return; if (root.hidden || root.className) return;
unread.replies.push(root); unread.replies.push(root);
@ -3050,21 +3043,14 @@
if (!thumb.hidden) return imgExpand.expand(thumb); if (!thumb.hidden) return imgExpand.expand(thumb);
}, },
dialog: function() { dialog: function() {
var controls, form, imageType, option, select, _i, _len, _ref; var controls, form, imageType, select;
controls = $.el('div', { controls = $.el('div', {
id: 'imgControls', id: 'imgControls',
innerHTML: "<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit height</option><option>fit screen</option></select> <label>Expand Images<input type=checkbox id=imageExpand></label>" innerHTML: "<select id=imageType name=imageType><option value=full>Full</option><option value='fit width'>Fit Width</option><option value='fit height'>Fit Height</option value='fit screen'><option value='fit screen'>Fit Screen</option></select><label>Expand Images<input type=checkbox id=imageExpand></label>"
}); });
imageType = $.get('imageType', 'full'); imageType = $.get('imageType', 'full');
select = $('select', controls); select = $('select', controls);
_ref = select.options; select.value = imageType;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
if (option.textContent === imageType) {
option.selected = true;
break;
}
}
imgExpand.cb.typeChange.call(select); imgExpand.cb.typeChange.call(select);
$.on(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
$.on(select, 'change', imgExpand.cb.typeChange); $.on(select, 'change', imgExpand.cb.typeChange);
@ -3089,22 +3075,20 @@
g.PAGENUM = parseInt(temp) || 0; g.PAGENUM = parseInt(temp) || 0;
} }
if (location.hostname === 'sys.4chan.org') { if (location.hostname === 'sys.4chan.org') {
$.onLoad(qr.sys); $.ready(qr.sys);
return; return;
} }
if (location.hostname === 'images.4chan.org') { if (location.hostname === 'images.4chan.org') {
if (conf['404 Redirect']) { $.ready(function() {
$.onLoad(function() { if (d.title === '4chan - 404') return redirect.init();
if (d.title === '4chan - 404') return redirect.init(); });
});
}
return; return;
} }
$.onLoad(options.init); $.ready(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) {
$.onLoad(function() { $.ready(function() {
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'
})); }));
@ -3136,15 +3120,16 @@
if (conf['Sauce']) sauce.init(); if (conf['Sauce']) sauce.init();
if (conf['Image Auto-Gif']) imgGif.init(); if (conf['Image Auto-Gif']) imgGif.init();
if (conf['Image Hover']) imgHover.init(); if (conf['Image Hover']) imgHover.init();
if (conf['Reveal Spoilers']) revealSpoilers.init();
if (conf['Report Button']) reportButton.init(); if (conf['Report Button']) reportButton.init();
if (conf['Quote Inline']) quoteInline.init(); if (conf['Quote Inline']) quoteInline.init();
if (conf['Quote Preview']) quotePreview.init(); if (conf['Quote Preview']) quotePreview.init();
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();
return $.onLoad(Main.onLoad); return $.ready(Main.ready);
}, },
onLoad: function() { ready: function() {
var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref; var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref;
if (conf['404 Redirect'] && d.title === '4chan - 404') { if (conf['404 Redirect'] && d.title === '4chan - 404') {
redirect.init(); redirect.init();
@ -3168,7 +3153,6 @@
if (conf['Auto Noko'] && canPost) form.action += '?noko'; if (conf['Auto Noko'] && canPost) form.action += '?noko';
if (conf['Cooldown'] && canPost) cooldown.init(); if (conf['Cooldown'] && canPost) cooldown.init();
if (conf['Image Expansion']) imgExpand.init(); if (conf['Image Expansion']) imgExpand.init();
if (conf['Reveal Spoilers'] && $('.postarea label')) revealSpoilers.init();
if (conf['Quick Reply']) qr.init(); if (conf['Quick Reply']) qr.init();
if (conf['Thread Watcher']) watcher.init(); if (conf['Thread Watcher']) watcher.init();
if (conf['Keybinds']) keybinds.init(); if (conf['Keybinds']) keybinds.init();
@ -3230,10 +3214,10 @@
}, },
css: '\ css: '\
/* dialog styling */\ /* dialog styling */\
div.dialog {\ .dialog {\
border: 1px solid;\ border: 1px solid rgba(0,0,0,.25);\
}\ }\
div.dialog > div.move {\ .move {\
cursor: move;\ cursor: move;\
}\ }\
label, a, .favicon, #qr img {\ label, a, .favicon, #qr img {\
@ -3305,6 +3289,7 @@
bottom: 0;\ bottom: 0;\
text-align: center;\ text-align: center;\
background: rgba(0,0,0,.5);\ background: rgba(0,0,0,.5);\
z-index: 1;\
}\ }\
#overlay::after {\ #overlay::after {\
content: "";\ content: "";\

View File

@ -2,7 +2,7 @@
{exec} = require 'child_process' {exec} = require 'child_process'
fs = require 'fs' fs = require 'fs'
VERSION = '2.24.0' VERSION = '2.24.2'
HEADER = """ HEADER = """
// ==UserScript== // ==UserScript==

View File

@ -1,4 +1,10 @@
master master
2.24.2
- mayhem
fix options popping up everytime a page loads
2.24.1
- mayhem - mayhem
fix Open thread in new tab keybind for Safari with Ninjakit fix Open thread in new tab keybind for Safari with Ninjakit
fix Index/Reply Navigation working in both cases when only one is enabled fix Index/Reply Navigation working in both cases when only one is enabled

View File

@ -1 +1 @@
postMessage({version:'2.24.0'},'*'); postMessage({version:'2.24.2'},'*');

View File

@ -121,7 +121,7 @@ conf = {}
) null, config ) null, config
NAMESPACE = '4chan_x.' NAMESPACE = '4chan_x.'
VERSION = '2.24.0' VERSION = '2.24.2'
SECOND = 1000 SECOND = 1000
MINUTE = 60*SECOND MINUTE = 60*SECOND
HOUR = 60*MINUTE HOUR = 60*MINUTE
@ -221,7 +221,7 @@ $.extend = (object, properties) ->
object object
$.extend $, $.extend $,
onLoad: (fc) -> ready: (fc) ->
if /interactive|complete/.test d.readyState if /interactive|complete/.test d.readyState
return fc() return fc()
cb = -> cb = ->
@ -896,8 +896,8 @@ options =
$.on a, 'click', options.dialog $.on a, 'click', options.dialog
$.replace home, a $.replace home, a
unless $.get 'firstrun' unless $.get 'firstrun'
options.dialog()
$.set 'firstrun', true $.set 'firstrun', true
options.dialog()
dialog: -> dialog: ->
dialog = ui.dialog 'options', '', ' dialog = ui.dialog 'options', '', '
@ -958,11 +958,11 @@ options =
<div class=error><code>Unread Count</code> is disabled.</div> <div class=error><code>Unread Count</code> is disabled.</div>
Unread favicons<br> Unread favicons<br>
<select name=favicon> <select name=favicon>
<option>ferongr</option> <option value=ferongr>ferongr</option>
<option>xat-</option> <option value=xat->xat-</option>
<option>Mayhem</option> <option value=Mayhem>Mayhem</option>
<option>Original</option> <option value=Original>Original</option>
<option>None</option> <option value=None>None</option>
</select> </select>
<span></span> <span></span>
</div> </div>
@ -1030,10 +1030,7 @@ options =
$.on time, 'keyup', $.cb.value $.on time, 'keyup', $.cb.value
$.on time, 'keyup', options.time $.on time, 'keyup', options.time
favicon = $ 'select', dialog favicon = $ 'select', dialog
for option in favicon.options favicon.value = conf['favicon']
if option.textContent is conf['favicon']
option.selected = true
break
$.on favicon, 'change', $.cb.value $.on favicon, 'change', $.cb.value
$.on favicon, 'change', options.favicon $.on favicon, 'change', options.favicon
@ -2144,16 +2141,17 @@ threadStats =
threadStats.postcountEl.textContent = ++threadStats.posts threadStats.postcountEl.textContent = ++threadStats.posts
if $ 'img[md5]', root if $ 'img[md5]', root
threadStats.imagecountEl.textContent = ++threadStats.images threadStats.imagecountEl.textContent = ++threadStats.images
if threadStats.images > 150 if threadStats.images > 151
threadStats.imagecountEl.className = 'error' threadStats.imagecountEl.className = 'error'
unread = unread =
init: -> init: ->
unread.replies = []
d.title = '(0) ' + d.title d.title = '(0) ' + d.title
$.on window, 'scroll', unread.scroll $.on window, 'scroll', unread.scroll
g.callbacks.push unread.node g.callbacks.push unread.node
replies: []
node: (root) -> node: (root) ->
return if root.hidden or root.className return if root.hidden or root.className
unread.replies.push root unread.replies.push root
@ -2240,7 +2238,6 @@ Favicon =
redirect = redirect =
init: -> init: ->
url = url =
# waiting for https://github.com/FoOlRulez/FoOlFuuka/issues/11
if location.hostname is 'images.4chan.org' if location.hostname is 'images.4chan.org'
redirect.image g.BOARD, location.pathname.split('/')[3] redirect.image g.BOARD, location.pathname.split('/')[3]
else if /^\d+$/.test g.THREAD_ID else if /^\d+$/.test g.THREAD_ID
@ -2372,14 +2369,10 @@ imgExpand =
controls = $.el 'div', controls = $.el 'div',
id: 'imgControls' id: 'imgControls'
innerHTML: innerHTML:
"<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit height</option><option>fit screen</option></select> "<select id=imageType name=imageType><option value=full>Full</option><option value='fit width'>Fit Width</option><option value='fit height'>Fit Height</option value='fit screen'><option value='fit screen'>Fit Screen</option></select><label>Expand Images<input type=checkbox id=imageExpand></label>"
<label>Expand Images<input type=checkbox id=imageExpand></label>"
imageType = $.get 'imageType', 'full' imageType = $.get 'imageType', 'full'
select = $ 'select', controls select = $ 'select', controls
for option in select.options select.value = imageType
if option.textContent is imageType
option.selected = true
break
imgExpand.cb.typeChange.call select imgExpand.cb.typeChange.call select
$.on select, 'change', $.cb.value $.on select, 'change', $.cb.value
$.on select, 'change', imgExpand.cb.typeChange $.on select, 'change', imgExpand.cb.typeChange
@ -2402,20 +2395,19 @@ Main =
g.PAGENUM = parseInt(temp) or 0 g.PAGENUM = parseInt(temp) or 0
if location.hostname is 'sys.4chan.org' if location.hostname is 'sys.4chan.org'
$.onLoad qr.sys $.ready qr.sys
return return
if location.hostname is 'images.4chan.org' if location.hostname is 'images.4chan.org'
if conf['404 Redirect'] $.ready -> redirect.init() if d.title is '4chan - 404'
$.onLoad -> redirect.init() if d.title is '4chan - 404'
return return
$.onLoad options.init $.ready 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
$.onLoad -> $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js' $.ready -> $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js'
$.set 'lastUpdate', now $.set 'lastUpdate', now
g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {} g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {}
@ -2462,6 +2454,9 @@ Main =
if conf['Image Hover'] if conf['Image Hover']
imgHover.init() imgHover.init()
if conf['Reveal Spoilers']
revealSpoilers.init()
if conf['Report Button'] if conf['Report Button']
reportButton.init() reportButton.init()
@ -2481,9 +2476,9 @@ Main =
quoteDR.init() quoteDR.init()
$.onLoad Main.onLoad $.ready Main.ready
onLoad: -> ready: ->
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
@ -2511,9 +2506,6 @@ Main =
if conf['Image Expansion'] if conf['Image Expansion']
imgExpand.init() imgExpand.init()
if conf['Reveal Spoilers'] and $('.postarea label')
revealSpoilers.init()
if conf['Quick Reply'] if conf['Quick Reply']
qr.init() qr.init()
@ -2585,10 +2577,10 @@ Main =
css: ' css: '
/* dialog styling */ /* dialog styling */
div.dialog { .dialog {
border: 1px solid; border: 1px solid rgba(0,0,0,.25);
} }
div.dialog > div.move { .move {
cursor: move; cursor: move;
} }
label, a, .favicon, #qr img { label, a, .favicon, #qr img {
@ -2660,6 +2652,7 @@ Main =
bottom: 0; bottom: 0;
text-align: center; text-align: center;
background: rgba(0,0,0,.5); background: rgba(0,0,0,.5);
z-index: 1;
} }
#overlay::after { #overlay::after {
content: ""; content: "";