diff --git a/4chan_x.user.js b/4chan_x.user.js index 02c17dac0..be17b17ee 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -43,7 +43,7 @@ */ (function() { - var $, $$, Anonymize, ArchiveLink, AutoGIF, Board, Build, Clone, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Fourchan, Get, Header, ImageExpand, ImageHover, Keybinds, Main, Menu, Misc, Nav, Notification, Polyfill, Post, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, ReplyHiding, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, d, doc, g, + var $, $$, Anonymize, ArchiveLink, AutoGIF, Board, Build, Clone, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Fourchan, Get, Header, ImageExpand, ImageHover, Keybinds, Main, Menu, Misc, Nav, Notification, Polyfill, Post, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, ReplyHiding, Report, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, d, doc, g, __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; }, __hasProp = {}.hasOwnProperty, @@ -6788,6 +6788,34 @@ } }; + Report = { + init: function() { + if (!/report/.test(location.search)) { + return; + } + return $.ready(this.ready); + }, + ready: function() { + var field, form; + form = $('form'); + field = $.id('recaptcha_response_field'); + $.on(field, 'keydown', function(e) { + if (e.keyCode === 8 && !field.value) { + return $.unsafeWindow.Recaptcha.reload('t'); + } + }); + return $.on(form, 'submit', function(e) { + var response; + e.preventDefault(); + response = field.value.trim(); + if (!/\s/.test(response)) { + field.value = "" + response + " " + response; + } + return form.submit(); + }); + } + }; + Board = (function() { Board.prototype.toString = function() { @@ -7159,6 +7187,7 @@ } switch (location.hostname) { case 'sys.4chan.org': + Report.init(); return; case 'images.4chan.org': $.ready(function() { diff --git a/Gruntfile.js b/Gruntfile.js index 5f42ec483..d3fed0ee6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,6 +16,7 @@ module.exports = function(grunt) { 'lib/polyfill.coffee', 'src/features.coffee', 'src/qr.coffee', + 'src/report.coffee', 'src/main.coffee' ], dest: 'tmp/script.coffee' @@ -65,6 +66,7 @@ module.exports = function(grunt) { interrupt: true }, files: [ + 'Gruntfile.js', 'package.json', 'lib/**/*.coffee', 'src/**/*.coffee', diff --git a/src/main.coffee b/src/main.coffee index 1a9cd40e2..5a51db6a5 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -289,6 +289,7 @@ Main = switch location.hostname when 'sys.4chan.org' + Report.init() return when 'images.4chan.org' $.ready -> diff --git a/src/report.coffee b/src/report.coffee new file mode 100644 index 000000000..42ae19bd4 --- /dev/null +++ b/src/report.coffee @@ -0,0 +1,14 @@ +Report = + init: -> + return unless /report/.test location.search + $.ready @ready + ready: -> + form = $ 'form' + field = $.id 'recaptcha_response_field' + $.on field, 'keydown', (e) -> + $.unsafeWindow.Recaptcha.reload 't' if e.keyCode is 8 and not field.value + $.on form, 'submit', (e) -> + e.preventDefault() + response = field.value.trim() + field.value = "#{response} #{response}" unless /\s/.test response + form.submit()