How do I put more than 1 script in a script? I am trying to do combind these scripts: This one: Code (Text): // ==UserScript== // @name Pwning Website // @namespace http://www.neofriends.net/ // @description script to alert "You are on a pwning website" on every page // @include http://www.neofriends.net/ // @exclude http://www.neofriends.net/* // ==/UserScript== alert('You are on a pwning website'); and this one: Code (Text): // ==UserScript== // @name Pwning Website // @namespace http://www.neofriends.net/ // @description script to alert that you are posting on neopets // @include http://www.neofriends.net/posting.php?* // @exclude http://www.neofriends.net/ // ==/UserScript== alert('You are about to post something'); Is there a command to combind more than one code set? Thanks, Fexxel
Code (Text): // ==UserScript== // @name Pwning Website // @namespace http://www.neofriends.net/ // @description two in one // @include http://www.neofriends.net/* // ==/UserScript== if (document.location.href == 'http://www.neofriends.net/'){ alert('You are on a pwning website'); } else if (document.location.href.match('posting.php?')){ alert('You are about to post something'); }
Could I do: Code (Text): // ==UserScript== // @name Pwning Website // @namespace http://www.neofriends.net/ // @description two in one // @include http://www.neofriends.net/* // ==/UserScript== if (document.location.href == 'http://www.neofriends.net/'){ alert('You are on a pwning website'); } else if (document.location.href.match('posting.php?')){ alert('You are about to post something'); } else if (document.location.href.match('downloads.php)){ alert('You are in the Downloads Section'); } ??? Thanks for the help guys
Test it yourself and see if it does what you want/expect it to do. Leaving it as Code (Text): match('downloads.php') means that it will give the alert on downloads.php as well as downloads.php?d=163
Alright, I tried it and it and it didn't work. Here's my updated code: Code (Text): // ==UserScript== // @name Pwning Website // @namespace http://www.neofriends.net/ // @description Testing this for neofriends.net // @include http://www.neofriends.net/* // ==/UserScript== if (document.location.href == 'http://www.neofriends.net/'){ alert('You are on a pwning website. It might be too pwnful for you. Are you sure you want to continue?'); } else if (document.location.href == 'http://www.neofriends.net/posting.php?')){ alert('You are about to post something. You might get flamed.'); } else if (document.location.href == 'http://www.neofriends.net/downloads.php')){ alert('You are in the Downloads Section') Just wondering what's wrong with it. According to US.org all my text is wrong. The whole thing is red. I don't completely understand the match thing. Remember that this is my first day with GM xD
You can use error console to find errors. (tools > error console) You had an error the first time. you had match('downloads.php) it should've been match('downloads.php') In your updated code you need to close out the last if statement. Add } to the end of the script. match returns true if it finds what's between the parenthesis () in the string. In my example you were trying to find 'downloads.php' in the window's URL
Ahah! Well, no, I don't have an error console. Is there an application I should be using because I'm typing up the scripts manually on userscripts.org xD Oh, and should I be using match('xxx') or is the href == thing fine?
you can use == if you want it to only alert on a single page. The alert you have for posting might not ever fire because there's no time that you'll post a message and the URL will be 'http://www.neofriends.net/posting.php' exactly. You can edit scripts without using userscripts.org. Right click on the greasemonkey head on the status bar then right click on the script to edit it. If nothing happenes then you need to setup you default editor at about:config search for greasemonkey.editor and change the value to your favorite editor. try : C:\Windows\notepad.exe You can also edit your scripts by right clicking the head and then click manage your scripts. Highlight your script and click edit.
I'm on Mac OS X. :-/ I'd prefer to program in Mac OS X, it doesn't crash as frequently as Vista. So is this valid: Code (Text): // ==UserScript== // @name Pwning Website // @namespace http://www.neofriends.net/ // @description Testing this for neofriends.net // @include http://www.neofriends.net/* // ==/UserScript== if (document.location.href == 'http://www.neofriends.net/'){ alert('You are on a pwning website. It might be too pwnful for you. Are you sure you want to continue?'); } else if (document.location.href.match('http://www.neofriends.net/posting.php?')){ alert('You are about to post something. You might get flamed.'); } else if (document.location.href.match('http://www.neofriends.net/downloads.php')){ alert('You are in the Downloads Section') } And how do I get the last } to be exactly aligned with the other "}"'s? So when I do match it's the same as http://www.xxxxx.com/posting.php?* ?