Feature request: greentext



  • >be me
    >post some greentext-like story
    >backspace every line because it's programmers' forum
    >click "post"
    >see it looks exactly like what you wanted
    >it's all in black, like every other text on the site
    >realize it doesn't have to be
    >make another pointless feature request thread because threads are free
    >add random political bullshit at the end just to annoy people

    MAGA



  • I tried it once on here. He went into meltdown.



  • @pjh by "he", do you mean undefined?


  • Discourse touched me in a no-no place

    @gąska I had to look up "greentext". undefined



  • @gąska said in Feature request: greentext:

    >be me
    >post some greentext-like story
    >backspace every line because it's programmers' forum
    >click "post"
    >see it looks exactly like what you wanted
    >it's all in black, like every other text on the site
    >realize it doesn't have to be
    >make another pointless feature request thread because threads are free
    >add random political bullshit at the end just to annoy people

    MAGABurma-Shave!


  • Impossible Mission Players - A

    @gąska
    >This is open source
    >You can make all the requests you want
    >But if you want them implemented
    >You have to BUILD them yourself

    Filed under: A joke probably only BLUBAR and his GW2 guild will get



  • @izzion said in Feature request: greentext:

    @gąska
    >This is open source
    >You can make all the requests you want
    >But if you want them implemented
    >You have to BUILD them yourself

    Filed under: A joke probably only BLUBAR and his GW2 guild will get

    I haven't actually done much dungeoning after I finished each explorable path once. And doing explorable paths in PUGs tends to mean skipping all the story.

    Edit: Also, I think you meant to link here: https://wiki.guildwars2.com/wiki/Ascalonian_Catacombs_(explorable)#Detha.27s_route



  • @ben_lubar said in Feature request: greentext:

    doing explorable paths in PUGs

    0_1514385897632_8c4ed9e5-cfcb-45c0-9593-688abc7eec21-images.jpg ⁉



  • @zecc said in Feature request: greentext:

    @ben_lubar said in Feature request: greentext:

    doing explorable paths in PUGs

    0_1514385897632_8c4ed9e5-cfcb-45c0-9593-688abc7eec21-images.jpg ⁉

    pick-up group

    Basically, any group of players that gets together one time to play a specific piece of content and then disbands.



  • I'm trying to decide which would be more appropriate: making > lines greentext, or making lines in <blockquote> greentext instead of blockquoting (and making them start with >), or both.

    Either way, it would be totally doable in userscript land...


  • Impossible Mission Players - A

    @ben_lubar
    I had the link delivered exactly where I meant to.



  • Script to make > lines greentext:

    (posting it in new post below*, as now it does blockquotes also)

    edit: Fixed to

    >handle this correctly, including the sub-elements
    but not this, because it's on a new line
    >and handle this
    >and this

    but not this, because it's a block element
    or this, because it's after the block element

    re-process posts after they're streamed in / edited? maybe?
    > yes and in the composer preview also

    Any more edge cases that I forgot about, I wonder? (Probably...)

    *once it's ready



  • I like green text like this.



  • @anotherusername said in Feature request: greentext:

    @pjh by "he", do you mean undefined?

    No. One of our other denizens who regularly goes into green-ink mode.

    "Abuse of power" was mentioned shortly after, since -being unaware of the concept anyway - the irony was forever lost on him.

    Still is, I believe.

    Backstory, for those not following along: as a joke, I changed the site CSS to make a particular user's text green in all his posts, after a series of egregiously whiney posts.

    Reader, it did not go down well.



  • @pjh I wasn't familiar with that backstory...



  • @anotherusername, it's still around here somewhere, probably in lounge. CBA to look it up ATM. I appear to be still non-sober, and my phone's battery is complaining about my using it.



  • @gąska said in Feature request: greentext:

    >make another pointless featurecode request thread because threads are free
    >add random political bullshit at the end just to annoy people

    MAGA

    @gąska why are you describing Gavino's posting habits?



  • @pjh said in Feature request: greentext:

    @anotherusername, it's still around here somewhere, probably in lounge. CBA to look it up ATM. I appear to be still non-sober, and my phone's battery is complaining about my using it.

    Nope, plain old Meta:

    https://what.thedailywtf.com/post/521412



  • Ok, new and improved greentext script:

    (function () {
      document.head.appendChild(document.createElement('style')).innerHTML = '.greentext{color:#789922}.greentext-block{display:inline-block!important;vertical-align:middle!important}';
      function process(s) {
        [].slice.call(document.querySelectorAll(s)).forEach(function (p) {
          /* replace blockquote elements with angle-bracket style quotes */
          p.normalize();
          [].slice.call(p.querySelectorAll('blockquote:not([class])')).reverse().forEach(function (q) {
            var e = document.createElement('p');
            q.replaceWith(e);
            
            [].slice.call(q.childNodes).forEach(function (c) {
              if (c.nodeType != c.ELEMENT_NODE || !c.classList.contains('toggle')) {
                e.appendChild(c);
              }
            });
            
            var n = 1;
            [].slice.call(e.childNodes).forEach(function recur(c) {
              if (c.nodeType == c.ELEMENT_NODE && window.getComputedStyle(c).display == 'block') {
                if (/iframely/.test(c.className)) {
                  var g = c.previousSibling;
                  if (!g || g.nodeType != g.ELEMENT_NODE || !g.classList.contains('greentext')) {
                    g = c.parentElement.insertBefore(document.createElement('span'), c);
                    g.classList.add('greentext');
                  }
                  g.appendChild(document.createTextNode('> '));
                  g.appendChild(c);
                  c.classList.add('greentext-block');
                  g.appendChild(document.createElement('br'));
                  n = 1;
                  
                } else {
                  var p = 0, pre = window.getComputedStyle(c).whiteSpace == 'pre';
                  if (c.tagName == 'P') {
                    p = n = 1;
                    var d = document.createElement('div');
                    [].slice.call(c.childNodes).forEach(function (j) {
                      d.appendChild(j);
                    });
                    if (!pre) {
                      while (d.firstChild && d.firstChild.nodeType == d.TEXT_NODE && !/\S/.test(d.firstChild.data)) d.firstChild.remove();
                      while (d.lastChild && d.lastChild.nodeType == d.TEXT_NODE && !/\S/.test(d.lastChild.data)) d.lastChild.remove();
                    }
                    c.replaceWith(d);
                    c = d;
                  }
                  
                  [].slice.call(c.childNodes).forEach(recur);
                }
                
                while (!pre && c.nextSibling && c.nextSibling.nodeType == c.TEXT_NODE && !/\S/.test(c.nextSibling.data)) {
                  c.nextSibling.remove();
                }
                
                if (p && c.nextSibling) {
                  if (!n) c.appendChild(document.createElement('br'));
                  c.appendChild(document.createTextNode('> '));
                }
                n = 1;
                
              } else if (c.nodeType != c.TEXT_NODE || c.previousSibling || /\S/.test(c.data)) {
                if (n) {
                  if (c.nodeType == c.TEXT_NODE) {
                    c.data = '> ' + c.data.replace(/^\s+/, '');
                  } else if (c.nodeType != c.ELEMENT_NODE || c.tagName != 'BR') {
                    c.parentNode.insertBefore(document.createTextNode('> '), c);
                  }
                }
                n = c.nodeType == c.ELEMENT_NODE && (window.getComputedStyle(c).display == 'block' || c.tagName == 'BR');
              }
            });
          });
          /* end replace blockquotes with angle-bracket quotes */
          
          p.normalize();
          (function processChildNodes(e, n) {
            if (e.nodeType == e.ELEMENT_NODE && (e.tagName == 'BR' || window.getComputedStyle(e).display == 'block')) n = 1;
            if (e.childNodes && e.childNodes.length) {
              [].slice.call(e.childNodes).forEach(function (c) {
                if (!n) {
                  var q = c.previousSibling;
                  if (q && q.nodeType == q.ELEMENT_NODE && q.classList.contains('greentext')) {
                    if (c.nodeType != c.ELEMENT_NODE || window.getComputedStyle(c).display != 'block') {
                      q.appendChild(c);
                    }
                  }
                }
                n = processChildNodes(c, n);
              });
            } else if (n) {
              if (e.nodeType == e.TEXT_NODE && /\S/.test(e.data)) {
                n = 0;
                if (/^\s*>/.test(e.data) && !e.parentElement.classList.contains('greentext')) {
                  var g = document.createElement('span');
                  g.classList.add('greentext');
                  e.replaceWith(g);
                  g.appendChild(e);
                }
              } else if (e.nodeType == e.ELEMENT_NODE && e.tagName != 'BR' && window.getComputedStyle(e).display != 'block') {
                n = 0;
              }
            }
            if (e.nodeType == e.ELEMENT_NODE && (e.tagName == 'BR' || window.getComputedStyle(e).display == 'block')) n = 1;
            return n;
          })(p, 1);
        });
      };
      $(window).on('action:topic.loaded', function () { process('[component="post/content"]'); });
      $(window).on('action:posts.loaded', function () { process('[component="post/content"]'); });
      $(window).on('action:posts.edited', function () { process('[component="post/content"]'); });
      $(window).on('action:composer.preview', function () { process('.composer .preview-container>.preview'); });
      process('[component="post/content"],.composer .preview-container>.preview');
    })();
    

    If you don't want it to convert blockquotes into > quotes, find these two comment lines, and either comment out or delete all of the lines of code in-between them:

          /* replace blockquote elements with angle-bracket style quotes */
    
          /* end replace blockquotes with angle-bracket quotes */
    


  • @anotherusername and here's the results:

    0_1514406509859_6c667505-e31b-435d-b569-fd1da4ea85d5-image.png

    0_1514406519523_7dec8030-e44e-4279-abd2-3f52f00d45db-image.png

    0_1514406527470_e32fbdf2-eb5e-4589-a2eb-bd2d460c38f5-image.png

    Without the blockquote-replacing code, the second one looks like:

    0_1514406703435_f2f5ea7c-330d-480f-a9fa-f54985a00f65-image.png


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.