How do I make Firefox auto-refresh on file change?

前端 未结 10 691
半阙折子戏
半阙折子戏 2020-11-29 18:43

Does anyone know of an extension for Firefox, or a script or some other mechanism, that can monitor one or more local files. Firefox would auto-refresh or otherwise update i

10条回答
  •  长情又很酷
    2020-11-29 18:55

    You can use live.js with a tampermonkey script to avoid having to include https://livejs.com/live.js in your HTML file.

    // ==UserScript==
    // @name         Auto reload
    // @author       weirane
    // @version      0.1
    // @match        http://127.0.0.1/*
    // @grant        none
    // ==/UserScript==
    
    (function() {
        'use strict';
        if (Number(window.location.port) === 8000) {
            const script = document.createElement('script');
            script.src = 'https://livejs.com/live.js';
            document.body.appendChild(script);
        }
    })();
    

    With this tampermonkey script, the live.js script will be automatically inserted to pages whose address matches http://127.0.0.1:8000/*. You can change the port according to your need.

提交回复
热议问题