Clipmarks
   
  
   
Godfrey Danielfollowshare
1-20-2007 4:20 PM884 views
I'm going to try to edit this script to include other excessive punctuation. Can't figure why the author would write this and leave out question marks.
14 Comments   | Add a Comment
1-20-2007 5:09 PM
kankamuso
Done, Godfrey:

// Based on a script in Mark Pilgram's upcoming "Dive into Greasemonkey", as well as "renamer"

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

// Why 42? We should ask Earth before it is too late.


(function() {
var replacements, regex, key, textnodes, node, s;

replacements = {
"!{2,}": "!",
"\\?{2,}": "?",
"\\.{4,}": "...",
};

regex = {};
for (key in replacements) {
regex[key] = new RegExp(key, 'g');
}

textnodes = document.evaluate( "//body//text()", document, null, XPath...
1-20-2007 5:19 PM
kankamuso
A better version:

replacements = {
"!+": "!",
"\\?+": "?",
"\\?(?:\\?|!)+": "?",
"!(?:\\?|!)+": "!",
"![!1]+": "!",
"\\.{4,}": "...",
};
1-20-2007 5:24 PM
Godfrey Daniel
Yeah, thanks, I just did it myself, but I like your second version better.
1-20-2007 5:29 PM
Godfrey Daniel
Unfortunately doesn't appear to be working here at The Clip.
1-20-2007 6:37 PM
Godfrey Daniel
My mistake. I had an error in the code.
1-20-2007 6:50 PM
bignosemousie
Nice.
1-20-2007 6:53 PM
Godfrey Daniel
Hey Kankamuso, how about writing one for smileys?
1-20-2007 6:55 PM
Godfrey Daniel
I can tweak and edit with some success, but have never written one from scratch.
1-20-2007 7:20 PM
ghiberti
I can tweak and edit with some success, but have never written one from scratch.
Mr Daniel, regular expressions or javascript?
1-20-2007 7:54 PM
wurdzgurl
I'm definitely at fault of this one.
1-21-2007 9:11 AM
kankamuso
What do you exactly mean with the smileys, Godfrey? Wipe them out completely?
1-21-2007 3:59 PM
Godfrey Daniel
Completely
1-21-2007 4:00 PM
Godfrey Daniel
BTW, if you could point me to a quick and slick tutorial on how to write these things, I would appreciate it.
2-3-2007 2:45 PM
haraya
Hey Godfrey, is that crazy ostrich chick still after you? You've been gone for days.

This is great! And thanks to Kankamuso for the code.
Login to Comment.  Not a member yet? Sign up





Embed This Clip In Your Site...


OK