I always have to manually edit my post when quoting someone else and getting several nested quotes like this:
This has also been recently discussed
here.
So I've written a small user script that removes all the extra quotes, leaving only the latest one:
It also shows 3 links to use the whole text, only the latest quote (default), or just a "~snip~":
Here's what the snip button does:
Important: You should use these 3 buttons
before making any editions. You may lose your work otherwise.
To install this userscript you need to:
Here you can see the source code:
https://openuserjs.org/scripts/EcuaMobi/Quote_plus/source// ==UserScript==
// @name Quote plus
// @namespace ecuamobi
// @author EcuaMobi
// @include https://bitcointalk.org/index.php?action=post;*quote=*
// @include https://bitcointalk.org/index.php?action=pm;sa=send;f=inbox;pmsg=*;quote;u=*
// @version 1.1.1
// @license MIT
// @grant none
// ==/UserScript==
(() => {
var full_text = document.forms.postmodify.message.value;
var regex = /\[quote author/gi,
result, indices = [];
// Find second [quote]
var i = 0;
var start2 = 0;
var end2 = 0;
while ((result = regex.exec(full_text))) {
i++;
if (2 == i) {
start2 = result.index;
break;
}
}
regex = /\[\/quote\]/gi, result, indices = [];
var last = 0;
while ((result = regex.exec(full_text))) {
if (last > 0) {
end2 = last + 8;
}
last = result.index;
}
// Are there several quotes?
if (start2 == 0 || end2 == 0) {
// Abort
return;
}
// Get text to use for every option
var latest_quote = full_text.substr(0, start2).trim() + '\n' + full_text.substr(end2).trim() + '\n';
var snip_quote = full_text.substr(0, start2).trim() + '~snip~[/quote]\n';
full_text = full_text.trim() + '\n';
// By default use the latest quote. REPLACE THIS BY snip_quote OR REMOVE IF DESIRED
document.forms.postmodify.message.value = latest_quote;
// Add buttons to manually use full text, latest quote or snip
const $links = "
Full text | Latest quote | ~snip~"
document.querySelector("textarea").insertAdjacentHTML('afterend', $links);
document.querySelector('#full_text').addEventListener('click', function(e){
e.preventDefault();
document.forms.postmodify.message.value = full_text;
});
document.querySelector('#latest_quote').addEventListener('click', function(e){
e.preventDefault();
document.forms.postmodify.message.value = latest_quote;
});
document.querySelector('#snip_quote').addEventListener('click', function(e){
e.preventDefault();
document.forms.postmodify.message.value = snip_quote;
});
})();
Demo:
Capture taken on Android. It works the same on PC/Mac/Laptop.
Notes and limitations:
- It will not run if there are no quotes inside your quote (no nested quotes)
- It only considers regular quotes ([ quote author=username link=...), not other simple quotes
- It may behave strangely if the nested quote is not at the beginning or if there are several quotes mixed with inline responses. I'm still testing these scenarios
- You should always check whether the script did a good job and click "Full text" otherwise
Version history:
- 1.1.1
By minifrij. jQuery has been removed
- 1.1
It now works when quoting from 'Show the last posts of this person.' or a PM (more info) - 1.0:
Initial release
I'll keep testing and improving it. Let me know your comments or any bugs you find.[/list]