single-file-core 1.6.29 → 1.6.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/helper.js
CHANGED
|
@@ -80,6 +80,7 @@ const INVOKERS_SELECTOR = INVOKER_ATTRIBUTE_NAMES.map(attributeName => "[" + att
|
|
|
80
80
|
const IGNORED_TAG_NAMES = ["SCRIPT", "NOSCRIPT", "META", "LINK", "TEMPLATE"];
|
|
81
81
|
const ROOT_PSEUDO_ELEMENT_NAMES = [":before", ":after"];
|
|
82
82
|
const BLOCK_CONTAINER_DISPLAY_VALUES = ["block", "flow-root", "list-item", "inline-block", "table-cell", "table-caption"];
|
|
83
|
+
const BLOCK_LEVEL_DISPLAY_VALUES = ["block", "flow-root", "list-item", "flex", "grid", "table"];
|
|
83
84
|
const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
|
|
84
85
|
const REGEXP_DOUBLE_QUOTES_STRING = /^"(.*?)"$/;
|
|
85
86
|
const FONT_WEIGHTS = {
|
|
@@ -975,9 +976,11 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
|
|
|
975
976
|
if (tagName == "VIDEO") {
|
|
976
977
|
const src = element.currentSrc;
|
|
977
978
|
if (src && !src.startsWith("blob:") && !src.startsWith("data:")) {
|
|
978
|
-
const computedStyle = getComputedStyle(win, element
|
|
979
|
+
const computedStyle = getComputedStyle(win, element);
|
|
980
|
+
const blockLevel = Boolean(computedStyle) && BLOCK_LEVEL_DISPLAY_VALUES.includes(computedStyle.getPropertyValue("display"));
|
|
979
981
|
data.videos.push({
|
|
980
|
-
|
|
982
|
+
blockLevel,
|
|
983
|
+
linkOffset: getVideoLinkOffset(doc, element, blockLevel),
|
|
981
984
|
src,
|
|
982
985
|
size: {
|
|
983
986
|
pxWidth: element.clientWidth,
|
|
@@ -1513,6 +1516,29 @@ function flatten(array) {
|
|
|
1513
1516
|
return array.flat ? array.flat() : array.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
|
|
1514
1517
|
}
|
|
1515
1518
|
|
|
1519
|
+
function getVideoLinkOffset(doc, element, blockLevel) {
|
|
1520
|
+
const offset = { top: 0, left: 0 };
|
|
1521
|
+
if (element.parentNode) {
|
|
1522
|
+
const probeElement = doc.createElement("a");
|
|
1523
|
+
probeElement.style.setProperty("position", "absolute", "important");
|
|
1524
|
+
probeElement.style.setProperty("margin", "0", "important");
|
|
1525
|
+
probeElement.style.setProperty("padding", "0", "important");
|
|
1526
|
+
probeElement.style.setProperty("border", "0", "important");
|
|
1527
|
+
probeElement.style.setProperty("width", "0", "important");
|
|
1528
|
+
probeElement.style.setProperty("height", "0", "important");
|
|
1529
|
+
if (blockLevel) {
|
|
1530
|
+
probeElement.style.setProperty("display", "block", "important");
|
|
1531
|
+
}
|
|
1532
|
+
element.insertAdjacentElement("beforebegin", probeElement);
|
|
1533
|
+
const probeRect = probeElement.getBoundingClientRect();
|
|
1534
|
+
const elementRect = element.getBoundingClientRect();
|
|
1535
|
+
offset.top = Math.round(elementRect.top - probeRect.top);
|
|
1536
|
+
offset.left = Math.round(elementRect.left - probeRect.left);
|
|
1537
|
+
probeElement.remove();
|
|
1538
|
+
}
|
|
1539
|
+
return offset;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1516
1542
|
function getComputedStyle(win, element, pseudoElement) {
|
|
1517
1543
|
try {
|
|
1518
1544
|
return win.getComputedStyle(element, pseudoElement);
|
package/core/index.js
CHANGED
|
@@ -903,15 +903,18 @@ class Processor {
|
|
|
903
903
|
if (attributeValue) {
|
|
904
904
|
const videoData = this.options.videos[Number(attributeValue)];
|
|
905
905
|
const src = (videoData && videoData.src) || videoElement.src;
|
|
906
|
-
if (
|
|
906
|
+
if (src) {
|
|
907
907
|
const linkElement = this.doc.createElement("a");
|
|
908
908
|
const imgElement = this.doc.createElement("img");
|
|
909
|
+
const linkOffset = (videoData && videoData.linkOffset) || { top: 0, left: 0 };
|
|
909
910
|
linkElement.href = src;
|
|
910
911
|
linkElement.target = "_blank";
|
|
911
912
|
linkElement.style.setProperty("z-index", 2147483647, "important");
|
|
912
913
|
linkElement.style.setProperty("position", "absolute", "important");
|
|
913
|
-
linkElement.style.setProperty("
|
|
914
|
-
|
|
914
|
+
linkElement.style.setProperty("margin", (linkOffset.top + 8) + "px 0 0 " + (linkOffset.left + 8) + "px", "important");
|
|
915
|
+
if (videoData && videoData.blockLevel) {
|
|
916
|
+
linkElement.style.setProperty("display", "block", "important");
|
|
917
|
+
}
|
|
915
918
|
linkElement.style.setProperty("width", ICON_SIZE, "important");
|
|
916
919
|
linkElement.style.setProperty("height", ICON_SIZE, "important");
|
|
917
920
|
linkElement.style.setProperty("min-width", ICON_SIZE, "important");
|
|
@@ -926,11 +929,7 @@ class Processor {
|
|
|
926
929
|
imgElement.style.setProperty("max-width", ICON_SIZE, "important");
|
|
927
930
|
imgElement.style.setProperty("max-height", ICON_SIZE, "important");
|
|
928
931
|
linkElement.appendChild(imgElement);
|
|
929
|
-
videoElement.insertAdjacentElement("
|
|
930
|
-
const positionInlineParent = videoElement.parentNode.style.getPropertyValue("position");
|
|
931
|
-
if ((!videoData.positionParent && (!positionInlineParent || positionInlineParent != "static")) || videoData.positionParent == "static") {
|
|
932
|
-
videoElement.parentNode.style.setProperty("position", "relative", "important");
|
|
933
|
-
}
|
|
932
|
+
videoElement.insertAdjacentElement("beforebegin", linkElement);
|
|
934
933
|
}
|
|
935
934
|
}
|
|
936
935
|
});
|
package/core/infobar.js
CHANGED
|
@@ -233,6 +233,9 @@ function appendInfobar(doc, options, useShadowRoot) {
|
|
|
233
233
|
infoData = infoData || "No info";
|
|
234
234
|
const parentElement = doc.body.tagName == "BODY" ? doc.body : doc.documentElement;
|
|
235
235
|
const infobarElement = createElement(doc, INFOBAR_TAGNAME, parentElement);
|
|
236
|
+
const hostStyleElement = doc.createElement("style");
|
|
237
|
+
hostStyleElement.textContent = `${INFOBAR_TAGNAME}::before,${INFOBAR_TAGNAME}::after{content:none !important}`;
|
|
238
|
+
infobarElement.appendChild(hostStyleElement);
|
|
236
239
|
let infobarContainer;
|
|
237
240
|
if (useShadowRoot) {
|
|
238
241
|
infobarContainer = infobarElement.attachShadow({ mode: "open" });
|
package/package.json
CHANGED
|
@@ -104,7 +104,9 @@ if (TOP_WINDOW) {
|
|
|
104
104
|
return Promise.resolve({});
|
|
105
105
|
} else if (message.method == GET_OPTIONS_MESSAGE) {
|
|
106
106
|
const session = sessions.get(message.sessionId);
|
|
107
|
-
|
|
107
|
+
if (session) {
|
|
108
|
+
return Promise.resolve({ options: session.options });
|
|
109
|
+
}
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
}
|