kkapuria3/BestBuy-GPU-Bot

Window constantly switches

the-rich-piana opened this issue ยท 11 comments

I don't know much about tampermonkey; But the whole reload and close old tab functionality means I can't really use my chrome.
Any fixes?

You can run this on a separate browser window.

I tried, but everytime it creates a new tab, it switches the focused window. (Windows 10)

I'm having a similar issue where chrome tabs me out when refreshing no matter what application or browser I'm using.

Ya honestly makes it unusable on my main pc.

The biggest issue for me is that it interrupts my typing, so any kind of work when the script is running is painful at times.

This issue was fixed when I upgraded to Windows 11. No more tabbing out of other windows constantly or typing being interrupted.

guys, any fixes for windows 10 ?

Besides upgrading to Windows 11, I haven't been able to find any fixes for that issue. Legit tried everything and nothing worked until I upgraded to Windows 11 which the problem stopped occurring altogether.

Hello,

The switching tab feature is caused by the
window.open(window.location.href, '_blank'); window.close();
code on line 580.

This is an alternative to reloading that reduces the memory leak that running the script for long periods of time will cause.

In order to work around this, simply comment out those two lines of code and uncomment the
//location.reload(); // This command here blows up your memory
line below it.

As stated, simply reloading every time will cause the tab to eat up memory, but if you x out the tab every once in a while you should have no severe issues.

You can replace those lines with this block to at least limit the full close/open to once every hour. Not sure how fast the memory grows, but you could also set the condition to only trigger at a certain time of night and have it clear the memory usage once per day.

const current_time = new Date();
if (current_time.getMinutes() == 0 && current_time.getSeconds() <= 20){
   window.open(window.location.href, '_blank');
   window.close();
} else {
    location.reload(); // This command here blows up your memory
}

Here is the code to set the tab to do a full reload every "x" hours:

const current_time = new Date();
const hrly_refresh_interval = 1 // Do a true reload of the webpage every X hours...
if (current_time.getHours() % hrly_refresh_interval == 0 && current_time.getMinutes() == 0){ //...and only refresh once on the set hour
  window.open(window.location.href, '_blank');
  window.close();
} else {
  location.reload(); // This command here blows up your memory
}