mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
112 lines
3.7 KiB
HTML
112 lines
3.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Site Preview</title>
|
|
<link rel="stylesheet" href="/_iframe-client.css">
|
|
<!-- Early console interception setup -->
|
|
<script>
|
|
// Set up console interception as early as possible to catch all errors
|
|
(function() {
|
|
// Store original console methods before any other script runs
|
|
const originalConsole = {
|
|
log: console.log,
|
|
warn: console.warn,
|
|
error: console.error,
|
|
info: console.info,
|
|
debug: console.debug,
|
|
exception: console.exception,
|
|
assert: console.assert,
|
|
clear: console.clear,
|
|
count: console.count,
|
|
countReset: console.countReset,
|
|
dir: console.dir,
|
|
dirxml: console.dirxml,
|
|
group: console.group,
|
|
groupCollapsed: console.groupCollapsed,
|
|
groupEnd: console.groupEnd,
|
|
table: console.table,
|
|
time: console.time,
|
|
timeEnd: console.timeEnd,
|
|
timeLog: console.timeLog,
|
|
trace: console.trace,
|
|
};
|
|
|
|
// Early error handlers to catch setup errors
|
|
const earlyErrors = [];
|
|
|
|
// Override console methods immediately
|
|
const methods = ['log', 'warn', 'error', 'info', 'debug', 'exception', 'assert', 'clear', 'count', 'countReset', 'dir', 'dirxml', 'group', 'groupCollapsed', 'groupEnd', 'table', 'time', 'timeEnd', 'timeLog', 'trace'];
|
|
|
|
methods.forEach(method => {
|
|
if (typeof console[method] === 'function') {
|
|
console[method] = function(...args) {
|
|
// Call original method
|
|
try {
|
|
originalConsole[method](...args);
|
|
} catch (e) {
|
|
// Original method failed
|
|
}
|
|
|
|
// Store error for later processing
|
|
if (method === 'error' || method === 'exception') {
|
|
earlyErrors.push({
|
|
level: method,
|
|
message: args.map(arg => {
|
|
if (typeof arg === 'object') {
|
|
try {
|
|
return JSON.stringify(arg);
|
|
} catch {
|
|
return String(arg);
|
|
}
|
|
}
|
|
return String(arg);
|
|
}).join(' '),
|
|
timestamp: Date.now(),
|
|
args: args
|
|
});
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
// Set up global error handlers
|
|
window.addEventListener('error', function(event) {
|
|
earlyErrors.push({
|
|
level: 'error',
|
|
message: `Global Error: ${event.message}`,
|
|
timestamp: Date.now(),
|
|
args: [{
|
|
filename: event.filename,
|
|
lineno: event.lineno,
|
|
colno: event.colno,
|
|
error: event.error ? event.error.message : 'No error object'
|
|
}]
|
|
});
|
|
});
|
|
|
|
window.addEventListener('unhandledrejection', function(event) {
|
|
earlyErrors.push({
|
|
level: 'error',
|
|
message: 'Unhandled Promise Rejection',
|
|
timestamp: Date.now(),
|
|
args: [event.reason]
|
|
});
|
|
});
|
|
|
|
// Store early errors for the main script to process
|
|
window._earlyConsoleErrors = earlyErrors;
|
|
})();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div class="loading">
|
|
<div class="spinner"></div>
|
|
<p>Loading preview...</p>
|
|
<p><small>Waiting for ServiceWorker and parent communication</small></p>
|
|
</div>
|
|
<script src="/_iframe-client.js"></script>
|
|
</body>
|
|
</html>
|