Good Day
I have never really used the browser console before, so I don't really know what it is capable of doing - What I want to achieve is the following:
How do I force/initiate an automatic refresh on a page from the browser console? That is, instead of having to press F5 everytime?
Also, does the console take jquery? Or does it depend on whether the web page you are on uses jquery or not?
Thank you!
First, load the page you want to refresh. To run the auto-refresh tab script in the DevTools console, you first need to open the console. On Windows, press the Shift, Ctrl, and I keys. On macOS, press Option, Command, and J.
Google Chrome (version 57.0.Select Extensions and click Get more extensions at the bottom of the page. Search for the Auto Reload Page Extension and click Add to Chrome. On the pop-up notification, click Add Extension. The Auto Reload Page Extension icon should now appear on the right side of the address bar.
Whenever you are working chrome, try this: Press F12 and open the developer tools. On the refresh button, on the top left of the browser window, do a right click.
Use a browser tab "A" to open and control another browser tab "B". This allows you to continuously auto-reload a Web page in tab "B" that otherwise you have no control over. Your reload command from tab "A" will not be wiped out when tab "B" is reloaded.
I use this to refresh a Website so that it does not time out and log me out. This approach does not require jQuery, and does not require you to have any control over the target Web page HTML code.
Open a browser new tab "A", press F12, select Console. Type in something like this:
win1 = window.open("https://www.example.com");
timer1 = setInterval(function(){win1.location.href="https://www.example.com"},10*60*1000);
The "win1" is to assign a Javascript variable name to the new browser tab "B", so that you can have Javascript control over it. The "timer1" is also to assign a variable name for good practice and for later control. The setInterVal function runs an anonymous function to call "win1" or tab "B" to refresh it's "location.href", every 10 minutes.
You'll probably have to keep both tabs open. "Pin" them for easy access. Close both tabs to stop the auto-reload. Hard refresh of tab "A" may also stop the auto reload. You might also be able to use the variable "timer1" to cancel the auto reload.
You can refresh a page from within the browser console by running the following command:
location.reload()
If the website you are on has jQuery loaded you will be able to run jQuery commands.
If the website does not have jQuery loaded you can use the following bookmark to inject jQuery into the page:
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){(function(){var d=document.createElement("div"),c=document.getElementsByTagName("body")[0],e=false,g="";d.style.position="fixed";d.style.height="32px";d.style.width="220px";d.style.marginLeft="-110px";d.style.top="0";d.style.left="50%";d.style.padding="5px 10px";d.style.zIndex=1001;d.style.fontSize="12px";d.style.color="#222";d.style.backgroundColor="#f99";if(typeof jQuery!="undefined"){g="This page already using jQuery v"+jQuery.fn.jquery;return f()}else{if(typeof $=="function"){e=true}}function a(i,k){var h=document.createElement("script");h.src=i;var j=document.getElementsByTagName("head")[0],b=false;h.onload=h.onreadystatechange=function(){if(!b&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){b=true;k();h.onload=h.onreadystatechange=null;j.removeChild(h)}};j.appendChild(h)}a("http://code.jquery.com/jquery.min.js",function(){if(typeof jQuery=="undefined"){g="Sorry, but jQuery wasn't able to load"}else{g="This page is now jQuerified with v"+jQuery.fn.jquery;if(e){g+=" and noConflict(). Use $jq(), not $()."}}return f()});function f(){d.innerHTML=g;c.appendChild(d);window.setTimeout(function(){if(typeof jQuery=="undefined"){c.removeChild(d)}else{jQuery(d).fadeOut("slow",function(){jQuery(this).remove()});if(e){$jq=jQuery.noConflict()}}},2500)}})();});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With