From 681d2caca7cab9380fc0d4aadfcc46224db210f0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 6 Nov 2020 19:19:18 +0530 Subject: [PATCH] minimal patch for iOS firefox --- www/common/boot2.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/www/common/boot2.js b/www/common/boot2.js index 30f776a25..87bba4a43 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -37,6 +37,42 @@ define([ window.alert("CryptPad needs localStorage to work. Try changing your cookie permissions, or using a different browser"); }; + + var getLogElement = function () { + var logger = document.querySelector('#cp-logger'); + if (logger) { return logger; } + logger = document.createElement('div'); + logger.setAttribute('id', 'cp-logger'); + document.body.appendChild(logger); + var css = function(){/* #cp-logger { display: none; } */}.toString().slice(14, -3); + var style = document.createElement('style'); + style.type = 'text/css'; + style.appendChild(document.createTextNode(css)); + document.head.appendChild(style); + return logger; + }; + + + var logToDom = function () { + var pre = document.createElement('pre'); + pre.innerText = 'x'; + getLogElement().appendChild(pre); + }; + + if (window.Proxy) { + var c = console; + window.console = new Proxy(c, { + get: function (o, k) { + if (k !== 'error') { return o[k]; } + return function () { + var args = Array.prototype.slice.call(arguments); + c.error.apply(null, args); + logToDom(); + }; + }, + }); + } + window.onerror = function (e) { if (/requirejs\.org/.test(e)) { console.log();