start thread updater rewrite
This commit is contained in:
parent
9b6667be1a
commit
de6794515f
138
4chan_x.js
138
4chan_x.js
@ -59,36 +59,47 @@
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var $, $$, NAMESPACE, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, config, d, delform, down, el, expand, expandComment, expandThread, g, getThread, href, i, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, keyModeInsert, keyModeNormal, keydown, keypress, l1, log, navtopr, nodeInserted, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, replyNav, report, request, scroll, scrollThread, span, temp, text, textContent, threadHiding, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watcher, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4;
|
||||
var $, $$, NAMESPACE, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, config, d, delform, down, el, expand, expandComment, expandThread, g, getThread, href, i, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, keyModeInsert, keyModeNormal, keydown, keypress, l1, log, navtopr, nodeInserted, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, replyNav, report, request, scroll, scrollThread, span, temp, text, textContent, threadHiding, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updater, updaterMake, watcher, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4;
|
||||
var __slice = Array.prototype.slice;
|
||||
if (typeof console != "undefined" && console !== null) {
|
||||
log = console.log;
|
||||
}
|
||||
config = {
|
||||
'404 Redirect': [true, 'Redirect dead threads'],
|
||||
'Anonymize': [false, 'Make everybody anonymous'],
|
||||
'Auto Watch': [true, 'Automatically watch threads that you start (Firefox only)'],
|
||||
'Comment Expansion': [true, 'Expand too long comments'],
|
||||
'Image Auto-Gif': [false, 'Animate gif thumbnails'],
|
||||
'Image Expansion': [true, 'Expand images'],
|
||||
'Image Hover': [false, 'Show full image on mouseover'],
|
||||
'Image Preloading': [false, 'Preload Images'],
|
||||
'Keybinds': [false, 'Binds actions to keys'],
|
||||
'Localize Time': [true, 'Show times based on your timezone'],
|
||||
'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'],
|
||||
'Post in Title': [true, 'Show the op\'s post in the tab title'],
|
||||
'Quick Reply': [true, 'Reply without leaving the page'],
|
||||
'Quick Report': [true, 'Add quick report buttons'],
|
||||
'Reply Hiding': [true, 'Hide single replies'],
|
||||
'Reply Navigation': [false, 'Navigate to the beginning / end of a thread'],
|
||||
'Sauce': [true, 'Add sauce to images'],
|
||||
'Show Stubs': [true, 'Of hidden threads / replies'],
|
||||
'Thread Expansion': [true, 'View all replies'],
|
||||
'Thread Hiding': [true, 'Hide entire threads'],
|
||||
'Thread Navigation': [true, 'Navigate to previous / next thread'],
|
||||
'Thread Updater': [true, 'Update threads'],
|
||||
'Thread Watcher': [true, 'Bookmark threads'],
|
||||
'Unread Count': [true, 'Show unread post count in tab title']
|
||||
main: {
|
||||
checkbox: {
|
||||
'404 Redirect': [true, 'Redirect dead threads'],
|
||||
'Anonymize': [false, 'Make everybody anonymous'],
|
||||
'Auto Watch': [true, 'Automatically watch threads that you start (Firefox only)'],
|
||||
'Comment Expansion': [true, 'Expand too long comments'],
|
||||
'Image Auto-Gif': [false, 'Animate gif thumbnails'],
|
||||
'Image Expansion': [true, 'Expand images'],
|
||||
'Image Hover': [false, 'Show full image on mouseover'],
|
||||
'Image Preloading': [false, 'Preload Images'],
|
||||
'Keybinds': [false, 'Binds actions to keys'],
|
||||
'Localize Time': [true, 'Show times based on your timezone'],
|
||||
'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'],
|
||||
'Post in Title': [true, 'Show the op\'s post in the tab title'],
|
||||
'Quick Reply': [true, 'Reply without leaving the page'],
|
||||
'Quick Report': [true, 'Add quick report buttons'],
|
||||
'Reply Hiding': [true, 'Hide single replies'],
|
||||
'Reply Navigation': [false, 'Navigate to the beginning / end of a thread'],
|
||||
'Sauce': [true, 'Add sauce to images'],
|
||||
'Show Stubs': [true, 'Of hidden threads / replies'],
|
||||
'Thread Expansion': [true, 'View all replies'],
|
||||
'Thread Hiding': [true, 'Hide entire threads'],
|
||||
'Thread Navigation': [true, 'Navigate to previous / next thread'],
|
||||
'Thread Updater': [true, 'Update threads'],
|
||||
'Thread Watcher': [true, 'Bookmark threads'],
|
||||
'Unread Count': [true, 'Show unread post count in tab title']
|
||||
}
|
||||
},
|
||||
updater: {
|
||||
checkbox: {
|
||||
'Verbose': [true, 'Show countdown timer, new post count'],
|
||||
'Auto Update': [false, 'Automatically fetch new posts']
|
||||
},
|
||||
'Interval': 30
|
||||
}
|
||||
};
|
||||
if (typeof GM_deleteValue === 'undefined') {
|
||||
window.GM_setValue = function(name, value) {
|
||||
@ -229,10 +240,10 @@
|
||||
$.extend($, {
|
||||
cb: {
|
||||
checked: function() {
|
||||
return GM_setValue(this.name, this.checked);
|
||||
return $.getValue(this.name, this.checked);
|
||||
},
|
||||
value: function() {
|
||||
return GM_setValue(this.name, this.value);
|
||||
return $.setValue(this.name, this.checked);
|
||||
}
|
||||
},
|
||||
deleteValue: function(name) {
|
||||
@ -259,8 +270,11 @@
|
||||
style.textContent = css;
|
||||
return $.append(d.head, style);
|
||||
},
|
||||
config: function(name) {
|
||||
return GM_getValue(name, config[name][0]);
|
||||
config: function(name, conf) {
|
||||
if (conf == null) {
|
||||
conf = config.main.checkbox;
|
||||
}
|
||||
return $.getValue(name, conf[name][0]);
|
||||
},
|
||||
zeroPad: function(n) {
|
||||
if (n < 10) {
|
||||
@ -917,12 +931,13 @@
|
||||
}
|
||||
},
|
||||
dialog: function() {
|
||||
var checked, dialog, hiddenNum, hiddenThread, html, input, name, title, _i, _len, _ref;
|
||||
var checked, conf, dialog, hiddenNum, hiddenThread, html, input, name, title, _i, _len, _ref;
|
||||
html = "<div class=move>Options <a name=close>X</a></div>";
|
||||
for (name in config) {
|
||||
title = config[name][1];
|
||||
conf = config.main.checkbox;
|
||||
for (name in conf) {
|
||||
title = conf[name][1];
|
||||
checked = $.config(name) ? "checked" : "";
|
||||
html += "<div><label title=\"" + title + "\">" + name + "<input " + checked + " name=\"" + name + "\" type=checkbox></label></div>";
|
||||
html += "<div><label title=\"" + title + "\">" + name + "<input name=\"" + name + "\" " + checked + " type=checkbox></label></div>";
|
||||
}
|
||||
html += "<div><a name=flavors>Flavors</a></div>";
|
||||
html += "<div><textarea style=\"display: none;\" name=flavors>" + (GM_getValue('flavors', g.flavors)) + "</textarea></div>";
|
||||
@ -1543,6 +1558,57 @@
|
||||
return $("#updater #count").textContent = 'Thread Updater';
|
||||
}
|
||||
};
|
||||
updater = {
|
||||
init: function() {
|
||||
var autoUpT, box, checked, conf, dialog, html, name, title, verbose, _i, _len, _ref;
|
||||
html = "<div class=move><span id=count></span> <span id=timer></span></div>";
|
||||
conf = config.updater.checkbox;
|
||||
for (name in conf) {
|
||||
title = conf[name][1];
|
||||
checked = $.config(name, conf) ? "checked" : "";
|
||||
html += "<div><label title=\"" + title + "\">" + name + "<input name=\"" + name + "\" " + checked + " type=checkbox></label></div>";
|
||||
}
|
||||
name = 'Auto Update This';
|
||||
title = 'Controls whether *this* thread auotmatically updates or not';
|
||||
checked = $.config('Auto Update', conf) ? 'checked' : '';
|
||||
html += "<div><label title=\"" + title + "\">" + name + "<input name=\"" + name + "\" " + checked + " type=checkbox></label></div>";
|
||||
dialog = ui.dialog('updater', {
|
||||
bottom: '0px',
|
||||
right: '0px'
|
||||
}, html);
|
||||
_ref = $$('input[type=checkbox]', dialog);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
box = _ref[_i];
|
||||
$.bind(box, 'click', $.cb.checked);
|
||||
}
|
||||
verbose = $('input[name=\"Verbose\"]', dialog);
|
||||
autoUpT = $('input[name=\"Auto Update This\"]', dialog);
|
||||
$.bind(verbose, 'click', updater.cb.verbose);
|
||||
$.bind(autoUpT, 'click', updater.cb.autoUpdate);
|
||||
$.append(d.body, dialog);
|
||||
return updater.cb.verbose.call(verbose);
|
||||
},
|
||||
cb: {
|
||||
verbose: function(e) {
|
||||
var t;
|
||||
if (this.checked) {
|
||||
$.show($('#count'));
|
||||
return $('#timer').textContent = (t = updater.timer) ? t : 'Thread Updater';
|
||||
} else {
|
||||
$.hide($('#count'));
|
||||
return $('#timer').textContent = 'Thread Updater';
|
||||
}
|
||||
},
|
||||
autoUpdate: function(e) {
|
||||
if (this.checked) {
|
||||
updater.timer = $.config('Interval', config.updater);
|
||||
return $('#timer').textContent = updater.timer;
|
||||
} else {
|
||||
return updater.timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
updaterMake = function() {
|
||||
var div, html, input, interval, name, _i, _len, _ref;
|
||||
html = "<div class=move><span id=count>Thread Updater</span> <span id=timer></span></div>";
|
||||
@ -2029,6 +2095,9 @@
|
||||
$.bind(d, 'keydown', keydown);
|
||||
$.bind(d, 'keypress', keypress);
|
||||
}
|
||||
if ($.config('Thread Updater')) {
|
||||
updater.init();
|
||||
}
|
||||
if (g.REPLY) {
|
||||
if ($.config('Image Preloading')) {
|
||||
g.callbacks.push(function(root) {
|
||||
@ -2045,9 +2114,6 @@
|
||||
return _results;
|
||||
});
|
||||
}
|
||||
if ($.config('Thread Updater')) {
|
||||
updaterMake();
|
||||
}
|
||||
if ($.config('Quick Reply') && $.config('Persistent QR')) {
|
||||
qr.persist();
|
||||
}
|
||||
|
||||
119
script.coffee
119
script.coffee
@ -7,30 +7,37 @@
|
||||
{log} = console if console?
|
||||
|
||||
config =
|
||||
'404 Redirect': [true, 'Redirect dead threads']
|
||||
'Anonymize': [false, 'Make everybody anonymous']
|
||||
'Auto Watch': [true, 'Automatically watch threads that you start (Firefox only)']
|
||||
'Comment Expansion': [true, 'Expand too long comments']
|
||||
'Image Auto-Gif': [false, 'Animate gif thumbnails']
|
||||
'Image Expansion': [true, 'Expand images']
|
||||
'Image Hover': [false, 'Show full image on mouseover']
|
||||
'Image Preloading': [false, 'Preload Images']
|
||||
'Keybinds': [false, 'Binds actions to keys']
|
||||
'Localize Time': [true, 'Show times based on your timezone']
|
||||
'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.']
|
||||
'Post in Title': [true, 'Show the op\'s post in the tab title']
|
||||
'Quick Reply': [true, 'Reply without leaving the page']
|
||||
'Quick Report': [true, 'Add quick report buttons']
|
||||
'Reply Hiding': [true, 'Hide single replies']
|
||||
'Reply Navigation': [false, 'Navigate to the beginning / end of a thread']
|
||||
'Sauce': [true, 'Add sauce to images']
|
||||
'Show Stubs': [true, 'Of hidden threads / replies']
|
||||
'Thread Expansion': [true, 'View all replies']
|
||||
'Thread Hiding': [true, 'Hide entire threads']
|
||||
'Thread Navigation': [true, 'Navigate to previous / next thread']
|
||||
'Thread Updater': [true, 'Update threads']
|
||||
'Thread Watcher': [true, 'Bookmark threads']
|
||||
'Unread Count': [true, 'Show unread post count in tab title']
|
||||
main:
|
||||
checkbox:
|
||||
'404 Redirect': [true, 'Redirect dead threads']
|
||||
'Anonymize': [false, 'Make everybody anonymous']
|
||||
'Auto Watch': [true, 'Automatically watch threads that you start (Firefox only)']
|
||||
'Comment Expansion': [true, 'Expand too long comments']
|
||||
'Image Auto-Gif': [false, 'Animate gif thumbnails']
|
||||
'Image Expansion': [true, 'Expand images']
|
||||
'Image Hover': [false, 'Show full image on mouseover']
|
||||
'Image Preloading': [false, 'Preload Images']
|
||||
'Keybinds': [false, 'Binds actions to keys']
|
||||
'Localize Time': [true, 'Show times based on your timezone']
|
||||
'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.']
|
||||
'Post in Title': [true, 'Show the op\'s post in the tab title']
|
||||
'Quick Reply': [true, 'Reply without leaving the page']
|
||||
'Quick Report': [true, 'Add quick report buttons']
|
||||
'Reply Hiding': [true, 'Hide single replies']
|
||||
'Reply Navigation': [false, 'Navigate to the beginning / end of a thread']
|
||||
'Sauce': [true, 'Add sauce to images']
|
||||
'Show Stubs': [true, 'Of hidden threads / replies']
|
||||
'Thread Expansion': [true, 'View all replies']
|
||||
'Thread Hiding': [true, 'Hide entire threads']
|
||||
'Thread Navigation': [true, 'Navigate to previous / next thread']
|
||||
'Thread Updater': [true, 'Update threads']
|
||||
'Thread Watcher': [true, 'Bookmark threads']
|
||||
'Unread Count': [true, 'Show unread post count in tab title']
|
||||
updater:
|
||||
checkbox:
|
||||
'Verbose': [true, 'Show countdown timer, new post count']
|
||||
'Auto Update': [false, 'Automatically fetch new posts']
|
||||
'Interval': 30
|
||||
|
||||
#x-browser
|
||||
if typeof GM_deleteValue is 'undefined'
|
||||
@ -135,9 +142,9 @@ $.extend = (object, properties) ->
|
||||
$.extend $,
|
||||
cb:
|
||||
checked: ->
|
||||
GM_setValue @name, @checked
|
||||
$.getValue @name, @checked
|
||||
value: ->
|
||||
GM_setValue @name, @value
|
||||
$.setValue @name, @checked
|
||||
deleteValue: (name) ->
|
||||
name = NAMESPACE + name
|
||||
delete localStorage[name]
|
||||
@ -155,8 +162,8 @@ $.extend $,
|
||||
style.type = 'text/css'
|
||||
style.textContent = css
|
||||
$.append d.head, style
|
||||
config: (name) ->
|
||||
GM_getValue name, config[name][0]
|
||||
config: (name, conf=config.main.checkbox) ->
|
||||
$.getValue name, conf[name][0]
|
||||
zeroPad: (n) ->
|
||||
if n < 10 then '0' + n else n
|
||||
x: (path, root=d.body) ->
|
||||
@ -675,10 +682,11 @@ options =
|
||||
|
||||
dialog: ->
|
||||
html = "<div class=move>Options <a name=close>X</a></div>"
|
||||
for name of config
|
||||
title = config[name][1]
|
||||
conf = config.main.checkbox
|
||||
for name of conf
|
||||
title = conf[name][1]
|
||||
checked = if $.config name then "checked" else ""
|
||||
html += "<div><label title=\"#{title}\">#{name}<input #{checked} name=\"#{name}\" type=checkbox></label></div>"
|
||||
html += "<div><label title=\"#{title}\">#{name}<input name=\"#{name}\" #{checked} type=checkbox></label></div>"
|
||||
html += "<div><a name=flavors>Flavors</a></div>"
|
||||
html += "<div><textarea style=\"display: none;\" name=flavors>#{GM_getValue 'flavors', g.flavors}</textarea></div>"
|
||||
|
||||
@ -1180,6 +1188,50 @@ updateVerbose = ->
|
||||
timer.hidden = true
|
||||
$("#updater #count").textContent = 'Thread Updater'
|
||||
|
||||
updater =
|
||||
init: ->
|
||||
html = "<div class=move><span id=count></span> <span id=timer></span></div>"
|
||||
conf = config.updater.checkbox
|
||||
for name of conf
|
||||
title = conf[name][1]
|
||||
checked = if $.config name, conf then "checked" else ""
|
||||
html += "<div><label title=\"#{title}\">#{name}<input name=\"#{name}\" #{checked} type=checkbox></label></div>"
|
||||
|
||||
name = 'Auto Update This'
|
||||
title = 'Controls whether *this* thread auotmatically updates or not'
|
||||
checked = if $.config 'Auto Update', conf then 'checked' else ''
|
||||
html += "<div><label title=\"#{title}\">#{name}<input name=\"#{name}\" #{checked} type=checkbox></label></div>"
|
||||
|
||||
dialog = ui.dialog 'updater', bottom: '0px', right: '0px', html
|
||||
|
||||
for box in $$ 'input[type=checkbox]', dialog
|
||||
$.bind box, 'click', $.cb.checked
|
||||
|
||||
verbose = $ 'input[name=\"Verbose\"]', dialog
|
||||
autoUpT = $ 'input[name=\"Auto Update This\"]', dialog
|
||||
$.bind verbose, 'click', updater.cb.verbose
|
||||
$.bind autoUpT, 'click', updater.cb.autoUpdate
|
||||
|
||||
$.append d.body, dialog
|
||||
|
||||
updater.cb.verbose.call verbose
|
||||
#updater.cb.autoUpdate.call autoUpT
|
||||
|
||||
cb:
|
||||
verbose: (e) ->
|
||||
if @checked
|
||||
$.show $ '#count'
|
||||
$('#timer').textContent = if t = updater.timer then t else 'Thread Updater'
|
||||
else
|
||||
$.hide $ '#count'
|
||||
$('#timer').textContent = 'Thread Updater'
|
||||
autoUpdate: (e) ->
|
||||
if @checked
|
||||
updater.timer = $.config 'Interval', config.updater
|
||||
$('#timer').textContent = updater.timer
|
||||
else
|
||||
updater.timer = null
|
||||
|
||||
updaterMake = ->
|
||||
html = "<div class=move><span id=count>Thread Updater</span> <span id=timer></span></div>"
|
||||
html += "<div><label>Verbose<input type=checkbox name=verbose></label></div>"
|
||||
@ -1594,6 +1646,9 @@ if $.config 'Keybinds'
|
||||
$.bind d, 'keydown', keydown
|
||||
$.bind d, 'keypress', keypress
|
||||
|
||||
if $.config 'Thread Updater'
|
||||
updater.init()
|
||||
|
||||
if g.REPLY
|
||||
if $.config 'Image Preloading'
|
||||
g.callbacks.push (root) ->
|
||||
@ -1601,8 +1656,6 @@ if g.REPLY
|
||||
for thumb in thumbs
|
||||
parent = thumb.parentNode
|
||||
el = $.el 'img', src: parent.href
|
||||
if $.config 'Thread Updater'
|
||||
updaterMake()
|
||||
if $.config('Quick Reply') and $.config 'Persistent QR'
|
||||
qr.persist()
|
||||
if $.config 'Post in Title'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user