|
1 | 1 | <head> |
2 | 2 | <style> |
| 3 | + |
| 4 | + *{ |
| 5 | + font-family: 'Whitney','Arial'; |
| 6 | + color:#fff; |
| 7 | + } |
| 8 | + |
| 9 | + button,input,select{ |
| 10 | + color:#000; |
| 11 | + } |
| 12 | + |
| 13 | + p { |
| 14 | + margin:0px; |
| 15 | + } |
| 16 | + |
3 | 17 | body { |
4 | 18 | background-color: #666; |
5 | 19 | margin: 0px; |
|
26 | 40 | min-width: 35px; |
27 | 41 | -webkit-app-region: no-drag; |
28 | 42 | text-align: center; |
29 | | - font-family: 'Whitney','Arial'; |
30 | 43 | color: #eee; |
31 | 44 | font-size: 22px; |
32 | 45 | padding-left: 4px; |
|
90 | 103 | border-radius: 8px; |
91 | 104 | } |
92 | 105 |
|
| 106 | + .updatedialog { |
| 107 | + display: none; |
| 108 | + position: fixed; |
| 109 | + width: 100%; |
| 110 | + height: 100%; |
| 111 | + background-color: rgba(51, 51, 51, 0.7); |
| 112 | + z-index:99999; |
| 113 | + } |
| 114 | + |
| 115 | + .updatedialog.active { |
| 116 | + display: block; |
| 117 | + } |
| 118 | + |
| 119 | + .updatedialogbody { |
| 120 | + position: fixed; |
| 121 | + background-color: #666; |
| 122 | + width: 26vw; |
| 123 | + left: 37vw; |
| 124 | + top: 45vh; |
| 125 | + padding: 16px; |
| 126 | + border-radius: 8px; |
| 127 | + } |
| 128 | + |
93 | 129 | .rolldownbtn { |
94 | 130 | position: fixed; |
95 | 131 | display: none; |
|
103 | 139 | .topbar:hover { |
104 | 140 | height: 30px !important; |
105 | 141 | } |
| 142 | + |
| 143 | + .buttoncontainer{ |
| 144 | + display:flex; |
| 145 | + flex-flow:row nowrap; |
| 146 | + justify-content: center; |
| 147 | + } |
| 148 | + |
| 149 | + .button{ |
| 150 | + flex: 1 1 0; |
| 151 | + display:flex; |
| 152 | + border-radius: 8px; |
| 153 | + height: 40px; |
| 154 | + margin: 0px 4px; |
| 155 | + padding:4px; |
| 156 | + background-color:#888; |
| 157 | + justify-content: center; |
| 158 | + align-items:center; |
| 159 | + font-size:20px; |
| 160 | + } |
| 161 | + .updatetext{ |
| 162 | + font-size: 20px; |
| 163 | + margin-top:0px; |
| 164 | + margin-bottom:8px; |
| 165 | + } |
106 | 166 | </style> |
107 | 167 | </head> |
108 | 168 |
|
|
147 | 207 | tabs</input> |
148 | 208 | </div> |
149 | 209 | </div> |
| 210 | + <div class="updatedialog"> |
| 211 | + <div class="updatedialogbody"> |
| 212 | + <p class="updatetext">An update for DTabs is available, would you like to apply it?</p> |
| 213 | + <div class="buttoncontainer"> |
| 214 | + <div class="button" onclick="update()"><p>Yes</p></div> |
| 215 | + <div class="button" onclick="dismissupdate(false)"><p>No</p></div> |
| 216 | + <div class="button" onclick="dismissupdate(true)"><p>Never</p></div> |
| 217 | + </div> |
| 218 | + </div> |
| 219 | + </div> |
150 | 220 | <div class="mainbody"> |
151 | 221 | </div> |
152 | 222 | </body> |
| 223 | +<script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
153 | 224 | <script> |
154 | | - const VERSION="VERSION=0;"; |
155 | | - |
| 225 | + const VERSION="VERSION=1;"; |
| 226 | + |
156 | 227 | var $ = document.querySelector.bind(document) |
157 | 228 | var $$ = document.querySelectorAll.bind(document) |
158 | 229 |
|
|
171 | 242 | } |
172 | 243 | ` |
173 | 244 | let tabtokens = {} |
174 | | - |
175 | 245 | let csskeys = {}; |
176 | 246 |
|
| 247 | + const fs = require("fs"); |
| 248 | + |
177 | 249 | $`#injecttoggle`.checked = localStorage.getItem('injectcss') == 'true' |
178 | 250 | $`#locktabs`.checked = localStorage.getItem('tablock') == 'true' |
179 | 251 | $`#injectpath`.textContent = localStorage.getItem('csspath') || "Select file" |
|
225 | 297 | $`.settings`.classList.add("active") |
226 | 298 | } |
227 | 299 |
|
| 300 | + //autoupdater |
| 301 | + setInterval(updatecheck,10800000) |
| 302 | + |
| 303 | + var updatecontents = ""; |
| 304 | + var checkdisabled = false; |
| 305 | + var verregex = /VERSION=(\d)+;/; |
| 306 | + var instance = axios.create({ |
| 307 | + validateStatus: a => { |
| 308 | + return true; |
| 309 | + } |
| 310 | + }); |
| 311 | + |
| 312 | + function updatecheck(noprompt){ |
| 313 | + if(checkdisabled) return; |
| 314 | + instance.get("https://raw.githubusercontent.com/craftxbox/DTabs/master/index.html").then(function(response){ |
| 315 | + if(response.status != 200 && !checkdisabled){ |
| 316 | + checkdisabled = true; |
| 317 | + alert("DTabs was unable to check for updates!") |
| 318 | + return; |
| 319 | + } |
| 320 | + updatecontents = response.data; |
| 321 | + if(!verregex.test(updatecontents)) return; |
| 322 | + if(updatecontents.match(verregex)[1] > VERSION.match(verregex)[1]){ |
| 323 | + console.log("DTabs found an update! Upstream Version:",updatecontents.match(verregex)[1]) |
| 324 | + if(!noprompt) $`.updatedialog`.classlist.add("active"); |
| 325 | + } else{ |
| 326 | + console.log("DTabs did not find an update. Upstream Version:",updatecontents.match(verregex)[1]) |
| 327 | + } |
| 328 | + }) |
| 329 | + } |
| 330 | + |
| 331 | + function update(){ |
| 332 | + $`.updatedialog`.classList.add("active") |
| 333 | + $`.updatedialogbody`.setAttribute("style","display:none;") |
| 334 | + updatecheck(true); |
| 335 | + fs.renameSync("./resources/app/index.html","./resources/app/index.html.OLD-"+Date.now()); |
| 336 | + fs.writeFileSync("./resources/app/index.html",updatecontents,"utf8"); |
| 337 | + alert("Update has been applied, DTabs will now exit."); |
| 338 | + window.close(); |
| 339 | + } |
| 340 | + |
| 341 | + function dismissupdate(dontask){ |
| 342 | + checkdisabled = dontask; |
| 343 | + $`.updatedialog`.classlist.remove("active"); |
| 344 | + } |
| 345 | + |
228 | 346 | function csspath(reload = false) { |
229 | 347 | if (!reload) { |
230 | 348 | const { dialog } = require("electron").remote |
|
235 | 353 | } |
236 | 354 | } |
237 | 355 | if (localStorage.getItem('injectcss') == 'true' && localStorage.getItem('injectcss') && localStorage.getItem('csspath') != null) { |
238 | | - const fs = require("fs"); |
239 | 356 | var cssfile = fs.readFileSync(localStorage.getItem("csspath")).toString(); |
240 | 357 | for (var i of $$("webview")) { |
241 | 358 | i.executeJavaScript(`document.querySelector('.DTABSCSS') != null ? document.head.removeChild(document.querySelector('.DTABSCSS')) : null; |
|
257 | 374 | async function inittabs() { |
258 | 375 | if (tabsuninit.length < 1) { |
259 | 376 | csspath(true); |
| 377 | + updatecheck(); |
260 | 378 | return; |
261 | 379 | }; |
262 | 380 | let i = tabsuninit[0] |
|
0 commit comments