Not loaded

Autoreload Bookmarklet

Just move the following bookmarklet to your bookmarks toolbar:

Please enable JavaScript!

Autoreload

It is ? bytes small and tested with Chromium, Firefox and Safari. Feel free to check out the source and to share improvements.

Have fun!

Implementation

This bookmarklet is written in the style of self-contained literate programming. That is, you can simply change the following JavaScript code snippets directly within this XHTML document, and the bookmarklet will be assembled automatically.

As usual, the bookmarklet is embedded into a closure within a "javascript" URL.

First, the original URL is retrieved, and the URL fragment is stripped. (The fragment causes trouble with autoreloading in some browsers.)

Then, a new window (usually just a new browser tab) is opened to provide a fresh environment for the autoreload mechanism. That ensures the bookmarklet won't influence the current window in any way.

The new window consists of a very simple HTML document which contains just a single big frame and some JavaScript code.



  
    [Autoreload] '+urlWithoutFragment+'
    
  
  
    
  
]]>

Since the autoreload mechanism needs a working frame object, it is completely embedded in the "load" event handler of the new window.

The autoreload mechanism itself works in two steps. First, an event handler is installed which triggers whenever the reload of the frame has finished. Second, the whole mechanism is started by loading the original URL once.

Finally, a frame reload is initiated 100ms after the previous reload has finished.

That's it!

Assembling

The following code is executed whenever this XHTML file is loaded. It assembles the implementation to a working bookmarklet link.

    

    

Copyright

Copyright © 2012 Volker Grabsch

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Fork me on GitHub