|
|
@@ -27,6 +27,8 @@
|
|
|
|
|
|
const LOAD_DEFERRED_IMAGES_START_EVENT = "single-file-load-deferred-images-start";
|
|
|
const LOAD_DEFERRED_IMAGES_END_EVENT = "single-file-load-deferred-images-end";
|
|
|
+ const BLOCK_COOKIES_START_EVENT = "single-file-block-cookies-start";
|
|
|
+ const BLOCK_COOKIES_END_EVENT = "single-file-block-cookies-end";
|
|
|
const LOAD_IMAGE_EVENT = "single-file-load-image";
|
|
|
const IMAGE_LOADED_EVENT = "single-file-image-loaded";
|
|
|
const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
|
|
|
@@ -55,11 +57,6 @@
|
|
|
document.documentElement.__defineGetter__("clientWidth", () => scrollWidth);
|
|
|
screen.__defineGetter__("height", () => scrollHeight);
|
|
|
screen.__defineGetter__("width", () => scrollWidth);
|
|
|
- try {
|
|
|
- document.__defineGetter__("cookie", () => { throw new Error("document.cookie temporary blocked by SingleFile"); });
|
|
|
- } catch (error) {
|
|
|
- // ignored
|
|
|
- }
|
|
|
if (!window._singleFile_getBoundingClientRect) {
|
|
|
window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
|
Element.prototype.getBoundingClientRect = function () {
|
|
|
@@ -77,14 +74,6 @@
|
|
|
window.__defineGetter__("innerHeight", () => scrollHeight);
|
|
|
window.__defineGetter__("innerWidth", () => scrollWidth);
|
|
|
}
|
|
|
- if (!window._singleFile_localStorage) {
|
|
|
- window._singleFile_localStorage = window.localStorage;
|
|
|
- window.__defineGetter__("localStorage", () => { throw new Error("localStorage temporary blocked by SingleFile"); });
|
|
|
- }
|
|
|
- if (!window._singleFile_indexedDB) {
|
|
|
- window._singleFile_indexedDB = window.indexedDB;
|
|
|
- window.__defineGetter__("indexedDB", () => { throw new Error("indexedDB temporary blocked by SingleFile"); });
|
|
|
- }
|
|
|
if (!window._singleFileImage) {
|
|
|
const Image = window.Image;
|
|
|
window._singleFileImage = window.Image;
|
|
|
@@ -133,12 +122,12 @@
|
|
|
dispatchEvent(new UIEvent("scroll"));
|
|
|
});
|
|
|
|
|
|
+
|
|
|
addEventListener(LOAD_DEFERRED_IMAGES_END_EVENT, () => {
|
|
|
delete document.documentElement.clientHeight;
|
|
|
delete document.documentElement.clientWidth;
|
|
|
delete screen.height;
|
|
|
delete screen.width;
|
|
|
- delete document.cookie;
|
|
|
if (window._singleFile_getBoundingClientRect) {
|
|
|
Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect;
|
|
|
window.innerHeight = window._singleFile_innerHeight;
|
|
|
@@ -147,6 +136,33 @@
|
|
|
delete window._singleFile_innerHeight;
|
|
|
delete window._singleFile_innerWidth;
|
|
|
}
|
|
|
+ if (window._singleFileImage) {
|
|
|
+ delete window.Image;
|
|
|
+ window.Image = window._singleFileImage;
|
|
|
+ delete window._singleFileImage;
|
|
|
+ }
|
|
|
+ dispatchEvent(new UIEvent("resize"));
|
|
|
+ dispatchEvent(new UIEvent("scroll"));
|
|
|
+ });
|
|
|
+
|
|
|
+ addEventListener(BLOCK_COOKIES_START_EVENT, () => {
|
|
|
+ try {
|
|
|
+ document.__defineGetter__("cookie", () => { throw new Error("document.cookie temporary blocked by SingleFile"); });
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
+ if (!window._singleFile_localStorage) {
|
|
|
+ window._singleFile_localStorage = window.localStorage;
|
|
|
+ window.__defineGetter__("localStorage", () => { throw new Error("localStorage temporary blocked by SingleFile"); });
|
|
|
+ }
|
|
|
+ if (!window._singleFile_indexedDB) {
|
|
|
+ window._singleFile_indexedDB = window.indexedDB;
|
|
|
+ window.__defineGetter__("indexedDB", () => { throw new Error("indexedDB temporary blocked by SingleFile"); });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ addEventListener(BLOCK_COOKIES_END_EVENT, () => {
|
|
|
+ delete document.cookie;
|
|
|
if (window._singleFile_localStorage) {
|
|
|
delete window.localStorage;
|
|
|
window.localStorage = window._singleFile_localStorage;
|
|
|
@@ -157,13 +173,6 @@
|
|
|
window.indexedDB = window._singleFile_indexedDB;
|
|
|
delete window._singleFile_indexedDB;
|
|
|
}
|
|
|
- if (window._singleFileImage) {
|
|
|
- delete window.Image;
|
|
|
- window.Image = window._singleFileImage;
|
|
|
- delete window._singleFileImage;
|
|
|
- }
|
|
|
- dispatchEvent(new UIEvent("resize"));
|
|
|
- dispatchEvent(new UIEvent("scroll"));
|
|
|
});
|
|
|
|
|
|
addEventListener(LOAD_DEFERRED_IMAGES_START_EVENT, () => {
|