Greasemonkey n00b needs heeeeeeeelp!


Recommended Posts

I'm trying to configure a greasemonkey script to fill in Neowin's "username search" field with my own username, but I'm having a significant degree of trouble making it work.

The script I currently have is:

// ==UserScript==// 
@name           NeoSearch//
@namespace 	*neowin*//
@description    Fills in Username Search field//
@include        [url="https://www.neowin.net/forum/index.php?act=Search//"]https://www.neowin.net/forum/index.php?act=Search//[/url] 

<script language="JavaScript">
<!--
function populateField{
this.sForm.namesearch.value="CelticWhisper";
}
//-->
</script>
==/UserScript==

Can someone clue me in on what I'm missing or doing wrong? I've never written a Greasemonkey script before and while I've done some Javascript for pages that I've built entirely myself, I don't know how to incorporate one into a preexisting page.

Thanks for any help you can give me.

Link to comment
Share on other sites

Still no luck after tweaking the code a bit.

New code looks like:

// ==UserScript==// 
//@name           NeoSearch
//@namespace 	  *neowin*
//@description    Fills in Username Search field
//@include        [url="https://www.neowin.net/forum/index.php?act=Search"]https://www.neowin.net/forum/index.php?act=Search[/url]

<script language="JavaScript">
<!--
function populateField(){
this.sForm.namesearch.value="CelticWhisper";
}
//-->


</script>
populateField();

// ==/UserScript==//

Link to comment
Share on other sites

Geasemonkey scripts are scripts, not html pages.

And it's probably not a good idea to rely on IE style scripting, I'd use the proper DOM methods.

Edit: Here you go.

// ==UserScript==
// @name NeoSearch
// @namespace *neowin*
// @description Fills in Username Search field
// @include https://www.neowin.net/forum/index.php?act=Search
// ==/UserScript==

(function()
{

var elem = document.getElementById("entered_name");
elem.value = "CelticWhisper";

})();

Edited by The_Decryptor
Link to comment
Share on other sites

Thanks, guys. Got it working with your suggestions and a little help from a guide I nabbed over my lunch hour.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.