![]() ![]() |
Salon Technology
• after the refresh the url changes to
This test code...
GM_log(unsafeWindow.refresh_time); unsafeWindow.refresh_time = 1000; GM_log(unsafeWindow.refresh_time); ...outputs... 300000
...but the tab doesn't refresh in a second - it still takes 5 minutes to refresh. source code:
<script type="text/javascript" language="javascript">
<!--
var urlReg = /^((\w+):\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(location.href);
var host = urlReg[6];
var path = urlReg[8];
var refresh_url = 'http://' + host + path + '?source=refresh';
var refresh_time = 300000;
function salonRefresh() {
document.location.href = refresh_url;
}
var refreshTimeout = setTimeout('salonRefresh()', refresh_time);
//-->
</script>
|
![]() ![]() |
because a timeout was already set for that refresh time. try this
unsafeWindow.refreshTimeout = unsafeWindow.setTimeout('salonRefresh()', 1000);
also i dont see why u cant just do this window.setTimeout(unsafeWindow.salonRefresh, 1000); |
![]() ![]() |
I made a local file for testing:
<head><script type="text/javascript" language="javascript">
<!--
var refresh_time = 1000;
function salonRefresh() {
location.href = location.href
}
var refreshTimeout = setTimeout('salonRefresh()', refresh_time);
//-->
</script></head>
<body>I refresh therefore I exist.</body>
code tests unsafeWindow.refreshTimeout = unsafeWindow.setTimeout('salonRefresh()', 1000000);
Result - a refresh every second window.setTimeout(unsafeWindow.salonRefresh, 1000000); Result - a refresh every second |
![]() ![]() |
well u will also have to clear their timeout first then set yours |
![]() ![]() |
>> clear their timeout I have no idea how to do that. |
![]() ![]() |
for(let i=999; i>=0; i--) unsafeWindow.clearTimeout(i); |
![]() ![]() |
for(let i=999; i>=0; i--) unsafeWindow.clearTimeout(i);
unsafeWindow.refreshTimeout = unsafeWindow.setTimeout('salonRefresh()', 2000);
Result - it works. for(let i=30000; i>=0; i--) unsafeWindow.clearTimeout(i); window.setTimeout(unsafeWindow.salonRefresh, 2000); Result - it works. But I'm confused. This... for (let i=30000; i>=0; i--) unsafeWindow.clearTimeout(i); ...works too. _____________________________
1. Why doesn't this work(?):
unsafeWindow.clearTimeout(0); 2. setTimeout stuff
Window clearTimeout() Method 3. global use
for(let i=n; i>=0; i--) unsafeWindow.clearTimeout(i) |
![]() ![]() |
ekbworldwide wrote:cuz the first timeout must not be the right one. even anomyous settimeout calls get assigned an integer in a global scope.unsafeWindow.clearTimeout(0); ekbworldwide wrote:it would screw up timeouts on other sites, probably not good for a global idea |
![]() ![]() |
#1
#2
#3
it would screw up timeouts on other sites, probably not good for a global idea I could just put the sites/domains in exclude. I just realized excludes are needed for http*:*.google.* and stuff relating to feeds and email - but I'm basically anti-twitter and all that crud. I don't need pages to be brand new every three minutes (or whatever). I'd rather have a page be "old" because I didn't allow refreshes (for the page or parts of the page) - than have the site refresh it for me.
If I now understand correctly - n isn't constant. So how about this(?):
for (let i=2000000; i>=0; i--) unsafeWindow.clearTimeout(i); ... inside an if statement. I'm trying to figure out how to build the if statement. 2 million milliseconds is about 30 minutes. I know that 30 minutes is overkill but I really hate refreshes. |
![]() ![]() |
ekbworldwide wrote:no. its clearing all timeouts on the page. ekbworldwide wrote:no, it would screw up 85% of websites, not a good idea ekbworldwide wrote:you dont get it. if theres 1 timeout on a page, it will be 0, if i add another, it will be 1, and so on. i can clearTimeout(0) and it will clear the first timeout that was set on the page |
![]() ![]() |
no. its clearing all timeouts on the page. My first thought was right? I'm confused again. Haha. Anyway... using a giant n is a terrible idea. It works fine on my tiny local test page but on a real webpage - the first link in my first post - even setting n > 500000 can start to take a few seconds or freeze Firefox or crash it. And I sometimes have many tabs open. So FOR loops aren't a good idea. New idea 1. In a script tag... 2. Use regex and find setTimeout - example - 3. Use unsafeWindow to create the equivalent of 4. 5. 6. Repeat steps on next script tag. _____________
I don't know if my logic is sound. I have no idea how to do step 3. The idea assumes only one setTimeout in a tag. |
![]() ![]() |
ekbworldwide wrote:i highly doubt theres ever gonna be 500,000 timeouts on a page. probably 100 or 200 is fine |
![]() ![]() |
The more I do this - the more confused I'm getting, but this... for (let i=100; i>=0; i--) {
refresh_time = Math.round((Math.random()*1000)*(Math.random()*1000));
function salonRefresh() {
location.href = location.href
}
var refreshTimeout = setTimeout('salonRefresh()', refresh_time);
t=setTimeout('salonRefresh()', refresh_time);
GM_log("refresh_time: " + refresh_time + " " + "t: " + t);
}
...helped me a bit. I see now that refresh_time isn't relevant at all. t starts at 3 and is only odd numbers - but at least I understand more. So - I've walked around in a big circle. Is this all I need(?): for (let i=500; i>=0; i--) unsafeWindow.clearTimeout(i); My overkill will be to make n = 500 and not 100 or 200. I won't bother with an IF statement. |
![]() ![]() |
ekbworldwide wrote:u cant do one anyways, its not in a variable so no way to check just gotta clear em. ekbworldwide wrote:stop using the quotes. use window.setTimeout(salonRefresh, refresh_time);are you trying to kill the refresh? if so just use unsafeWindow.salonRefresh=function(){return true;};
|
![]() ![]() |
oh oh oh ... big confusion. Trying to shed some light on it First:
for(let i=900; i>=0; i--) unsafeWindow.clearTimeout(i); is EXACTLY the same as for(let i=900; i>=0; i--) unsafeWindow.clearTimeout(i); which both are different than
for(let i=900; i>=0; i--) {}
unsafeWindow.clearTimeout(i);
Second: Your first statement lead us to the impression that you wanted to have a ONE SECOND TIMEOUT instead of the FIVE MINUTE TIMEOUT to refresh the page. This is obviously not the case any more. Can you specify your question again without anticipating the answer? Let us do the work :-) Third: You said that t starts with 3 and has just odd numbers in this example
var refreshTimeout = setTimeout('salonRefresh()', refresh_time);
t=setTimeout('salonRefresh()', refresh_time);
This is of course correct, because EVERY call of setTimeout will generate a completely NEW timeout in ADDITION to every timeout currently running. So Joe suggested to clear all running timeouts before you set your new one. And you can do that with the statement under my "First" section. Fourth: The result of a setTimeout call is a unique identifier of the generated timeout. In the previous example the variables |
![]() ![]() |
Current script:
// regular refresh stuff ----------------------------------
for (let i=500; i>=0; i--)
unsafeWindow.clearTimeout(i);
// meta stuff ---------------------------------------------
let m=window.setTimeout(function() {},99);
for(let i=m;i>0;i--)
window.clearTimeout(i);
// For the meta stuff to work - an about:config tweak needs to be made.
// set accessibility.blockautorefresh to true
__________________________________________
With the script enabled - going to the link: Chicago Tribune
...instantly shows the message. |
![]() ![]() |
Ok, but it's not the enabled script that causes this behaviour. It is the Firefox option (Tools/Options/Advanced/Tab General/Section Accessibility ... "Warn me when web sites try to redirect or reload the page") which is checked for you. As far as I know the alert message can not be turned off by Greasemonkey. |
![]() ![]() |
So the meta refresh code doesn't actually work? I'll post at userstyles.org and see if I can hide the message with Stylish. _____________
I just realized that there's no way to "exclude" about:config stuff - so using the about:config setting isn't going to work. example In a script I an exclude |
![]() ![]() |
After some google-ing I strongly believe that a meta refresh can not be stopped by Javascript. |
![]() ![]() |
I noticed the word auto in blockautorefresh. I think what I want to block is all auto-refreshes. New question: In about:config if I set accessibility.blockautorefresh to true - does that block all auto-refreshes (i.e. meta, js, http, whatever)? |
![]() ![]() |
It will block meta and http, but not js. |

