Add option to fix XXX'd post numbers.

This commit is contained in:
Nicolas Stepien 2012-02-15 13:56:01 +01:00
parent 6716d64b97
commit 2292ac2815
3 changed files with 42 additions and 3 deletions

View File

@ -71,13 +71,14 @@
*/ */
(function() { (function() {
var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, SECOND, Time, VERSION, anonymize, conf, config, d, engine, expandComment, expandThread, filter, flatten, g, getTitle, imgExpand, imgGif, imgHover, key, keybinds, log, nav, options, qr, quoteBacklink, quoteDR, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _base, var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, SECOND, Time, VERSION, anonymize, conf, config, d, engine, expandComment, expandThread, filter, flatten, g, getTitle, imgExpand, imgGif, imgHover, key, keybinds, log, nav, options, qr, quoteBacklink, quoteDR, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, unxify, updater, val, watcher, _base,
__slice = Array.prototype.slice; __slice = Array.prototype.slice;
config = { config = {
main: { main: {
Enhancing: { Enhancing: {
'404 Redirect': [true, 'Redirect dead threads and images'], '404 Redirect': [true, 'Redirect dead threads and images'],
'Fix XXX\'d Post Numbers': [true, 'Replace XXX\'d post numbers with their actual number'],
'Keybinds': [true, 'Binds actions to keys'], 'Keybinds': [true, 'Binds actions to keys'],
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'], 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
'Report Button': [true, 'Add report buttons'], 'Report Button': [true, 'Add report buttons'],
@ -1189,6 +1190,23 @@
} }
}; };
unxify = {
init: function() {
return g.callbacks.push(this.node);
},
node: function(root) {
var quote;
if (unxify.censor === false) return;
if (unxify.censor === void 0) {
unxify.censor = /\D/.test($('.quotejs + .quotejs', root).textContent);
unxify.node(root);
return;
}
quote = $('.quotejs + .quotejs', root);
return quote.textContent = quote.previousElementSibling.hash.slice(1);
}
};
qr = { qr = {
init: function() { init: function() {
var form, iframe, link, loadChecking; var form, iframe, link, loadChecking;
@ -1348,7 +1366,7 @@
if (!g.REPLY) { if (!g.REPLY) {
$('select', qr.el).value = $.x('ancestor::div[@class="thread"]/div', this).id; $('select', qr.el).value = $.x('ancestor::div[@class="thread"]/div', this).id;
} }
id = this.hash.slice(2); id = this.previousElementSibling.hash.slice(1);
text = ">>" + id + "\n"; text = ">>" + id + "\n";
sel = window.getSelection(); sel = window.getSelection();
if ((s = sel.toString()) && id === ((_ref = $.x('ancestor-or-self::blockquote/preceding-sibling::input', sel.anchorNode)) != null ? _ref.name : void 0)) { if ((s = sel.toString()) && id === ((_ref = $.x('ancestor-or-self::blockquote/preceding-sibling::input', sel.anchorNode)) != null ? _ref.name : void 0)) {
@ -3562,6 +3580,7 @@
if (conf['Quote Backlinks']) quoteBacklink.init(); if (conf['Quote Backlinks']) quoteBacklink.init();
if (conf['Indicate OP quote']) quoteOP.init(); if (conf['Indicate OP quote']) quoteOP.init();
if (conf['Indicate Cross-thread Quotes']) quoteDR.init(); if (conf['Indicate Cross-thread Quotes']) quoteDR.init();
if (conf['Fix XXX\'d Post Numbers']) unxify.init();
if (conf['Quick Reply'] && conf['Hide Original Post Form']) { if (conf['Quick Reply'] && conf['Hide Original Post Form']) {
Main.css += 'form[name=post] { display: none; }'; Main.css += 'form[name=post] { display: none; }';
} }

View File

@ -1,5 +1,6 @@
master master
- Mayhem - Mayhem
New option to fix XXX'd post numbers.
Fix post number quoting on /b/ and /v/. Fix post number quoting on /b/ and /v/.
Update archive redirection for /v/. Update archive redirection for /v/.

View File

@ -2,6 +2,7 @@ config =
main: main:
Enhancing: Enhancing:
'404 Redirect': [true, 'Redirect dead threads and images'] '404 Redirect': [true, 'Redirect dead threads and images']
'Fix XXX\'d Post Numbers': [true, 'Replace XXX\'d post numbers with their actual number']
'Keybinds': [true, 'Binds actions to keys'] 'Keybinds': [true, 'Binds actions to keys']
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'] 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
'Report Button': [true, 'Add report buttons'] 'Report Button': [true, 'Add report buttons']
@ -868,6 +869,21 @@ nav =
{top} = nav.threads[i]?.getBoundingClientRect() {top} = nav.threads[i]?.getBoundingClientRect()
window.scrollBy 0, top window.scrollBy 0, top
unxify =
init: ->
g.callbacks.push @node
node: (root) ->
if unxify.censor is false
# Don't execute on safe boards
return
if unxify.censor is undefined
# Test if the board's censored
unxify.censor = /\D/.test $('.quotejs + .quotejs', root).textContent
unxify.node root
return
quote = $ '.quotejs + .quotejs', root
quote.textContent = quote.previousElementSibling.hash[1..]
qr = qr =
init: -> init: ->
return unless $.id 'recaptcha_challenge_field_holder' return unless $.id 'recaptcha_challenge_field_holder'
@ -997,7 +1013,7 @@ qr =
$('select', qr.el).value = $.x('ancestor::div[@class="thread"]/div', @).id $('select', qr.el).value = $.x('ancestor::div[@class="thread"]/div', @).id
# Make sure we get the correct number, even with XXX censors # Make sure we get the correct number, even with XXX censors
id = @hash[2..] id = @previousElementSibling.hash[1..]
text = ">>#{id}\n" text = ">>#{id}\n"
sel = window.getSelection() sel = window.getSelection()
@ -2810,6 +2826,9 @@ Main =
if conf['Indicate Cross-thread Quotes'] if conf['Indicate Cross-thread Quotes']
quoteDR.init() quoteDR.init()
if conf['Fix XXX\'d Post Numbers']
unxify.init()
if conf['Quick Reply'] and conf['Hide Original Post Form'] if conf['Quick Reply'] and conf['Hide Original Post Form']
Main.css += 'form[name=post] { display: none; }' Main.css += 'form[name=post] { display: none; }'