This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.js
59 lines (49 loc) · 1.61 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(function(){
'use strict';
var CHROME_ONLY = 1;
window.addEventListener('load', function(){
var O = {
doc: document,
body: document.body,
init: function(){
var noscript = document.querySelector('noscript');
if(CHROME_ONLY && window.navigator.vendor != 'Google Inc.'){
var html = noscript.innerHTML.split(/\r\n|\r|\n/);
html = html.map(function(a){ return a.trim(); });
html = html.filter(function(a){ return a.length; });
var msg = html[html.length - 1];
O.fatalError(msg);
return;
}
noscript.remove();
O.rf('/omikron.js', function(status, script){
if(status != 200) return O.fatalError('Cannot load framework script. Try disabling extensions.');
new Function(script)();
});
},
fatalError: function(msg){
var h1 = O.doc.createElement('h1');
var t = O.doc.createTextNode('Fatal Error');
O.body.appendChild(h1);
h1.appendChild(t);
t = O.doc.createTextNode(msg);
O.body.appendChild(t);
},
urlTime: function(url){
var char = url.indexOf('?') != -1 ? '&' : '?';
return '' + url + char + '_=' + Date.now();
},
rf: function(file, cb){
var xhr = new window.XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
cb(xhr.status, xhr.responseText);
}
};
xhr.open('GET', O.urlTime(file));
xhr.send();
}
};
O.init();
});
})()