diff --git a/4chan_x.user.js b/4chan_x.user.js index d9fee1ed5..39d667293 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3435,22 +3435,22 @@ return $.on(a, 'click', DeleteButton["delete"]); }, "delete": function() { - var data, id, m, pwd, self; + var board, data, id, m, pwd, self; + $.off(this, 'click', DeleteButton["delete"]); + this.textContent = 'Deleting...'; if (m = d.cookie.match(/4chan_pass=([^;]+)/)) { pwd = decodeURIComponent(m[1]); } else { - this.textContent = 'Error: no password found'; - return; + pwd = $.id('delPassword').value; } - $.off(this, 'click', DeleteButton["delete"]); - this.textContent = 'Deleting...'; id = $.x('preceding-sibling::input', this).name; + board = $.x('preceding-sibling::span[1]/a', this).pathname.match(/\w+/)[0]; + self = this; data = new FormData(); data.append(id, 'delete'); data.append('mode', 'usrdel'); data.append('pwd', pwd); - self = this; - return $.ajax("https://sys.4chan.org/" + g.BOARD + "/imgboard.php", { + return $.ajax("https://sys.4chan.org/" + board + "/imgboard.php", { onload: function() { return DeleteButton.load(self, this.response); }, diff --git a/script.coffee b/script.coffee index eedd97457..ecd530c7c 100644 --- a/script.coffee +++ b/script.coffee @@ -2619,28 +2619,30 @@ DeleteButton = $.add $('.postInfo', post.el), a $.on a, 'click', DeleteButton.delete delete: -> - if m = d.cookie.match(/4chan_pass=([^;]+)/) - pwd = decodeURIComponent m[1] - else - @textContent = 'Error: no password found' - return - $.off @, 'click', DeleteButton.delete @textContent = 'Deleting...' + if m = d.cookie.match(/4chan_pass=([^;]+)/) + pwd = decodeURIComponent m[1] + else + pwd = $.id('delPassword').value id = $.x('preceding-sibling::input', @).name + board = $.x('preceding-sibling::span[1]/a', @).pathname.match(/\w+/)[0] + self = this + data = new FormData() data.append id, 'delete' data.append 'mode', 'usrdel' data.append 'pwd', pwd - self = this - $.ajax "https://sys.4chan.org/#{g.BOARD}/imgboard.php", { + + $.ajax "https://sys.4chan.org/#{board}/imgboard.php", { onload: -> DeleteButton.load self, @response onerror: -> DeleteButton.error self }, { type: 'post' form: data } + load: (self, html) -> doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = html