1
0
Эх сурвалжийг харах

fix link to original video

Gildas 3 жил өмнө
parent
commit
206374a39f

+ 7 - 2
src/single-file/single-file-core.js

@@ -689,7 +689,8 @@ class Processor {
 		this.doc.querySelectorAll("video").forEach(videoElement => {
 			const attributeValue = videoElement.getAttribute(util.VIDEO_ATTRIBUTE_NAME);
 			if (attributeValue) {
-				const src = this.options.videos[Number(attributeValue)] || videoElement.src;
+				const videoData = this.options.videos[Number(attributeValue)];
+				const src = videoData.src || videoElement.src;
 				if (videoElement && src) {
 					const linkElement = this.doc.createElement("a");
 					const imgElement = this.doc.createElement("img");
@@ -698,7 +699,7 @@ class Processor {
 					linkElement.style.setProperty("z-index", 2147483647, "important");
 					linkElement.style.setProperty("position", "absolute", "important");
 					linkElement.style.setProperty("top", "8px", "important");
-					linkElement.style.setProperty("right", "8px", "important");
+					linkElement.style.setProperty("left", "8px", "important");
 					linkElement.style.setProperty("width", ICON_SIZE, "important");
 					linkElement.style.setProperty("height", ICON_SIZE, "important");
 					linkElement.style.setProperty("min-width", ICON_SIZE, "important");
@@ -714,6 +715,10 @@ class Processor {
 					imgElement.style.setProperty("max-height", ICON_SIZE, "important");
 					linkElement.appendChild(imgElement);
 					videoElement.insertAdjacentElement("afterend", linkElement);
+					const positionInlineParent = videoElement.parentNode.style.getPropertyValue("position");
+					if ((!videoData.positionParent && (!positionInlineParent || positionInlineParent != "static")) || videoData.positionParent == "static") {
+						videoElement.parentNode.style.setProperty("position", "relative", "important");
+					}
 				}
 			}
 		});

+ 4 - 2
src/single-file/single-file-helper.js

@@ -274,8 +274,10 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
 		}
 	}
 	if (element.tagName == "VIDEO") {
-		if (element.currentSrc) {
-			data.videos.push(element.currentSrc);
+		const src = element.currentSrc;
+		if (src && !src.startsWith("blob:") && !src.startsWith("data:")) {
+			const positionParent = win.getComputedStyle(element.parentNode).getPropertyValue("position");
+			data.videos.push({ positionParent, src });
 			element.setAttribute(VIDEO_ATTRIBUTE_NAME, data.videos.length - 1);
 		}
 		if (!element.poster) {