12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ファイルの変更を監視し、ブラウザを自動でリロード

Last updated at Posted at 2013-02-23

AutoLoader

ファイルの変更を監視し、ブラウザを自動でリロードしてくれます。
コーディングの際、CSSやHTMLを変更したあと保存すると
かってにブラウザをリロードしてくれます!
ブックマークレット形式なので簡単に使えます。
FileAPIを利用しているため、IEでは動かなかったりします。

使い方

AutoLoader

1.まずは下のリングをブックマークバーに登録します。
2.リロードしたいページを開いた状態で、ブックマークレットをクリックすると小ウィンドウが開きます。そこのグレーのボックスに監視したいファイルをドロップして下さい。
3.監視ファイルを変更すると、親ウィンドウが自動でリロードされます!
4.監視を辞めたいときは、小ウィンドウを閉じるかリストをクリックすればOKです!

Bookmarklet

[AutoLoader](javascript:(function(){if(!window.File){alert("対応していません!");return}var e=window.open("","autoloader","width=350, height=450px, location=no");if(e.autoload)e.foucus();else{var t=e.document,n=t.createElement("div"),r=t.createElement("script");n.innerHTML='

    Copyright 2013 AutoLoader Geekz

    ',r.innerHTML='(function(e,t){var n=e.autoload,r=function(e){return t.getElementById(e)};autoload={},autoload.FPS=250,autoload.observer={list:{},getFiles:function(e){return e.target.files?e.target.files:e.dataTransfer.files},addFiles:function(e){var t=this.getFiles(e);for(var n=0;n<t.length;n++)this.enable(t[n])},checkPoint:function(e){var t;try{t=e.lastModifiedDate.toString()}catch(n){t=e.getAsBinary()}return t},enable:function(n){var i,s,o=r("#list ul");s=this.checkPoint(n),this.list[n.name]=setInterval(function(){i=autoload.observer.checkPoint(n),s!=i&&(s=autoload.observer.checkPoint(n),e.opener.location.reload())},autoload.FPS);var u=t.createElement("li");u.addEventListener("click",function(){this.parentNode.removeChild(this),autoload.observer.remove(n.name)},!0),r("list").appendChild(u).innerHTML=n.name},remove:function(e){clearInterval(this.list[e]),delete this.list[e]}},setInterval(function(){(!e.opener||e.opener.closed)&&e.close()},500),input=r("drop"),input.addEventListener("dragenter",function(e){e.preventDefault()},!0),input.addEventListener("dragover",function(e){e.preventDefault()},!0),input.addEventListener("drop",function(e){autoload.observer.addFiles(e),e.preventDefault()},!0),r("file").addEventListener("change",function(e){autoload.observer.addFiles(e)},!0)})(window,document)',t.title="Autoloader ver.1.0",t.body.appendChild(n),t.body.appendChild(r)}})())

    ↑ブックマークレット!これをタブにドラックして登録して下さい。

    12
    12
    0

    Register as a new user and use Qiita more conveniently

    1. You get articles that match your needs
    2. You can efficiently read back useful information
    3. You can use dark theme
    What you can do with signing up
    12
    12

    Delete article

    Deleted articles cannot be recovered.

    Draft of this article would be also deleted.

    Are you sure you want to delete this article?