CelticWhisper Posted February 12, 2008 Share Posted February 12, 2008 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 More sharing options...
CelticWhisper Posted February 12, 2008 Author Share Posted February 12, 2008 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 More sharing options...
noroom Posted February 12, 2008 Share Posted February 12, 2008 Since Greasemonkey scripts are open, look for one that does something simple and look at the source. Link to comment Share on other sites More sharing options...
The_Decryptor Veteran Posted February 12, 2008 Veteran Share Posted February 12, 2008 (edited) 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 February 12, 2008 by The_Decryptor Link to comment Share on other sites More sharing options...
CelticWhisper Posted February 13, 2008 Author Share Posted February 13, 2008 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 More sharing options...
Recommended Posts