I have a javascript in a form of an extension on my Brave, that is connected to the authotkey commands, when I press a button the script will activate and constantly check for the button on a website, I refresh the website and the button appears, javascript clicks the button... Perfect...
Only sometimes, for no reason what so ever, it wont click it until full page is loaded and its slow to execute, other times it works in 0.1 seconds and clicks the button soon as it appears in the elements, I have tried a million things, even going so far to reinstall Windows, I do not change the code nothing in the code changes, the script sometimes works before site loads really fast, and sometimes waits for the whole page to load before clicking it. (It will usually work for few hours or days and then stop working)
My internet is fiber optics always same Ms and 0 jitter.
ANY TOUGHTS?
It might not be something on your end.
Sometimes, one element on the page that's getting loaded will take longer to load for reasons that are not under your own control - for example images loaded from a 3rd party source, like ads. This can cause delays in other dependent processes (that includes your script). However,
if you update your question with reproduction instructions we might be able to determine why, and,
in hindsight, it does sound like a load event being delayed, and it might be possible to change the script reference point to be a DOMContentLoaded event which fires sooner and should be enough for your script to start clicking stuff.
Related
I have a simple html page that displays some monitoring results, it reloads every 2 minutes and makes noise when those results are not acceptable. I keep this page open 24/7, so new Chrome started freezing and suspending it, as I found out via chrome://discards/ .. So the page stopped making noise and catching my attention, mostly cause the tab gets frozen by Chrome. That happens if I forget to leave the tab with this page active, "on top". Is there a rather simple way to prevent Chrome from freezing the tab, even if it is not active? I could involve some Javascript, if needed..
I am aware that there is a simple solution of opening new window with this page and leaving it alone. On the other hand, I made the page, so I can make changes to HTML in order to ensure that page remains unfrozen. I tried updating title with current time on every reload, this visibly helped, page seemingly always has fresh time in the title, but it still doesn't make noise. And if I switch into it when noise is supposed to happen, - it starts the sound half way like it was trying to all alone.. it's even funny..
Is there any simple solution to this? Thanks for your help.
I have a php page that hangs for 3-10 seconds after the page loads, you can't even scroll up or down, or close the tab when this happens. (the chrome loading gif still loops tho) Happens in Chrome and IE.
Chrome Timeline: http://imgur.com/wF5Pioz,KRbnxIm#0
Shows ContentVeil.js repeating over and over. I think it is client side(?), I did a grepWIN to search for ContentVeil, with no luck, and it doesn't show up in Chrome Network tab.
Chrome Profile: Second image, from above link.
I think this shows the issue at the anonymous function from meta-boxes.min.js, ln 1.
meta-boxes.min.js: http://pastebin.com/yqtJyqB1
Unfortunately line one is a function that encapsulates the whole script. I don't know js very well, I tried to just remove each function one by one but that just created more errors.
Any ideas on how I could find the source of the problem would be much appreciated.
It's part of the Evernote web clipping extension, and it's hooks DOM events, causing massive slowdowns if you are doing large amount of dom changes.
I have a webapp, that when loaded for the first time has a long initialization sequence. Basically it calls an external API to get loads of data which it caches upon completion, using HTML5 localstorage API.
The issue is, it never gets through initialization in Mobile Safari on the first attempt. At around the same point each time, my AJAX calls just stop firing. When I refresh the page, it starts initialization over again, but this time gets through.
If I clear the browser cache and start this process over again, it is always the same. Fail on first attempt, succeed on subsequent refreshes.
I'm aware that there are certain barriers in place in Mobile Safari to prevent large consumption of data unless in direct response to user input (such as the HTML5 audio tag not being able to 'autoplay').
I'm wondering if there is something similar in place for loading web pages for the first time that immediately consume large amounts of data. And by refreshing, Mobile Safari takes that as your explicit permission to do so.
Anyone know?
I suggest you start with a simple, quick-loading base html file, which will give your user something to look at right away -- even if it's just a simple "Loading...".
Then use ajax to get your "loads of data," using window.onload for example. Ideally give your user something to read or interact with so they don't notice the wait, or a progress indicator, to know the site is actually working.
People are impatient, and when faced with a blank screen and the browser loading indicator not making progress, they're going to assume your site is broken within a few seconds.
The certain barriers...to prevent large consumption of data are probably there for exactly this reason, to improve user experience and prevent monstrous web pages.
I am writing an android (2.2) app which launches the default native web browser via a new Intent to a page I've created. On that page, it pauses for 2 seconds before then submitting a form, which redirects the user to another page.
I am using javascript's setTimeout() function.
It works most of the time, but then sometimes it just stops working, and won't work again until I restart the phone!
There are NO javascript errors which appear in LogCat.
Even stranger, to counteract this I put a link on the page that says "If the page has not redirected in 5 seconds click here". It submits the form when clicked, via onClick() and .submit(). Well, again, it usually works, but, when the setTimeout() function stops working, so does the link! But, I have confirmed that alert() still works, so some javascript functions apparently still work.
Any ideas why setTimeout() and .submit() would just randomly stop working, until the phone is reset?
EDIT: I've also confirmed that window.location doesn't work anymore either, but, if you just have a regular link, it does actually let you click on it, and it leaves the page.
EDIT: It appears that you can get this problem to happen more quickly if you hit STOP and REFRESH a few times while waiting for the setTimeout to fire off. Basically if I hit stop, then refresh, then stop, then back, etc, a couple times, I can get this problem to happen. After it starts, no amount of refreshing or killing/restarting the browser will make these javascript functions start working again.
Thanks!
Richard
I came across this post that may be of help: http://www.barneyb.com/barneyblog/2011/02/20/settimeout-bug-in-android-2-2/
On a page, something like jsFiddle, that executes user inputed Javascript, is there a way to stop / disrupt "problem" scripts running in an iframe?
The major class of problem scripts would be infinite loops, I think. Browsers deal with multiple alerts quite well, but a script like, for (var i = 0; ++i; i < 100) { /* do stuff */ } will go forever.
How can I either detect and not run, or run and stop, say after 10 seconds of running, a script?
Removing the iframe is fine, but I only want to remove it if the script is still running after 10 seconds, but I don't want to remove it if the script has stopped running.
Here is how I imagine the page will work. If you have a better solution, let me know...
The input page contains a textarea and a blank iframe. The user enters their script into the textarea, and when ready they click on run. Then (backstage) a separate page is created that contains the user script in executable form on an HTML page. The src of the iframe is set to the page with the executable code. This all happens dynamically without a page refresh.
I haven't used this jsandbox script, but it appears to have what you want.
If one script freezes on a page, other scripts will not continue to run. Therefore, there is no way to detect if another script has stopped running, without using a custom plugin or something. Browsers do not use multithreading in that way.
You could set a timeout in the main window which stops / deletes the script after 10 seconds. Then you just have to clear the timeout when the script has finished (just add a line like this to the iframe script: window.frames[0].clearTimeout(window.frames[0].timeoutName) -- I don't know if it works, but it should)
I think this would largely depend on the script and how browsers handle scripts in iframes.
Let's say there's a while(true) in the iframe.
The browser may either lock up, or crash the tab (like what Chrome does), or it might lock up the iframe. If it locks up or crashes the tab, there's nothing you can do with JS itself to prevent it, other than attempting static analysis on the script to find possibly problematic statements (Static analysis to find problematic scripts like that would never be foolproof)
Assuming the browser only locks up the iframe or does something else while still allowing the scripts in the main page to do things, removing the iframe after a certain period of time is an option.
The browser might also display the "Script is slow" popup. In this case, it will most likely either completely shut down all scripts in the entire tab or just in the iframe. If just the iframe, the other scripts in the tab could still clean up after it after the predefined period of time.
Another alternative would be to pre-evaluate the script in a separate runtime where you can detect things like that yourself. You could run the script in, say, Rhino, and determine if it takes too long to process, or something similar.
I don't know if this would work exactly, you might be able to get something like this to work with a little bit of tinkering. I take it that you are taking in text JavaScript and then evaling it, right? You could parse or maybe even just use regex to replace all of the for, for..in, while, and function declaration's call with the function call then some logic that calls your code and figures out if it has been running for 10 secs. If it has it will either return; or break; or something. The code would likely freak out afterward and probably start throwing errors, but at least the script would stop.