-
Notifications
You must be signed in to change notification settings - Fork 3
/
monochromium.js
56 lines (55 loc) · 1.53 KB
/
monochromium.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
window.MonoChromium = function (url) {
var m = new Modal();
m.className = "webbrowser monochromium";
m.$m.className += " webbrowser monochromium";
m.title("Elgoog MonoChrome");
m.content(`
<div class='bar'>
<button class='back'>←</button>
<button class='forwards'>→</button>
<button class='reload'>↻</button>
<input spellcheck='false'/>
<button class='hotdog'>≡</button>
</div>
<div class='iframe-wrapper'>
<iframe nwdisable nwfaketop nwUserAgent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) MonoChrome/41.0.2228.0 Safari/537.36'>
</div>
`);
var $if = m.$("iframe");
//$if.sandbox = "allow-scripts allow-same-origin";
var $in = m.$("input");
$in.value = url || "http://gmail.net/";
$in.value = $if.src = urlize($in.value);
function validate() {
if ($if.contentWindow.history) {
return true;
} else {
console.log("no history");
return false;
}
}
function urlize(str) {
if (str.match(/^(\w+:\/?\/?)?/)) {
return "http://" + $in.value.replace(/^\w+:\/?\/?/, "");
}
}
m.$(".back").onclick = function () {
if (!validate()) return;
$if.contentWindow.history.go(-1);
};
m.$(".forwards").onclick = function () {
if (!validate()) return;
$if.contentWindow.history.go(1);
};
m.$(".reload").onclick = function () {
if (!validate()) return;
$if.contentWindow.history.go(0);
};
$in.onkeypress = function (e) {
if (e.keyCode == 13) {
$if.src = "http://" + $in.value.replace(/\w+:\/?\/?/, "");
$in.value = $if.src;
}
};
return m;
};