mirror of
https://github.com/zhigang1992/AlwaysHTTPS.git
synced 2026-06-12 21:58:35 +08:00
24 lines
591 B
JavaScript
24 lines
591 B
JavaScript
'use strict';
|
|
|
|
// Reload client for Chrome Apps & Extensions.
|
|
// The reload client has a compatibility with livereload.
|
|
// WARNING: only supports reload command.
|
|
|
|
const LIVERELOAD_HOST = 'localhost:';
|
|
const LIVERELOAD_PORT = 35729;
|
|
const connection = new WebSocket('ws://' + LIVERELOAD_HOST + LIVERELOAD_PORT + '/livereload');
|
|
|
|
connection.onerror = error => {
|
|
console.log('reload connection got error:', error);
|
|
};
|
|
|
|
connection.onmessage = e => {
|
|
if (e.data) {
|
|
const data = JSON.parse(e.data);
|
|
if (data && data.command === 'reload') {
|
|
chrome.runtime.reload();
|
|
}
|
|
}
|
|
};
|
|
|