Slashdot RndSig

By deleted user Last update Jun 19, 2005 — Installed 446 times.
// Slashdot Random Sig
//
// With Slashdot's built in signature system, signatures are limited to 120 characters, but
// this appends to comment, so is technically unlimited and will apply to post length.  
// Requires posts to be in 'Plain Old Text' or 'HTML Formatted' and it is suggested that you 
// turn off Slashdot signatures.
//
// Yes this could be easily modified for other sites
//
// 2005/4/24 - original release
// 2005/4/30 - addressed array length bug and usability pointed out by ~Bob/Paul~
// 2005/6/28 - Fixed double-sig bug, added more specific instructions -- Anthony
//
// Brought to you by snop.com
//
// ==UserScript==
// @name          Slashdot RndSig
// @namespace     http://www.snop.com
// @description	  Appends a random signature when posting a comment on Slashdot. You need to edit the script to put in your own signatures!
// @include       http://*.slashdot.org/comments.pl*
// @include       http://slashdot.org/comments.pl*
// ==/UserScript==

(
	function() 
	{
		// TO ADD SIGNATURES: Just change the values of these or add new lines.
		// Remember, the last line SHOULD NOT have a comma on the end. If you want
		// to place a " mark, type \" instead. Use HTML formatting if you want.
		var mySig = new Array
		(
			"Add your signatures here!", 
			"When you want to type a double-quote use \" instead",
			"You can use <i>any</i> kind of HTML formatting that Slashdot accepts.",
			"You can also create new lines here if you want",
			"but make sure that the last line",
			"HAS NO COMMA!"
		);

		var credits = "<br>Generated by <a href='http://www.snop.com/downloads/SlashdotRndSig.user.js'>SlashdotRndSig</a> via <a href='http://greasemonkey.mozdev.org/'>GreaseMonkey</a>";

		function AddSig(e)
		{
			// Get the comment field
			var comment = document.getElementsByName('postercomment');
			
			// Some people actually use the "Preview" button (!) so we need to make sure we're not adding two sigs
			if(comment.item(0).value.lastIndexOf(credits) == -1)
				// Pick a sig, and then give credit where credit is due.
				comment.item(0).value = comment.item(0).value + "<br>---<br>" + mySig[Math.round(Math.random()*(mySig.length-1))] + credits;
		}

		window.addEventListener('submit', function(e) {  AddSig(e); }, false);

	}
)();