-2

I am trying to figure out how to refresh the page after the dom loads. If the dom loads and there is not a specific text on the page, it refreshes and keeps looping till that text is found.

// ==UserScript== // @name My Fancy New Userscript // @namespace http://use.i.E.your.homepage/ // @version 0.1 // @description enter something useful // @match http://stackoverflow.com/questions/8192126/clicking-a-button-on-a-page-using-a-greasemonkey-userscript-in-chrome/8192413#8192413 // @copyright 2012+, You // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js // ==/UserScript== function available() { var nodeList = document.querySelectorAll('.table'); if (nodeList[0].innerHTML.indexOf( "Not available." ) != -1) { Location.reload(); else { alert("Hello! I am an alert box!!"); } } } $(function() { available(); }); 
3
  • that sounds a bit dodgy, will it not just result in a never ending redirect loop? Commented May 23, 2014 at 18:50
  • not if the text is found, but what difference would it make, there is no guarantee that text will ever appear. Also, you should post examples of what you have tried. Commented May 23, 2014 at 19:07
  • Added my code so far. Tampermonkey is not letting me enable the script for some reason. Commented May 23, 2014 at 19:51

2 Answers 2

0

To reload the page with javascript:

Location.reload(); 

You'll need some way of checking for your bit of text as well. Without seeing your DOM structure I can't give an accurate answer to that aspect.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I added this to my script. My script won't enable for some reason.
0

Location must be lower case.

location.reload(); 


By the way, passing a true as a param means that the page will load from the server instead than loading from caché.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.