Make initial redirection only occur if the system is webOS - Closes #3 (#4)

* Make initial redirection only occur if the system is webos

* Switch to from copying source of is_webos, to using a global variable

* Fix indentation
pull/8/head
Drake 2021-06-16 22:46:16 -07:00 zatwierdzone przez GitHub
rodzic b599491f33
commit 364e67ce5a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 5 dodań i 4 usunięć

Wyświetl plik

@ -60,11 +60,15 @@
};
</script>
<script>
var is_webos = navigator.userAgent.toLowerCase().indexOf("webos") !== -1 ||
navigator.userAgent.toLowerCase().indexOf("netcast") !== -1 ||
navigator.userAgent.toLowerCase().indexOf("smarttv") !== -1;
console.log("is_webos: " + is_webos)
// Exploit data: url navigation for browsers which didn't have following patch
// applied yet (webOS 3.x):
// https://chromium.googlesource.com/chromium/src.git/+/130ee686fa00b617bfc001ceb3bb49782da2cb4e
try {
if (window.location.protocol !== 'data:') {
if (window.location.protocol !== 'data:' && is_webos) {
window.location = 'data:text/html;base64,' + btoa(document.documentElement.innerHTML
.replace('="css/common.css"', '="' + new URL('css/common.css', window.location.href).href + '"')
.replace('__START_ORIGIN__', window.location.href));
@ -212,9 +216,6 @@
document.querySelector("#main-article").innerHTML = "<pre id='log'></pre>";
var is_local = window.location.protocol === 'file:';
var is_webos = navigator.userAgent.toLowerCase().indexOf("webos") !== -1 ||
navigator.userAgent.toLowerCase().indexOf("netcast") !== -1 ||
navigator.userAgent.toLowerCase().indexOf("smarttv") !== -1;
if (!is_local && !is_webos) {
log("[Warning] You should be visiting this page from a webOS device, not your desktop web browser!");