Move the Delete Buttons into the menu as Delete Links. Enable by default. Fix cross-board deleting.
This commit is contained in:
parent
f23915b5e7
commit
7b22bb4839
@ -77,7 +77,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, AutoGif, Conf, Config, DeleteButton, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
var $, $$, Anonymize, AutoGif, Conf, Config, DeleteLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Get, ImageExpand, ImageHover, Keybinds, Main, Menu, Nav, Options, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, ReplyHiding, ReportLink, RevealSpoilers, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Time, TitlePost, UI, Unread, Updater, Watcher, d, g, _base;
|
||||||
|
|
||||||
Config = {
|
Config = {
|
||||||
main: {
|
main: {
|
||||||
@ -87,7 +87,7 @@
|
|||||||
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
|
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
|
||||||
'File Info Formatting': [true, 'Reformats the file information'],
|
'File Info Formatting': [true, 'Reformats the file information'],
|
||||||
'Report Link': [true, 'Add report links'],
|
'Report Link': [true, 'Add report links'],
|
||||||
'Delete Button': [false, 'Add delete buttons'],
|
'Delete Link': [true, 'Add delete links'],
|
||||||
'Comment Expansion': [true, 'Expand too long comments'],
|
'Comment Expansion': [true, 'Expand too long comments'],
|
||||||
'Thread Expansion': [true, 'View all replies'],
|
'Thread Expansion': [true, 'View all replies'],
|
||||||
'Index Navigation': [true, 'Navigate to previous / next thread'],
|
'Index Navigation': [true, 'Navigate to previous / next thread'],
|
||||||
@ -3798,46 +3798,42 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DeleteButton = {
|
DeleteLink = {
|
||||||
init: function() {
|
init: function() {
|
||||||
this.a = $.el('a', {
|
|
||||||
className: 'delete_button',
|
|
||||||
innerHTML: '[ × ]',
|
|
||||||
href: 'javascript:;'
|
|
||||||
});
|
|
||||||
return Main.callbacks.push(this.node);
|
|
||||||
},
|
|
||||||
node: function(post) {
|
|
||||||
var a;
|
var a;
|
||||||
if (!(a = $('.delete_button', post.el))) {
|
a = Menu.newEntry('a');
|
||||||
a = DeleteButton.a.cloneNode(true);
|
a.href = 'javascript:;';
|
||||||
$.add($('.postInfo', post.el), a);
|
$.addClass(a, 'delete_link');
|
||||||
}
|
$.on(a, 'context', function() {
|
||||||
return $.on(a, 'click', DeleteButton["delete"]);
|
a.textContent = 'Delete this post';
|
||||||
|
return $.on(a, 'click', DeleteLink["delete"]);
|
||||||
|
});
|
||||||
|
return Menu.entries.push({
|
||||||
|
el: a,
|
||||||
|
requirements: {
|
||||||
|
isArchived: false
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
"delete": function() {
|
"delete": function() {
|
||||||
var board, form, id, m, pwd, self;
|
var board, form, id, m, pwd, self;
|
||||||
$.off(this, 'click', DeleteButton["delete"]);
|
$.off(this, 'click', DeleteLink["delete"]);
|
||||||
this.innerHTML = '[ Deleting... ]';
|
this.textContent = 'Deleting...';
|
||||||
if (m = d.cookie.match(/4chan_pass=([^;]+)/)) {
|
pwd = (m = d.cookie.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $.id('delPassword').value;
|
||||||
pwd = decodeURIComponent(m[1]);
|
id = this.parentNode.dataset.id;
|
||||||
} else {
|
board = $('.postNum > a[title="Highlight this post"]', $.id(this.parentNode.dataset.rootid)).pathname.split('/')[1];
|
||||||
pwd = $.id('delPassword').value;
|
|
||||||
}
|
|
||||||
id = $.x('preceding-sibling::input', this).name;
|
|
||||||
board = $.x('preceding-sibling::span[1]/a', this).pathname.match(/\w+/)[0];
|
|
||||||
self = this;
|
self = this;
|
||||||
form = {
|
form = {
|
||||||
mode: 'usrdel',
|
mode: 'usrdel',
|
||||||
pwd: pwd
|
pwd: pwd
|
||||||
};
|
};
|
||||||
form[id] = 'delete';
|
form[id] = 'delete';
|
||||||
return $.ajax("https://sys.4chan.org/" + board + "/imgboard.php", {
|
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + board + "/"), {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
return DeleteButton.load(self, this.response);
|
return DeleteLink.load(self, this.response);
|
||||||
},
|
},
|
||||||
onerror: function() {
|
onerror: function() {
|
||||||
return DeleteButton.error(self);
|
return DeleteLink.error(self);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
form: $.formData(form)
|
form: $.formData(form)
|
||||||
@ -3851,15 +3847,15 @@
|
|||||||
s = 'Banned!';
|
s = 'Banned!';
|
||||||
} else if (msg = doc.getElementById('errmsg')) {
|
} else if (msg = doc.getElementById('errmsg')) {
|
||||||
s = msg.textContent;
|
s = msg.textContent;
|
||||||
$.on(self, 'click', DeleteButton["delete"]);
|
$.on(self, 'click', DeleteLink["delete"]);
|
||||||
} else {
|
} else {
|
||||||
s = 'Deleted';
|
s = 'Deleted';
|
||||||
}
|
}
|
||||||
return self.innerHTML = "[ " + s + " ]";
|
return self.textContent = s;
|
||||||
},
|
},
|
||||||
error: function(self) {
|
error: function(self) {
|
||||||
self.innerHTML = '[ Connection error, please retry. ]';
|
self.textContent = 'Connection error, please retry.';
|
||||||
return $.on(self, 'click', DeleteButton["delete"]);
|
return $.on(self, 'click', DeleteLink["delete"]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4533,8 +4529,8 @@
|
|||||||
if (Conf['Report Link']) {
|
if (Conf['Report Link']) {
|
||||||
ReportLink.init();
|
ReportLink.init();
|
||||||
}
|
}
|
||||||
if (Conf['Delete Button']) {
|
if (Conf['Delete Link']) {
|
||||||
DeleteButton.init();
|
DeleteLink.init();
|
||||||
}
|
}
|
||||||
if (Conf['Resurrect Quotes']) {
|
if (Conf['Resurrect Quotes']) {
|
||||||
Quotify.init();
|
Quotify.init();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ Config =
|
|||||||
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
|
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
|
||||||
'File Info Formatting': [true, 'Reformats the file information']
|
'File Info Formatting': [true, 'Reformats the file information']
|
||||||
'Report Link': [true, 'Add report links']
|
'Report Link': [true, 'Add report links']
|
||||||
'Delete Button': [false, 'Add delete buttons']
|
'Delete Link': [true, 'Add delete links']
|
||||||
'Comment Expansion': [true, 'Expand too long comments']
|
'Comment Expansion': [true, 'Expand too long comments']
|
||||||
'Thread Expansion': [true, 'View all replies']
|
'Thread Expansion': [true, 'View all replies']
|
||||||
'Index Navigation': [true, 'Navigate to previous / next thread']
|
'Index Navigation': [true, 'Navigate to previous / next thread']
|
||||||
@ -2981,28 +2981,31 @@ Quotify =
|
|||||||
$.replace node, nodes
|
$.replace node, nodes
|
||||||
return
|
return
|
||||||
|
|
||||||
DeleteButton =
|
DeleteLink =
|
||||||
init: ->
|
init: ->
|
||||||
@a = $.el 'a',
|
a = Menu.newEntry 'a'
|
||||||
className: 'delete_button'
|
a.href = 'javascript:;'
|
||||||
innerHTML: '[ × ]'
|
$.addClass a, 'delete_link'
|
||||||
href: 'javascript:;'
|
$.on a, 'context', ->
|
||||||
Main.callbacks.push @node
|
a.textContent = 'Delete this post'
|
||||||
node: (post) ->
|
$.on a, 'click', DeleteLink.delete
|
||||||
unless a = $ '.delete_button', post.el
|
Menu.entries.push
|
||||||
a = DeleteButton.a.cloneNode true
|
el: a
|
||||||
$.add $('.postInfo', post.el), a
|
requirements:
|
||||||
$.on a, 'click', DeleteButton.delete
|
isArchived: false
|
||||||
delete: ->
|
delete: ->
|
||||||
$.off @, 'click', DeleteButton.delete
|
$.off @, 'click', DeleteLink.delete
|
||||||
@innerHTML = '[ Deleting... ]'
|
@textContent = 'Deleting...'
|
||||||
|
|
||||||
if m = d.cookie.match /4chan_pass=([^;]+)/
|
pwd =
|
||||||
pwd = decodeURIComponent m[1]
|
if m = d.cookie.match /4chan_pass=([^;]+)/
|
||||||
else
|
decodeURIComponent m[1]
|
||||||
pwd = $.id('delPassword').value
|
else
|
||||||
id = $.x('preceding-sibling::input', @).name
|
$.id('delPassword').value
|
||||||
board = $.x('preceding-sibling::span[1]/a', @).pathname.match(/\w+/)[0]
|
|
||||||
|
id = @parentNode.dataset.id
|
||||||
|
board = $('.postNum > a[title="Highlight this post"]',
|
||||||
|
$.id @parentNode.dataset.rootid).pathname.split('/')[1]
|
||||||
self = this
|
self = this
|
||||||
|
|
||||||
form =
|
form =
|
||||||
@ -3010,13 +3013,12 @@ DeleteButton =
|
|||||||
pwd: pwd
|
pwd: pwd
|
||||||
form[id] = 'delete'
|
form[id] = 'delete'
|
||||||
|
|
||||||
$.ajax "https://sys.4chan.org/#{board}/imgboard.php", {
|
$.ajax $.id('delform').action.replace("/#{g.BOARD}/", "/#{board}/"), {
|
||||||
onload: -> DeleteButton.load self, @response
|
onload: -> DeleteLink.load self, @response
|
||||||
onerror: -> DeleteButton.error self
|
onerror: -> DeleteLink.error self
|
||||||
}, {
|
}, {
|
||||||
form: $.formData form
|
form: $.formData form
|
||||||
}
|
}
|
||||||
|
|
||||||
load: (self, html) ->
|
load: (self, html) ->
|
||||||
doc = d.implementation.createHTMLDocument ''
|
doc = d.implementation.createHTMLDocument ''
|
||||||
doc.documentElement.innerHTML = html
|
doc.documentElement.innerHTML = html
|
||||||
@ -3024,13 +3026,13 @@ DeleteButton =
|
|||||||
s = 'Banned!'
|
s = 'Banned!'
|
||||||
else if msg = doc.getElementById 'errmsg' # error!
|
else if msg = doc.getElementById 'errmsg' # error!
|
||||||
s = msg.textContent
|
s = msg.textContent
|
||||||
$.on self, 'click', DeleteButton.delete
|
$.on self, 'click', DeleteLink.delete
|
||||||
else
|
else
|
||||||
s = 'Deleted'
|
s = 'Deleted'
|
||||||
self.innerHTML = "[ #{s} ]"
|
self.textContent = s
|
||||||
error: (self) ->
|
error: (self) ->
|
||||||
self.innerHTML = '[ Connection error, please retry. ]'
|
self.textContent = 'Connection error, please retry.'
|
||||||
$.on self, 'click', DeleteButton.delete
|
$.on self, 'click', DeleteLink.delete
|
||||||
|
|
||||||
ReportLink =
|
ReportLink =
|
||||||
init: ->
|
init: ->
|
||||||
@ -3529,8 +3531,8 @@ Main =
|
|||||||
if Conf['Report Link']
|
if Conf['Report Link']
|
||||||
ReportLink.init()
|
ReportLink.init()
|
||||||
|
|
||||||
if Conf['Delete Button']
|
if Conf['Delete Link']
|
||||||
DeleteButton.init()
|
DeleteLink.init()
|
||||||
|
|
||||||
if Conf['Resurrect Quotes']
|
if Conf['Resurrect Quotes']
|
||||||
Quotify.init()
|
Quotify.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user