diff --git a/4chan_x.user.js b/4chan_x.user.js index 6563f2c59..358c9650c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -72,7 +72,7 @@ */ (function() { - var $, $$, Anonymize, AutoGif, Conf, Config, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, ImageExpand, ImageHover, Keybinds, Main, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportButton, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base; + var $, $$, Anonymize, AutoGif, Conf, Config, DeleteButton, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, ImageExpand, ImageHover, Keybinds, Main, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportButton, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base; Config = { main: { @@ -82,6 +82,7 @@ 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'], 'File Info Formatting': [true, 'Reformats the file information'], 'Report Button': [true, 'Add report buttons'], + 'Delete Button': [false, 'Add delete buttons'], 'Comment Expansion': [true, 'Expand too long comments'], 'Thread Expansion': [true, 'View all replies'], 'Index Navigation': [true, 'Navigate to previous / next thread'], @@ -3416,6 +3417,29 @@ } }; + DeleteButton = { + init: function() { + this.a = $.el('a', { + className: 'delete_button', + innerHTML: '[ X ]', + href: 'javascript:;' + }); + return Main.callbacks.push(this.node); + }, + node: function(post) { + var a; + if (!(a = $('.delete_button', post.el))) { + a = DeleteButton.a.cloneNode(true); + $.add($('.postInfo', post.el), a); + } + return $.on(a, 'click', DeleteButton["delete"]); + }, + "delete": function() { + $.x('preceding-sibling::input', this).checked = true; + return $.id('delPassword').nextElementSibling.click(); + } + }; + ReportButton = { init: function() { this.a = $.el('a', { @@ -4053,6 +4077,9 @@ if (Conf['Report Button']) { ReportButton.init(); } + if (Conf['Delete Button']) { + DeleteButton.init(); + } if (Conf['Resurrect Quotes']) { Quotify.init(); } diff --git a/changelog b/changelog index 79ba5bcfb..f8965c85f 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- aeosynth + delete button 2.31.6 - Mayhem diff --git a/script.coffee b/script.coffee index c40a271f3..a537e5f78 100644 --- a/script.coffee +++ b/script.coffee @@ -6,6 +6,7 @@ Config = 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'] 'File Info Formatting': [true, 'Reformats the file information'] 'Report Button': [true, 'Add report buttons'] + 'Delete Button': [false, 'Add delete buttons'] 'Comment Expansion': [true, 'Expand too long comments'] 'Thread Expansion': [true, 'View all replies'] 'Index Navigation': [true, 'Navigate to previous / next thread'] @@ -2605,6 +2606,22 @@ Quotify = $.replace node, nodes return +DeleteButton = + init: -> + @a = $.el 'a', + className: 'delete_button' + innerHTML: '[ X ]' + href: 'javascript:;' + Main.callbacks.push @node + node: (post) -> + unless a = $ '.delete_button', post.el + a = DeleteButton.a.cloneNode true + $.add $('.postInfo', post.el), a + $.on a, 'click', DeleteButton.delete + delete: -> + $.x('preceding-sibling::input', @).checked = true + $.id('delPassword').nextElementSibling.click() + ReportButton = init: -> @a = $.el 'a', @@ -3082,6 +3099,9 @@ Main = if Conf['Report Button'] ReportButton.init() + if Conf['Delete Button'] + DeleteButton.init() + if Conf['Resurrect Quotes'] Quotify.init()