From f8fe6bd137ab72a6838847e4b7a7e686fd81661a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 5 May 2011 16:44:00 +0200 Subject: [PATCH 01/16] Better watch icon update. Ready for automatic refresh? --- 4chan_x.js | 62 ++++++++++++++++++--------------------------------- script.coffee | 37 +++++++++++------------------- 2 files changed, 35 insertions(+), 64 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 2f1798b9e..0de870b65 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1464,54 +1464,46 @@ }; watcher = { init: function() { - var dialog, favicon, html, id, input, inputs, src, watched, watchedBoard, _i, _len, _results; + var dialog, favicon, html, input, inputs, watched, _i, _len; html = '
Thread Watcher
'; dialog = ui.dialog('watcher', { top: '50px', left: '0px' }, html); $.append(d.body, dialog); - watched = $.getValue('watched', {}); - watcher.refresh(watched); - watchedBoard = watched[g.BOARD] || {}; inputs = $$('form > input[value=delete], div.thread > input[value=delete]'); - _results = []; for (_i = 0, _len = inputs.length; _i < _len; _i++) { input = inputs[_i]; - id = input.name; - if (id in watchedBoard) { - src = Favicon["default"]; - } else { - src = Favicon.empty; - } favicon = $.el('img', { - src: src, className: 'favicon' }); $.bind(favicon, 'click', watcher.cb.toggle); - _results.push($.before(input, favicon)); + $.before(input, favicon); } - return _results; + watched = $.getValue('watched', {}); + return watcher.refresh(watched); }, refresh: function(watched) { - var board, div, id, props, _i, _len, _ref, _results; + var board, div, favicon, id, props, watchedBoard, _i, _j, _len, _len2, _ref, _ref2, _ref3, _results; _ref = $$('#watcher > div:not(.move)'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { div = _ref[_i]; $.remove(div); } - _results = []; for (board in watched) { - _results.push((function() { - var _ref2, _results2; - _ref2 = watched[board]; - _results2 = []; - for (id in _ref2) { - props = _ref2[id]; - _results2.push(watcher.addLink(props, $('#watcher'))); - } - return _results2; - })()); + _ref2 = watched[board]; + for (id in _ref2) { + props = _ref2[id]; + watcher.addLink(props, $('#watcher')); + } + } + watchedBoard = watched[g.BOARD] || {}; + _ref3 = $$('img.favicon'); + _results = []; + for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { + favicon = _ref3[_j]; + id = favicon.nextSibling.name; + _results.push(id in watchedBoard ? favicon.src = Favicon["default"] : favicon.src = Favicon.empty); } return _results; }, @@ -1541,30 +1533,20 @@ favicon = $('img.favicon', thread); id = favicon.nextSibling.name; if (favicon.src === Favicon.empty) { - return watcher.watch(thread); + return watcher.watch(thread, id); } else { return watcher.unwatch(g.BOARD, id); } }, unwatch: function(board, id) { - var favicon, input, watched; - if (input = $("input[name=\"" + id + "\"]")) { - favicon = input.previousSibling; - favicon.src = Favicon.empty; - } + var watched; watched = $.getValue('watched', {}); delete watched[board][id]; $.setValue('watched', watched); return watcher.refresh(watched); }, - watch: function(thread) { - var favicon, id, props, tc, watched, _name; - favicon = $('img.favicon', thread); - if (favicon.src === Favicon["default"]) { - return; - } - favicon.src = Favicon["default"]; - id = favicon.nextSibling.name; + watch: function(thread, id) { + var props, tc, watched, _name; tc = $('span.filetitle', thread).textContent || $('blockquote', thread).textContent; props = { textContent: "/" + g.BOARD + "/ - " + tc.slice(0, 25), diff --git a/script.coffee b/script.coffee index 0ef275f32..d52872294 100644 --- a/script.coffee +++ b/script.coffee @@ -1167,31 +1167,31 @@ watcher = dialog = ui.dialog 'watcher', top: '50px', left: '0px', html $.append d.body, dialog - #populate watcher - watched = $.getValue 'watched', {} - watcher.refresh watched - #add watch buttons - watchedBoard = watched[g.BOARD] or {} inputs = $$ 'form > input[value=delete], div.thread > input[value=delete]' for input in inputs - id = input.name - if id of watchedBoard - src = Favicon.default - else - src = Favicon.empty favicon = $.el 'img', - src: src className: 'favicon' $.bind favicon, 'click', watcher.cb.toggle $.before input, favicon + #populate watcher, display watch buttons + watched = $.getValue 'watched', {} + watcher.refresh watched + refresh: (watched) -> for div in $$ '#watcher > div:not(.move)' $.remove div for board of watched for id, props of watched[board] watcher.addLink props, $ '#watcher' + watchedBoard = watched[g.BOARD] or {} + for favicon in $$ 'img.favicon' + id = favicon.nextSibling.name + if id of watchedBoard + favicon.src = Favicon.default + else + favicon.src = Favicon.empty addLink: (props, dialog) -> div = $.el 'div' @@ -1215,29 +1215,18 @@ watcher = favicon = $ 'img.favicon', thread id = favicon.nextSibling.name if favicon.src == Favicon.empty - watcher.watch thread + watcher.watch thread, id else # favicon.src == Favicon.default watcher.unwatch g.BOARD, id unwatch: (board, id) -> - if input = $ "input[name=\"#{id}\"]" - favicon = input.previousSibling - favicon.src = Favicon.empty - watched = $.getValue 'watched', {} delete watched[board][id] $.setValue 'watched', watched watcher.refresh watched - watch: (thread) -> - favicon = $ 'img.favicon', thread - - #this happens if we try to auto-watch an already watched thread. - return if favicon.src is Favicon.default - - favicon.src = Favicon.default - id = favicon.nextSibling.name + watch: (thread, id) -> tc = $('span.filetitle', thread).textContent or $('blockquote', thread).textContent props = textContent: "/#{g.BOARD}/ - #{tc[...25]}" From 484740da1173b3c16551ef213f950774a51ab0f7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 5 May 2011 18:16:21 +0200 Subject: [PATCH 02/16] Automatic watcher updates. --- 4chan_x.js | 8 +++++--- script.coffee | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 0de870b65..08772dbc7 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1464,7 +1464,7 @@ }; watcher = { init: function() { - var dialog, favicon, html, input, inputs, watched, _i, _len; + var dialog, favicon, html, input, inputs, _i, _len; html = '
Thread Watcher
'; dialog = ui.dialog('watcher', { top: '50px', @@ -1480,8 +1480,10 @@ $.bind(favicon, 'click', watcher.cb.toggle); $.before(input, favicon); } - watched = $.getValue('watched', {}); - return watcher.refresh(watched); + watcher.refresh($.getValue('watched', {})); + return setInterval((function() { + return watcher.refresh($.getValue('watched', {})); + }), 1000); }, refresh: function(watched) { var board, div, favicon, id, props, watchedBoard, _i, _j, _len, _len2, _ref, _ref2, _ref3, _results; diff --git a/script.coffee b/script.coffee index d52872294..b90bb1115 100644 --- a/script.coffee +++ b/script.coffee @@ -1176,8 +1176,9 @@ watcher = $.before input, favicon #populate watcher, display watch buttons - watched = $.getValue 'watched', {} - watcher.refresh watched + watcher.refresh $.getValue 'watched', {} + + setInterval (-> watcher.refresh($.getValue 'watched', {}) ), 1000 refresh: (watched) -> for div in $$ '#watcher > div:not(.move)' From 458f03167b76717c7e2400be7e32554d503b4ece Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 5 May 2011 18:56:12 +0200 Subject: [PATCH 03/16] Every second, check if we updated one second before. --- 4chan_x.js | 15 ++++++++++----- script.coffee | 6 +++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 08772dbc7..05a67438e 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1482,11 +1482,13 @@ } watcher.refresh($.getValue('watched', {})); return setInterval((function() { - return watcher.refresh($.getValue('watched', {})); + if (Date.now() > $.getValue('watcher.lastUpdated', 0)) { + return watcher.refresh($.getValue('watched', {})); + } }), 1000); }, refresh: function(watched) { - var board, div, favicon, id, props, watchedBoard, _i, _j, _len, _len2, _ref, _ref2, _ref3, _results; + var board, div, favicon, id, props, watchedBoard, _i, _j, _len, _len2, _ref, _ref2, _ref3; _ref = $$('#watcher > div:not(.move)'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { div = _ref[_i]; @@ -1501,13 +1503,16 @@ } watchedBoard = watched[g.BOARD] || {}; _ref3 = $$('img.favicon'); - _results = []; for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { favicon = _ref3[_j]; id = favicon.nextSibling.name; - _results.push(id in watchedBoard ? favicon.src = Favicon["default"] : favicon.src = Favicon.empty); + if (id in watchedBoard) { + favicon.src = Favicon["default"]; + } else { + favicon.src = Favicon.empty; + } } - return _results; + return $.setValue('watcher.lastUpdated', Date.now()); }, addLink: function(props, dialog) { var div, link, x; diff --git a/script.coffee b/script.coffee index b90bb1115..e3760ab50 100644 --- a/script.coffee +++ b/script.coffee @@ -1178,7 +1178,10 @@ watcher = #populate watcher, display watch buttons watcher.refresh $.getValue 'watched', {} - setInterval (-> watcher.refresh($.getValue 'watched', {}) ), 1000 + setInterval (-> + if Date.now() > $.getValue 'watcher.lastUpdated', 0 + watcher.refresh($.getValue 'watched', {}) + ), 1000 refresh: (watched) -> for div in $$ '#watcher > div:not(.move)' @@ -1193,6 +1196,7 @@ watcher = favicon.src = Favicon.default else favicon.src = Favicon.empty + $.setValue 'watcher.lastUpdated', Date.now() addLink: (props, dialog) -> div = $.el 'div' From d31ec005f816435bce5cd84c8b7ad0a7da5a7a27 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 5 May 2011 19:28:30 +0200 Subject: [PATCH 04/16] Aeosynth you dummy. --- 4chan_x.js | 5 +++-- script.coffee | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 05a67438e..d9baf6527 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1482,7 +1482,7 @@ } watcher.refresh($.getValue('watched', {})); return setInterval((function() { - if (Date.now() > $.getValue('watcher.lastUpdated', 0)) { + if (watcher.lastUpdated < $.getValue('watcher.lastUpdated', 0)) { return watcher.refresh($.getValue('watched', {})); } }), 1000); @@ -1512,7 +1512,8 @@ favicon.src = Favicon.empty; } } - return $.setValue('watcher.lastUpdated', Date.now()); + $.setValue('watcher.lastUpdated', Date.now()); + return watcher.lastUpdated = Date.now(); }, addLink: function(props, dialog) { var div, link, x; diff --git a/script.coffee b/script.coffee index e3760ab50..4cfe35c36 100644 --- a/script.coffee +++ b/script.coffee @@ -1179,7 +1179,7 @@ watcher = watcher.refresh $.getValue 'watched', {} setInterval (-> - if Date.now() > $.getValue 'watcher.lastUpdated', 0 + if watcher.lastUpdated < $.getValue 'watcher.lastUpdated', 0 watcher.refresh($.getValue 'watched', {}) ), 1000 @@ -1197,6 +1197,7 @@ watcher = else favicon.src = Favicon.empty $.setValue 'watcher.lastUpdated', Date.now() + watcher.lastUpdated = Date.now() addLink: (props, dialog) -> div = $.el 'div' From 8d8da47d32c2b9202b098627cc7af3183d31e79c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 5 May 2011 23:42:33 +0200 Subject: [PATCH 05/16] archive.no-ip.org doesn't archive /c/ ;_; --- 4chan_x.js | 1 - script.coffee | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index d9baf6527..8806d04cc 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1782,7 +1782,6 @@ case '3': case 'adv': case 'an': - case 'c': case 'ck': case 'co': case 'fa': diff --git a/script.coffee b/script.coffee index 4cfe35c36..227102600 100644 --- a/script.coffee +++ b/script.coffee @@ -1390,7 +1390,7 @@ redirect = -> url = "http://green-oval.net/cgi-board.pl/#{g.BOARD}/thread/#{g.THREAD_ID}" when 'jp', 'm', 'tg' url = "http://archive.easymodo.net/cgi-board.pl/#{g.BOARD}/thread/#{g.THREAD_ID}" - when '3', 'adv', 'an', 'c', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' + when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' url = "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}" else url = "http://boards.4chan.org/#{g.BOARD}" From c0a70c40fdc884e097fc9827f8d70b42214cce52 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 6 May 2011 01:24:26 +0200 Subject: [PATCH 06/16] Fix Auto-Watch. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 8806d04cc..15204e748 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -2188,7 +2188,7 @@ unread.init(); } if ($.config('Auto Watch') && location.hash === '#watch') { - watcher.watch(); + watcher.watch($('body > form'), $('form > input[value=delete]').name); } } else { threading.init(); diff --git a/script.coffee b/script.coffee index 227102600..7d33118a9 100644 --- a/script.coffee +++ b/script.coffee @@ -1699,7 +1699,7 @@ main = unread.init() if $.config('Auto Watch') and location.hash is '#watch' - watcher.watch() + watcher.watch($('body > form'), $('form > input[value=delete]').name) else #not reply threading.init() From 5c58d3f0319b847c2d20a55cfa1aee41ddb3d0d6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 6 May 2011 23:53:50 -0700 Subject: [PATCH 07/16] rm watcher.addlink --- 4chan_x.js | 25 +++++++++++-------------- script.coffee | 25 ++++++++++++------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 15204e748..0ffc85079 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1488,8 +1488,9 @@ }), 1000); }, refresh: function(watched) { - var board, div, favicon, id, props, watchedBoard, _i, _j, _len, _len2, _ref, _ref2, _ref3; - _ref = $$('#watcher > div:not(.move)'); + var board, dialog, div, favicon, id, link, props, watchedBoard, x, _i, _j, _len, _len2, _ref, _ref2, _ref3; + dialog = $('#watcher'); + _ref = $$('div:not(.move)', dialog); for (_i = 0, _len = _ref.length; _i < _len; _i++) { div = _ref[_i]; $.remove(div); @@ -1498,7 +1499,14 @@ _ref2 = watched[board]; for (id in _ref2) { props = _ref2[id]; - watcher.addLink(props, $('#watcher')); + div = $.el('div'); + x = $.el('a', { + textContent: 'X' + }); + $.bind(x, 'click', watcher.cb.x); + link = $.el('a', props); + $.append(div, x, $.tn(' '), link); + $.append(dialog, div); } } watchedBoard = watched[g.BOARD] || {}; @@ -1515,17 +1523,6 @@ $.setValue('watcher.lastUpdated', Date.now()); return watcher.lastUpdated = Date.now(); }, - addLink: function(props, dialog) { - var div, link, x; - div = $.el('div'); - x = $.el('a', { - textContent: 'X' - }); - $.bind(x, 'click', watcher.cb.x); - link = $.el('a', props); - $.append(div, x, $.tn(' '), link); - return $.append(dialog, div); - }, cb: { toggle: function(e) { return watcher.toggle(e.target.parentNode); diff --git a/script.coffee b/script.coffee index 7d33118a9..0eb8585cb 100644 --- a/script.coffee +++ b/script.coffee @@ -1180,15 +1180,24 @@ watcher = setInterval (-> if watcher.lastUpdated < $.getValue 'watcher.lastUpdated', 0 - watcher.refresh($.getValue 'watched', {}) + watcher.refresh $.getValue 'watched', {} ), 1000 refresh: (watched) -> - for div in $$ '#watcher > div:not(.move)' + dialog = $ '#watcher' + for div in $$ 'div:not(.move)', dialog $.remove div for board of watched for id, props of watched[board] - watcher.addLink props, $ '#watcher' + div = $.el 'div' + x = $.el 'a', + textContent: 'X' + $.bind x, 'click', watcher.cb.x + link = $.el 'a', props + + $.append div, x, $.tn(' '), link + $.append dialog, div + watchedBoard = watched[g.BOARD] or {} for favicon in $$ 'img.favicon' id = favicon.nextSibling.name @@ -1199,16 +1208,6 @@ watcher = $.setValue 'watcher.lastUpdated', Date.now() watcher.lastUpdated = Date.now() - addLink: (props, dialog) -> - div = $.el 'div' - x = $.el 'a', - textContent: 'X' - $.bind x, 'click', watcher.cb.x - link = $.el 'a', props - - $.append div, x, $.tn(' '), link - $.append dialog, div - cb: toggle: (e) -> watcher.toggle e.target.parentNode From b4169832c6bb9e75d5d21cc5c332ddfd1f6120e5 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 6 May 2011 23:59:29 -0700 Subject: [PATCH 08/16] better auto-watch condition --- 4chan_x.js | 4 ++-- script.coffee | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 0ffc85079..198baec1f 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -2184,8 +2184,8 @@ if ($.config('Unread Count')) { unread.init(); } - if ($.config('Auto Watch') && location.hash === '#watch') { - watcher.watch($('body > form'), $('form > input[value=delete]').name); + if ($.config('Auto Watch') && $.config('Thread Watcher') && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) { + watcher.watch(null, g.THREAD_ID); } } else { threading.init(); diff --git a/script.coffee b/script.coffee index 0eb8585cb..09dc87bc3 100644 --- a/script.coffee +++ b/script.coffee @@ -1697,8 +1697,9 @@ main = if $.config 'Unread Count' unread.init() - if $.config('Auto Watch') and location.hash is '#watch' - watcher.watch($('body > form'), $('form > input[value=delete]').name) + if $.config('Auto Watch') and $.config('Thread Watcher') and + location.hash is '#watch' and $('img.favicon').src is Favicon.empty + watcher.watch null, g.THREAD_ID else #not reply threading.init() From 94058fa9eb9582e91842efb584a5b07ffcabcf74 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 7 May 2011 00:17:16 -0700 Subject: [PATCH 09/16] flavor comments --- 4chan_x.js | 17 ++++++++++++++--- script.coffee | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 198baec1f..801801915 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -94,7 +94,7 @@ 'Unread Count': [true, 'Show unread post count in tab title'] }, textarea: { - flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url='].join('\n') + flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n') } }, updater: { @@ -1592,8 +1592,19 @@ }, cb: { node: function(root) { - var i, link, names, prefix, prefixes, span, suffix, _i, _len, _ref, _results; - prefixes = $.config('flavors').split('\n'); + var i, link, names, prefix, prefixes, s, span, suffix, _i, _len, _ref, _results; + prefixes = (function() { + var _i, _len, _ref, _results; + _ref = $.config('flavors').split('\n'); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + s = _ref[_i]; + if (s[0] !== '#') { + _results.push(s); + } + } + return _results; + })(); names = (function() { var _i, _len, _results; _results = []; diff --git a/script.coffee b/script.coffee index 09dc87bc3..87f00f59c 100644 --- a/script.coffee +++ b/script.coffee @@ -41,6 +41,7 @@ config = 'http://regex.info/exif.cgi?url=' 'http://iqdb.org/?url=' 'http://tineye.com/search?url=' + '#http://saucenao.com/search.php?db=999&url=' ].join '\n' updater: checkbox: @@ -1263,7 +1264,7 @@ sauce = g.callbacks.push sauce.cb.node cb: node: (root) -> - prefixes = $.config('flavors').split '\n' + prefixes = (s for s in ($.config('flavors').split '\n') when s[0] != '#') names = (prefix.match(/(\w+)\./)[1] for prefix in prefixes) for span in $$ 'span.filesize', root suffix = $('a', span).href From 0802720a6fe26d0ea50d3228b89f561516192fcc Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 7 May 2011 00:50:06 -0700 Subject: [PATCH 10/16] 2.3.0 --- 4chan_x.js | 2 +- changelog | 8 ++++++++ header | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 801801915..52243900f 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -2,7 +2,7 @@ // @name 4chan x // @namespace aeosynth // @description Adds various features. -// @version 2.2.2 +// @version 2.3.0 // @copyright 2009-2011 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* diff --git a/changelog b/changelog index 805539893..c0e20b2c9 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,11 @@ +2.3.0 +- mayhem: + refresh watcher list on un/watch + auto refresh watcher list + update no-ip.org archive + fix auto-watch +- flavor comments + 2.2.2 - hopefully fix upgrading issues diff --git a/header b/header index 0b3df9579..1e96c45ad 100644 --- a/header +++ b/header @@ -2,7 +2,7 @@ // @name 4chan x // @namespace aeosynth // @description Adds various features. -// @version 2.2.2 +// @version 2.3.0 // @copyright 2009-2011 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* From 43617c6db9214d438e4ba4c684fde75bfdb3d520 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 15:54:07 +0200 Subject: [PATCH 11/16] Start work for watch thread on reply. --- 4chan_x.js | 11 ++++++++--- script.coffee | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 52243900f..095214714 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -91,7 +91,8 @@ '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'] + 'Unread Count': [true, 'Show unread post count in tab title'], + 'Watch on Reply': [false, 'Automatically watch threads you reply to'] }, textarea: { flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n') @@ -1022,9 +1023,13 @@ return _results; }, submit: function(e) { - var form, isQR, recaptcha, span; + var form, isQR, recaptcha, span, value; form = e.target; isQR = form.parentNode.id === 'qr'; + if ($.config('Watch on Reply') && $.config('Thread Watcher')) { + value = g.THREAD_ID || $('input[name=resto]').value; + watcher.watch(null, value); + } if (isQR) { if (span = this.nextSibling) { $.remove(span); @@ -1113,7 +1118,7 @@ }, cooldownStart: function(duration) { var submit, submits, _i, _len; - submits = $$('#qr input[type=submit], form[name=post] input[type=submit]'); + submits = $$('#com_submit'); for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; submit.value = duration; diff --git a/script.coffee b/script.coffee index 87f00f59c..75d486949 100644 --- a/script.coffee +++ b/script.coffee @@ -36,6 +36,7 @@ config = 'Thread Updater': [true, 'Update threads'] 'Thread Watcher': [true, 'Bookmark threads'] 'Unread Count': [true, 'Show unread post count in tab title'] + 'Watch on Reply': [false, 'Automatically watch threads you reply to'] textarea: flavors: [ 'http://regex.info/exif.cgi?url=' @@ -774,6 +775,10 @@ qr = form = e.target isQR = form.parentNode.id == 'qr' + if $.config('Watch on Reply') and $.config('Thread Watcher') + value = g.THREAD_ID or $('input[name=resto]').value + watcher.watch null, value + if isQR if span = @nextSibling $.remove span @@ -854,7 +859,7 @@ qr = return true cooldownStart: (duration) -> - submits = $$ '#qr input[type=submit], form[name=post] input[type=submit]' + submits = $$ '#com_submit' for submit in submits submit.value = duration submit.disabled = true From c669c7a128245d795ae1f8819eb563dbc46e4c26 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 15:56:02 +0200 Subject: [PATCH 12/16] Also have that less retarded selector. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 095214714..4736cb6f9 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1130,7 +1130,7 @@ cooldownCB: function() { var submit, submits, _i, _len; qr.duration = qr.duration - 1; - submits = $$('#qr input[type=submit], form[name=post] input[type=submit]'); + submits = $$('#com_submit'); for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; if (qr.duration === 0) { diff --git a/script.coffee b/script.coffee index 75d486949..6ad1d904b 100644 --- a/script.coffee +++ b/script.coffee @@ -869,7 +869,7 @@ qr = cooldownCB: -> qr.duration = qr.duration - 1 - submits = $$ '#qr input[type=submit], form[name=post] input[type=submit]' + submits = $$ '#com_submit' for submit in submits if qr.duration == 0 submit.disabled = false From 85516f8c9e6c879bb9d85134c10e768f4e110b06 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 17:20:27 +0200 Subject: [PATCH 13/16] Finish watch thread on reply. --- 4chan_x.js | 16 +++++++++++++--- script.coffee | 10 ++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 4736cb6f9..ffebe67da 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1023,12 +1023,22 @@ return _results; }, submit: function(e) { - var form, isQR, recaptcha, span, value; + var form, isQR, recaptcha, span, thread, threads, value, _i, _len; form = e.target; isQR = form.parentNode.id === 'qr'; if ($.config('Watch on Reply') && $.config('Thread Watcher')) { - value = g.THREAD_ID || $('input[name=resto]').value; - watcher.watch(null, value); + if (g.REPLY && $('img.favicon').src === Favicon.empty) { + watcher.watch(null, g.THREAD_ID); + } else { + value = $('input[name=resto]').value; + threads = $$('div.op'); + for (_i = 0, _len = threads.length; _i < _len; _i++) { + thread = threads[_i]; + if (thread.id === value && $('img.favicon', thread).src === Favicon.empty) { + watcher.watch(thread, value); + } + } + } } if (isQR) { if (span = this.nextSibling) { diff --git a/script.coffee b/script.coffee index 6ad1d904b..8c4846ea5 100644 --- a/script.coffee +++ b/script.coffee @@ -776,8 +776,14 @@ qr = isQR = form.parentNode.id == 'qr' if $.config('Watch on Reply') and $.config('Thread Watcher') - value = g.THREAD_ID or $('input[name=resto]').value - watcher.watch null, value + if g.REPLY and $('img.favicon').src is Favicon.empty + watcher.watch null, g.THREAD_ID + else + value = $('input[name=resto]').value + threads = $$ 'div.op' + for thread in threads + if thread.id is value and $('img.favicon', thread).src is Favicon.empty + watcher.watch thread, value if isQR if span = @nextSibling From 4b53286f6cf9a242aa071532e4454adadfb70f00 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 7 May 2011 12:03:39 -0700 Subject: [PATCH 14/16] better text selection prevention --- 4chan_x.js | 12 ++---------- script.coffee | 13 +++---------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 52243900f..9cb79ffa5 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -179,9 +179,9 @@ }, dragstart: function(e) { var d, el, rect; + e.preventDefault(); ui.el = el = e.target.parentNode; d = document; - d.body.className = 'noselect'; d.addEventListener('mousemove', ui.drag, true); d.addEventListener('mouseup', ui.dragend, true); rect = el.getBoundingClientRect(); @@ -192,6 +192,7 @@ }, drag: function(e) { var bottom, el, left, right, top; + e.preventDefault(); el = ui.el; left = e.clientX - ui.dx; if (left < 20) { @@ -219,7 +220,6 @@ localStorage["" + id + "Left"] = el.style.left; localStorage["" + id + "Top"] = el.style.top; d = document; - d.body.className = ''; d.removeEventListener('mousemove', ui.drag, true); return d.removeEventListener('mouseup', ui.dragend, true); } @@ -2330,14 +2330,6 @@ #watcher > div:last-child {\ padding-bottom: 5px;\ }\ -\ - body.noselect {\ - -webkit-user-select: none;\ - -khtml-user-select: none;\ - -moz-user-select: none;\ - -o-user-select: none;\ - user-select: none;\ - }\ ' }; main.init(); diff --git a/script.coffee b/script.coffee index 87f00f59c..ecde1e7e5 100644 --- a/script.coffee +++ b/script.coffee @@ -99,9 +99,10 @@ ui = (-> el.parentNode.removeChild(el)), true el dragstart: (e) -> + #prevent text selection + e.preventDefault() ui.el = el = e.target.parentNode d = document - d.body.className = 'noselect' d.addEventListener 'mousemove', ui.drag, true d.addEventListener 'mouseup', ui.dragend, true #distance from pointer to el edge is constant; calculate it here. @@ -113,6 +114,7 @@ ui = ui.width = document.body.clientWidth - el.offsetWidth ui.height = document.body.clientHeight - el.offsetHeight drag: (e) -> + e.preventDefault() {el} = ui left = e.clientX - ui.dx if left < 20 then left = '0px' @@ -135,7 +137,6 @@ ui = localStorage["#{id}Left"] = el.style.left localStorage["#{id}Top"] = el.style.top d = document - d.body.className = '' d.removeEventListener 'mousemove', ui.drag, true d.removeEventListener 'mouseup', ui.dragend, true @@ -1830,14 +1831,6 @@ main = #watcher > div:last-child { padding-bottom: 5px; } - - body.noselect { - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -o-user-select: none; - user-select: none; - } ' main.init() From 17f2d6e8b6cb075bb5988c53eacdd37290043b0b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 22:48:01 +0200 Subject: [PATCH 15/16] Do not break the report button. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 336d64443..edc3e6582 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1697,7 +1697,7 @@ for (_i = 0, _len = arr.length; _i < _len; _i++) { el = arr[_i]; a = $.el('a', { - textContent: '[ ! ]' + innerHTML: '[ ! ]' }); $.bind(a, 'click', quickReport.cb.report); $.after(el, a); diff --git a/script.coffee b/script.coffee index 24d00be20..892b2e7e8 100644 --- a/script.coffee +++ b/script.coffee @@ -1325,7 +1325,7 @@ quickReport = arr = $$ 'span[id^=no]', root for el in arr a = $.el 'a', - textContent: '[ ! ]' + innerHTML: '[ ! ]' $.bind a, 'click', quickReport.cb.report $.after el, a $.after el, $.tn(' ') From eb59ecd63dd941c5bb30566f0718e593ec62ec50 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 7 May 2011 14:56:42 -0700 Subject: [PATCH 16/16] tweak auto watch reply --- 4chan_x.js | 19 ++++++++----------- script.coffee | 13 ++++++------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index edc3e6582..63842c7b6 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -71,6 +71,7 @@ '404 Redirect': [true, 'Redirect dead threads'], 'Anonymize': [false, 'Make everybody anonymous'], 'Auto Watch': [true, 'Automatically watch threads that you start'], + 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'], 'Comment Expansion': [true, 'Expand too long comments'], 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'], 'Image Auto-Gif': [false, 'Animate gif thumbnails'], @@ -91,8 +92,7 @@ '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'], - 'Watch on Reply': [false, 'Automatically watch threads you reply to'] + 'Unread Count': [true, 'Show unread post count in tab title'] }, textarea: { flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n') @@ -1023,20 +1023,17 @@ return _results; }, submit: function(e) { - var form, isQR, recaptcha, span, thread, threads, value, _i, _len; + var form, id, isQR, op, recaptcha, span; form = e.target; isQR = form.parentNode.id === 'qr'; - if ($.config('Watch on Reply') && $.config('Thread Watcher')) { + if ($.config('Auto Watch Reply') && $.config('Thread Watcher')) { if (g.REPLY && $('img.favicon').src === Favicon.empty) { watcher.watch(null, g.THREAD_ID); } else { - value = $('input[name=resto]').value; - threads = $$('div.op'); - for (_i = 0, _len = threads.length; _i < _len; _i++) { - thread = threads[_i]; - if (thread.id === value && $('img.favicon', thread).src === Favicon.empty) { - watcher.watch(thread, value); - } + id = $('input[name=resto]').value; + op = d.getElementById(id); + if ($('img.favicon', op).src === Favicon.empty) { + watcher.watch(op, id); } } } diff --git a/script.coffee b/script.coffee index 892b2e7e8..c50272e40 100644 --- a/script.coffee +++ b/script.coffee @@ -15,6 +15,7 @@ config = '404 Redirect': [true, 'Redirect dead threads'] 'Anonymize': [false, 'Make everybody anonymous'] 'Auto Watch': [true, 'Automatically watch threads that you start'] + 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] 'Comment Expansion': [true, 'Expand too long comments'] 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'] 'Image Auto-Gif': [false, 'Animate gif thumbnails'] @@ -36,7 +37,6 @@ config = 'Thread Updater': [true, 'Update threads'] 'Thread Watcher': [true, 'Bookmark threads'] 'Unread Count': [true, 'Show unread post count in tab title'] - 'Watch on Reply': [false, 'Automatically watch threads you reply to'] textarea: flavors: [ 'http://regex.info/exif.cgi?url=' @@ -776,15 +776,14 @@ qr = form = e.target isQR = form.parentNode.id == 'qr' - if $.config('Watch on Reply') and $.config('Thread Watcher') + if $.config('Auto Watch Reply') and $.config('Thread Watcher') if g.REPLY and $('img.favicon').src is Favicon.empty watcher.watch null, g.THREAD_ID else - value = $('input[name=resto]').value - threads = $$ 'div.op' - for thread in threads - if thread.id is value and $('img.favicon', thread).src is Favicon.empty - watcher.watch thread, value + id = $('input[name=resto]').value + op = d.getElementById id + if $('img.favicon', op).src is Favicon.empty + watcher.watch op, id if isQR if span = @nextSibling