Author

Topic: User Script: Automatically remove nested quotes v1.1.1 (Read 654 times)

sr. member
Activity: 378
Merit: 335
https://t.me/CRYPTOVlKING
I was searching for the famous ~snip~ as I saw other people use it and managed to find your thread and script. So I made a mini guide on Croatian section on how to install and use it, based on your topic, to help people like me who are frustrated on mobile devices and don't have an idea that ~snip~ exists in automated form.

What surprised me was the amount of people that are long term members and had same frustrations like I did with deleting obsolete quotes of quotes manually and didn't even know about the existence of this script.

So firstly thanks to all who helped making this script and secondly I have a suggestion based on my recent experience and findings.

Why not put this topic in Beginners section to help new members from the get go and maybe stick it. If I didn't dig through forum I would still be a frustrated young forum member Cheesy
legendary
Activity: 1876
Merit: 1475
This wasn't a huge job, so I went though and changed it.
Thanks! I've checked and tested your code and updated the OP and the script on openuserjs.org.
legendary
Activity: 2352
Merit: 1267
In Memory of Zepher
I would recommend getting rid of jQuery though. You're already using querySelector in one spot so you can replace the jQuery stuff with plain DOM calls I think.
This wasn't a huge job, so I went though and changed it.

Thanks for the script EcuaMobi, it's fantastic.
legendary
Activity: 1876
Merit: 1475
I would recommend getting rid of jQuery though. You're already using querySelector in one spot so you can replace the jQuery stuff with plain DOM calls I think.
Thanks. I'll check that when I have some time
legendary
Activity: 3654
Merit: 8909
https://bpip.org
I'd appreciate if someone can audit the code

FWIW I have reviewed the code and it appears to be safe - doesn't attempt to send your PMs anywhere, or steal your netflix account, or flirt with your spouse.

I would recommend getting rid of jQuery though. You're already using querySelector in one spot so you can replace the jQuery stuff with plain DOM calls I think.
legendary
Activity: 1876
Merit: 1475
I've realized this script didn't work when quoting from 'Show the last posts of this person' or when quoting a PM.
The script has been updated to version 1.1 to fix this.

If you prefer not to use it on personal messages, just remove this line:
Code:
// @include     https://bitcointalk.org/index.php?action=pm;sa=send;f=inbox;pmsg=*;quote;u=*
(However it's completely safe as of course everything happens on your own browser. I'd appreciate if someone can audit the code)
hero member
Activity: 2366
Merit: 838
If you have an Android device, you can use usi (User|Unified Script Injector) or Tampermonkey and it will *probably* work. The former has better compatibility.
Thanks for your guided steps, I might try them later just for curious, because I would prefer to do most of things on computers or laptops, not on mobile devices. I asked this for lazy guys whom usually pyramid-quoting, and blame on their mobile devices.
By the way, due to the topic title, I would like to raise a minor discussion on the term: pyramid quote or nested quote, which one should officially used?
I know that they have nearly same implications, but global moderator officially mentioned the type of posting style as pyramid quote, I think we should use only one term here to mention about it: Pyramid quotes.
Any ideas?
1. No zero or low value, pointless or uninteresting posts or threads. [1][e]

~snip~

1. Such posts as "SELL SELL SELL", "I agree", "+1", "Support", "Watching", "Interesting", "LOL", "SCAM", "LEGIT", "FAKE", other one word posts, posts consisting mostly of swearing, quote pyramids, useless introduction threads, threads about a topic already recently discussed in several other threads.
legendary
Activity: 1876
Merit: 1475
If you have an Android device, you can use usi (User|Unified Script Injector) or Tampermonkey and it will *probably* work. The former has better compatibility.
I tested this script with Tampermonkey for Android (https://play.google.com/store/apps/details?id=net.biniok.tampermonkey) and it definitely works. However it's not really a very good browser, at least on Android 9.
I'm checking the other one.

Update:
Firefox for Android along with User|Unified Script Injector worked great! And that one is definitely a very good browser. Here's a gif demo.
I'm updating OP to suggest this for Android.



By the way, due to the topic title, I would like to raise a minor discussion on the term: pyramid quote or nested quote, which one should officially used?
I know that they have nearly same implications, but global moderator officially mentioned the type of posting style as pyramid quote, I think we should use only one term here to mention about it: Pyramid quotes.
Any ideas?
I thought nested quotes was the generic name, while pyramid quotes was used only when several (5+ or so) quotes are nested so the whole thing looks like a pyramid seen from above.
legendary
Activity: 2772
Merit: 3282
Excellent script. I added the topic in my guide for interests of users who don't want to do pyramid quotes. [TIPS] to avoid pyramid quotes (for Newbies). One question, can I use the script on mobile devices? If yes, how to use it? Most of time, when I am on mobile devices, I don't want to spend my time to delete unused parts inside quote blocks, but I usually come back later (when I am on computers or laptops) to edit such pyramid quotes. However, I doubt that other users often spend their time to do it.

If you have an Android device, you can use usi (User|Unified Script Injector) or Tampermonkey and it will *probably* work. The former has better compatibility.
hero member
Activity: 2366
Merit: 838
Excellent script. I added the topic in my guide for interests of users who don't want to do pyramid quotes. [TIPS] to avoid pyramid quotes (for Newbies). One question, can I use the script on mobile devices? If yes, how to use it? Most of time, when I am on mobile devices, I don't want to spend my time to delete unused parts inside quote blocks, but I usually come back later (when I am on computers or laptops) to edit such pyramid quotes. However, I doubt that other users often spend their time to do it.
legendary
Activity: 1876
Merit: 1475
I introduce the "Quote plus" user script.

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
Code:
// ==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]
    Jump to: