Просмотр исходного кода

block cookie and localStorage while loading deferred images to block popups

Gildas 7 лет назад
Родитель
Сommit
46b67a2677
2 измененных файлов с 7 добавлено и 0 удалено
  1. 4 0
      lib/lazy/web/web-lazy-loader-after.js
  2. 3 0
      lib/lazy/web/web-lazy-loader-before.js

+ 4 - 0
lib/lazy/web/web-lazy-loader-after.js

@@ -33,6 +33,10 @@
 		delete window._singleFile_getBoundingClientRect;
 		delete window._singleFile_getBoundingClientRect;
 		delete window._singleFile_innerHeight;
 		delete window._singleFile_innerHeight;
 		delete window._singleFile_innerWidth;
 		delete window._singleFile_innerWidth;
+		delete document.cookie;
+		delete window.localStorage;
+		window.localStorage = window._singleFile_localStorage;
+		delete window._singleFile_localStorage;
 	}
 	}
 	dispatchEvent(new UIEvent("resize"));
 	dispatchEvent(new UIEvent("resize"));
 	dispatchEvent(new UIEvent("scroll"));
 	dispatchEvent(new UIEvent("scroll"));

+ 3 - 0
lib/lazy/web/web-lazy-loader-before.js

@@ -42,6 +42,9 @@
 		}
 		}
 		return boundingRect;
 		return boundingRect;
 	};
 	};
+	window._singleFile_localStorage = window.localStorage;
+	window.__defineGetter__("localStorage", () => { throw new Error("localStorage temporary blocked by SingleFile"); });
+	document.__defineGetter__("cookie", () => { throw new Error("document.cookie temporary blocked by SingleFile"); });
 	dispatchEvent(new UIEvent("resize"));
 	dispatchEvent(new UIEvent("resize"));
 	dispatchEvent(new UIEvent("scroll"));
 	dispatchEvent(new UIEvent("scroll"));
 	dispatchEvent(new CustomEvent(LOAD_OBSERVED_ELEMENTS_EVENT));
 	dispatchEvent(new CustomEvent(LOAD_OBSERVED_ELEMENTS_EVENT));