chore: sync from Academia-LMS 4eff528
This commit is contained in:
1 parent
dc8475d107
commit
0687af7f92
6 files changed
+896
-2
No files matched your search
@@ -0,0 +1,28 @@
|
||||
/* Loaded before the GUI bundle (inline scripts are blocked by the CSP). */
|
||||
// Opaque origin (sandboxed iframe): localStorage/sessionStorage/cookies throw SecurityError.
|
||||
// Replace them with in-memory stand-ins before the GUI bundle loads.
|
||||
(function () {
|
||||
function mem() {
|
||||
var d = {};
|
||||
return {
|
||||
getItem: function (k) { return Object.prototype.hasOwnProperty.call(d, k) ? d[k] : null; },
|
||||
setItem: function (k, v) { d[k] = String(v); },
|
||||
removeItem: function (k) { delete d[k]; },
|
||||
clear: function () { d = {}; },
|
||||
key: function (i) { return Object.keys(d)[i] || null; },
|
||||
get length() { return Object.keys(d).length; }
|
||||
};
|
||||
}
|
||||
['localStorage', 'sessionStorage'].forEach(function (name) {
|
||||
var ok = false;
|
||||
try { ok = !!window[name]; } catch (e) { /* SecurityError */ }
|
||||
if (!ok) {
|
||||
try { Object.defineProperty(window, name, { value: mem(), configurable: true }); } catch (e) { /* ignore */ }
|
||||
}
|
||||
});
|
||||
var cookieOk = false;
|
||||
try { cookieOk = typeof document.cookie === 'string'; } catch (e) { /* SecurityError */ }
|
||||
if (!cookieOk) {
|
||||
try { Object.defineProperty(document, 'cookie', { get: function () { return ''; }, set: function () {}, configurable: true }); } catch (e) { /* ignore */ }
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user