Please help!
I am making a simple Greasemonkey Script.
Right now it does the following: (pseudocode)
if {number of links on page > 0
then {display: there are more links
else { display: there are no links!
Can I add to this a script that does the following?
if {page contains word "apple"
do the following
-load www.domain.com/url1
-then wait 10 seconds
-load www.domain.com/url2
else {do nothing
if(document.getElementsByTagName('a').length > NUMBER_HERE ){
// how do you want to display your message?
}else{
// because that changes what to write here.
}
You will have to explain what you mean by wait 10 seconds, javascript is reloaded when the page changes, so anything you attempt on the first page would be lost by the second page...
If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
The same applies to HTML and the forums [HTML][/HTML] tags.
Yep, I've already got the first part down; the part number of links and displaying messages. Got that. I'm talking about:
If the current page has the word "apple" on it, go to URL1, wait a little bit, and then Go to URL2.
Also, the javascript is running in greasemonkey, in the browser. Won't it consistently monitor the page and carry out functions over a multi-page action? If it was server-side I would understand that it couldn't, but it's not.
To clarify, I want it to recognize if there is the word "apple" in the page content. If there is, I want to load domain.com/url1, and then load domain.com/url2.
Incidentally, URL1 is the logout link, and URL2 is the original page.
Also, the javascript is running in greasemonkey, in the browser. Won't it consistently monitor the page and carry out functions over a multi-page action? If it was server-side I would understand that it couldn't, but it's not.
To clarify, I want it to recognize if there is the word "apple" in the page content. If there is, I want to load domain.com/url1, and then load domain.com/url2.
Incidentally, URL1 is the logout link, and URL2 is the original page.
Unfortunately it doesn't work like that, greasemonkey scripts are run after any onload functions for the page, and that's it, anything else you want the code to do has to be done from within the greasemonkey scripts.
You could do something like:
Bookmarks