OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the Adblock Plus build tools, | 2 * This file is part of the Adblock Plus build tools, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 (function() | 18 (function() |
19 { | 19 { |
20 var basename = {{metadata.get("general", "basename")|json}}; | 20 var version = null; |
21 | |
22 function doPoll() | 21 function doPoll() |
23 { | 22 { |
24 var request = new XMLHttpRequest(); | 23 var request = new XMLHttpRequest(); |
25 request.open("GET", "http://localhost:43816/"); | 24 request.open("GET", chrome.extension.getURL("devenvVersion__")); |
26 request.addEventListener("load", function() | 25 request.addEventListener("load", function() |
27 { | 26 { |
28 if (request.responseText != basename) | 27 if (version == null) |
29 return; | 28 version = request.responseText; |
30 | 29 |
31 var views = chrome.extension.getViews(); | 30 if (request.responseText != version) |
32 for (var i = 0; i < views.length; i++) | 31 chrome.runtime.reload(); |
33 if (views[i] != window) | 32 else |
34 views[i].close(); | 33 window.setTimeout(doPoll, 5000); |
35 window.location.reload(); | |
36 }, false); | 34 }, false); |
37 request.send(null); | 35 request.send(null); |
38 | |
39 window.setTimeout(doPoll, 5000); | |
40 } | 36 } |
41 | 37 |
42 // Delay first poll to prevent reloading again immediately after a reload | 38 // Delay first poll to prevent reloading again immediately after a reload |
43 window.setTimeout(doPoll, 10000); | 39 doPoll(); |
44 })(); | 40 })(); |
OLD | NEW |