瀏覽代碼

fixed issue with embedded tweets containing a scrollbar

Gildas 6 年之前
父節點
當前提交
f4bebc84e9
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      lib/single-file/single-file-core.js

+ 9 - 1
lib/single-file/single-file-core.js

@@ -197,6 +197,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			await this.processor.finalize();
 		}
 
+		getDocument() {
+			return this.processor.doc;
+		}
+
 		async getPageData() {
 			if (this.root) {
 				this.onprogress(new ProgressEvent(PAGE_ENDED, { pageURL: this.options.url }));
@@ -507,7 +511,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 						frameElement.setAttribute("style", "all:initial!important;border:0!important;width:100%!important;height:" + elementInfo.height + "px!important");
 						const windowId = "shadow-" + this.options.framesData.length;
 						frameElement.setAttribute(docUtil.WIN_ID_ATTRIBUTE_NAME, windowId);
-						this.options.framesData.push({ windowId, content: elementInfo.content, baseURI: this.baseURI });
+						this.options.framesData.push({ windowId, content: elementInfo.content, baseURI: this.baseURI, shadowRootContent: true });
 						element.appendChild(frameElement);
 					}
 				});
@@ -998,6 +1002,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 							if (frameData.processor) {
 								this.stats.add("processed", "frames", 1);
 								await frameData.processor.run();
+								if (frameData.shadowRootContent) {
+									const frameDoc = frameData.processor.getDocument();
+									frameDoc.documentElement.setAttribute("style", "overflow:hidden");
+								}
 								const pageData = await frameData.processor.getPageData();
 								frameElement.removeAttribute(docUtil.WIN_ID_ATTRIBUTE_NAME);
 								if (pageData.content.match(NOSCRIPT_TAG_FOUND) || pageData.content.match(SCRIPT_TAG_FOUND)) {