-
Notifications
You must be signed in to change notification settings - Fork 133
/
template.jst
74 lines (74 loc) · 2.76 KB
/
template.jst
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!doctype html>
<html><head>
<meta charset="utf-8">
<title>4chan X</title>
<link rel="stylesheet" href="web.css">
<link rel="icon" href="img/icon.gif">
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/ohnjgmpcibpbafdlkimncjhflgedgpam">
</head><body>
<div id="header">
<h1 id="4chan-x">4chan X</h1>
<div id="links">
<a href="https://github.com/ccd0/4chan-x">Source Code</a>
<a href="https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md">Changelog</a>
<a href="https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions">FAQ</a>
<a href="https://github.com/ccd0/4chan-x/wiki/Privacy">Privacy</a>
<a href="https://github.com/ccd0/4chan-x/issues">Report Bugs</a>
</div>
</div>
<a class="screenshot" href="img/screenshot.png"><img src="img/screenshot.png" alt="Screenshot"></a>
<%=
content
.match(/<\/h1>([^]*)<h2 id="more-information"/)[1]
.replace(
/(<h3 id="(.*?)">)(.*?)(<\/h3>[^]*?)(?=<h)/g,
'<input hidden type="checkbox" id="$2-hide"><div>$1<label for="$2-hide">$3</label>$4</div>'
)
%>
<script>
function imagePreview() {
this.removeEventListener('mouseover', imagePreview, false);
var img = new Image();
img.src = this.href;
img.alt = 'preview';
var span = document.createElement('span');
span.className = 'hover';
span.appendChild(img);
this.parentNode.insertBefore(span, this.nextSibling);
}
function storeInstall(e) {
if (!e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey && e.button === 0) {
var url = this.href;
chrome.webstore.install(url, function(){}, function(){
location.href = url;
});
e.preventDefault();
}
}
for (var i = 0; i < document.links.length; i++) {
var link = document.links[i];
if (/\.png$/.test(link.pathname) && !link.querySelector('.hover')) {
link.addEventListener('mouseover', imagePreview, false);
} else if (window.chrome && link.host === 'chrome.google.com') {
link.addEventListener('click', storeInstall, false);
}
}
var engine = (function() {
if (/Edge\//.test(navigator.userAgent)) return 'edge';
if (/Chrome\//.test(navigator.userAgent)) return 'blink';
if (/WebKit\//.test(navigator.userAgent)) return 'webkit';
if (/Gecko\/|Goanna/.test(navigator.userAgent)) return 'gecko';
if (/Presto\//.test(navigator.userAgent)) return 'presto';
})();
var engines = {'firefox': 'gecko', 'chromium': 'blink presto', 'safari': 'webkit', 'webkitgtk-qtwebkit-qtwebengine': 'webkit', 'ms-edge': 'edge', 'other-browsers': ''};
if (location.hash.slice(1) in engines) {
for (browser in engines) {
document.getElementById(browser + '-hide').checked = (browser !== location.hash.slice(1));
}
} else if (engine) {
for (browser in engines) {
document.getElementById(browser + '-hide').checked = (engines[browser].indexOf(engine) < 0);
}
}
</script>
</body></html>