Eliminate extra exclamation points!!!

I’m not militant about punctuation but i do find it annoying when people write things with lots of exclamation points. So i created a Greasemonkey script that turns anything more than two exclamation points into just one. Greasemonkey has to be installed and you need to be using Firefox in order for this to work. If you have them both already then grab my excessive exclamation points script. There is some excessive punctuation below for you to test. After you have installed the script just refresh this page and you should see the exclamation points disappear from this post’s title and the lines below.

Two exclamation points!!
Ten exclamation points!!!!!!!!!!
Five exclamation points and a number one!!!!!1
Forty Two!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I’ve also uploaded the script to userscripts.org here.

(Thank you for all the code suggestion and corrections!)

30 thoughts on “Eliminate extra exclamation points!!!”

  1. Nice script,
    but why not use RegExp the way they’re meant.
    If you use “!+” as a pattern it will replace strings of !’s of any length >0. Even greater than 42. :)

  2. Ergh, it ate my post. :(

    Regarding this line: for (var i = 0; i %lt; textnodes.snapshotLength; i++)

    I’d be a liar if I said I knew what snapshotLength does. I can’t help but think, though, that assigning textnodes.snapshotLength to a variable before hitting the loop would be faster than having to compute textnodes.snapshotLength every time. Especially on pages with lots of text nodes.

  3. // ==UserScript==
    // @name Eliminate excessive exclamation points
    // @namespace http://www.zieak.com
    // @description Turns exclamation points into just one
    // @include *
    // ==/UserScript==

    (function() {
    var regex, textnodes, node, length;
    textnodes = document.evaluate( “//body//text()”, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    length = textnodes.snapshotLength;
    regex = new RegExp(‘![!1]+’, ‘g’);
    for (var i = 0; i

  4. Are you serious?

    (function(){
    for (var nodes = document.selectNodes(‘//body//text()[contains(.,"!!")]‘), i = 0, node; node = nodes[i]; i++)
    node.data = node.data.replace(/!!+/g, ‘!’);
    })()

    Not sure if Firefox supports selectNodes

  5. This blog post was linked on Lifehacker, and there were alot of comments there “challenging” what it couldn’t do. I took a few minutes to add a few patterns to deal with those cases as well.

    Here, enjoy some more regexes (drop these into the script in place of the existing portion)

    This should cover ??????, !?!?!?!?!, and !!!11!!!!!11!!1!1

    http://www.doorknobsoft.com/codetests/exclam_regex.txt

  6. My coding knowledge is virtually nil, or I’d take a stab at this myself, so here’s a suggestion.

    Is there any way to make the replacement exclamation mark colored? Maybe a dark red so it’s noticeable without being blatant?

  7. I live in a town called Palisades Park, New Jersey. A printed sheet of little payment-reminder stickers contains this heading: “Stickers!!!!!!”
    When I asked the tax collector why so many exclamation marks, he replice “So people will notice.” Not wanting to get on the bad side of the tax collector, I kept quiet. But had to ask myself, What if something were really and truly urgent, life and death, how many exclamation marks would that require?

  8. In the town I live, Palisades Park, New Jersey in USA, the tax bill encloses little gummed reminder stickers. The heading on the paper proclaims: “Stickers!!!!”

    Am wondering how many exclamation marks would be required for announcement of an impending tornado or earthquake.

Leave a Reply