| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671 |
- /*
- * Copyright 2010-2020 Gildas Lormeau
- * contact : gildas.lormeau <at> gmail.com
- *
- * This file is part of SingleFile.
- *
- * The code in this file is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * (GNU AGPL) as published by the Free Software Foundation, either version 3
- * of the License, or (at your option) any later version.
- *
- * The code in this file is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
- * General Public License for more details.
- *
- * As additional permission under GNU AGPL version 3 section 7, you may
- * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
- * AGPL normally required by section 4, provided you include this license
- * notice and a URL through which recipients can access the Corresponding
- * Source.
- */
- /* global browser, document, globalThis, prompt, getComputedStyle, addEventListener, removeEventListener, requestAnimationFrame, setTimeout, getSelection, Node */
- const singlefile = globalThis.singlefile;
- const SELECTED_CONTENT_ATTRIBUTE_NAME = singlefile.helper.SELECTED_CONTENT_ATTRIBUTE_NAME;
- const MASK_TAGNAME = "singlefile-mask";
- const MASK_CONTENT_CLASSNAME = "singlefile-mask-content";
- const PROGRESSBAR_CLASSNAME = "singlefile-progress-bar";
- const PROGRESSBAR_CONTENT_CLASSNAME = "singlefile-progress-bar-content";
- const SELECTION_ZONE_TAGNAME = "single-file-selection-zone";
- const LOGS_WINDOW_TAGNAME = "singlefile-logs-window";
- const LOGS_CLASSNAME = "singlefile-logs";
- const LOGS_LINE_CLASSNAME = "singlefile-logs-line";
- const LOGS_LINE_TEXT_ELEMENT_CLASSNAME = "singlefile-logs-line-text";
- const LOGS_LINE_STATUS_ELEMENT_CLASSNAME = "singlefile-logs-line-icon";
- const SINGLE_FILE_UI_ELEMENT_CLASS = singlefile.helper.SINGLE_FILE_UI_ELEMENT_CLASS;
- const SELECT_PX_THRESHOLD = 8;
- const LOG_PANEL_DEFERRED_IMAGES_MESSAGE = browser.i18n.getMessage("logPanelDeferredImages");
- const LOG_PANEL_FRAME_CONTENTS_MESSAGE = browser.i18n.getMessage("logPanelFrameContents");
- const LOG_PANEL_EMBEDDED_IMAGE_MESSAGE = browser.i18n.getMessage("logPanelEmbeddedImage");
- const LOG_PANEL_STEP_MESSAGE = browser.i18n.getMessage("logPanelStep");
- const LOG_PANEL_WIDTH = browser.i18n.getMessage("logPanelWidth");
- const CSS_PROPERTIES = new Set(Array.from(getComputedStyle(document.documentElement)));
- let selectedAreaElement, logsWindowElement;
- createLogsWindowElement();
- export {
- getSelectedLinks,
- markSelection,
- unmarkSelection,
- promptMessage as prompt,
- setVisible,
- onStartPage,
- onEndPage,
- onLoadResource,
- onInsertingEmbeddedImage,
- onInsertEmbeddedImage,
- onLoadingDeferResources,
- onLoadDeferResources,
- onLoadingFrames,
- onLoadFrames,
- onStartStage,
- onEndStage,
- onPageLoading,
- onLoadPage,
- onStartStageTask,
- onEndStageTask
- };
- function promptMessage(message, defaultValue) {
- return prompt(message, defaultValue);
- }
- function setVisible(visible) {
- const maskElement = document.querySelector(MASK_TAGNAME);
- if (maskElement) {
- maskElement.style.setProperty("display", visible ? "block" : "none");
- }
- if (logsWindowElement) {
- logsWindowElement.style.setProperty("display", visible ? "block" : "none");
- }
- }
- function onStartPage(options) {
- let maskElement = document.querySelector(MASK_TAGNAME);
- if (!maskElement) {
- if (options.logsEnabled) {
- document.documentElement.appendChild(logsWindowElement);
- }
- if (options.shadowEnabled) {
- const maskElement = createMaskElement();
- if (options.progressBarEnabled) {
- createProgressBarElement(maskElement);
- }
- }
- }
- }
- function onEndPage() {
- const maskElement = document.querySelector(MASK_TAGNAME);
- if (maskElement) {
- maskElement.remove();
- }
- logsWindowElement.remove();
- clearLogs();
- }
- function onLoadResource(index, maxIndex, options) {
- if (options.shadowEnabled && options.progressBarEnabled) {
- updateProgressBar(index, maxIndex);
- }
- }
- function onLoadingDeferResources(options) {
- updateLog("load-deferred-images", LOG_PANEL_DEFERRED_IMAGES_MESSAGE, "…", options);
- }
- function onLoadDeferResources(options) {
- updateLog("load-deferred-images", LOG_PANEL_DEFERRED_IMAGES_MESSAGE, "✓", options);
- }
- function onInsertingEmbeddedImage(options) {
- updateLog("insert-embedded-image", LOG_PANEL_EMBEDDED_IMAGE_MESSAGE, "…", options);
- }
- function onInsertEmbeddedImage(options) {
- updateLog("insert-embedded-image", LOG_PANEL_EMBEDDED_IMAGE_MESSAGE, "✓", options);
- }
- function onLoadingFrames(options) {
- updateLog("load-frames", LOG_PANEL_FRAME_CONTENTS_MESSAGE, "…", options);
- }
- function onLoadFrames(options) {
- updateLog("load-frames", LOG_PANEL_FRAME_CONTENTS_MESSAGE, "✓", options);
- }
- function onStartStage(step, options) {
- updateLog("step-" + step, `${LOG_PANEL_STEP_MESSAGE} ${step + 1} / 3`, "…", options);
- }
- function onEndStage(step, options) {
- updateLog("step-" + step, `${LOG_PANEL_STEP_MESSAGE} ${step + 1} / 3`, "✓", options);
- }
- function onPageLoading() { }
- function onLoadPage() { }
- function onStartStageTask() { }
- function onEndStageTask() { }
- function getSelectedLinks() {
- let selectionFound;
- const links = [];
- const selection = getSelection();
- for (let indexRange = 0; indexRange < selection.rangeCount; indexRange++) {
- let range = selection.getRangeAt(indexRange);
- if (range && range.commonAncestorContainer) {
- const treeWalker = document.createTreeWalker(range.commonAncestorContainer);
- let rangeSelectionFound = false;
- let finished = false;
- while (!finished) {
- if (rangeSelectionFound || treeWalker.currentNode == range.startContainer || treeWalker.currentNode == range.endContainer) {
- rangeSelectionFound = true;
- if (range.startContainer != range.endContainer || range.startOffset != range.endOffset) {
- selectionFound = true;
- if (treeWalker.currentNode.tagName == "A" && treeWalker.currentNode.href) {
- links.push(treeWalker.currentNode.href);
- }
- }
- }
- if (treeWalker.currentNode == range.endContainer) {
- finished = true;
- } else {
- treeWalker.nextNode();
- }
- }
- if (selectionFound && treeWalker.currentNode == range.endContainer && treeWalker.currentNode.querySelectorAll) {
- treeWalker.currentNode.querySelectorAll("*").forEach(descendantElement => {
- if (descendantElement.tagName == "A" && descendantElement.href) {
- links.push(treeWalker.currentNode.href);
- }
- });
- }
- }
- }
- return Array.from(new Set(links));
- }
- async function markSelection(optionallySelected) {
- let selectionFound = markSelectedContent();
- if (selectionFound || optionallySelected) {
- return selectionFound;
- } else {
- selectionFound = await selectArea();
- if (selectionFound) {
- return markSelectedContent();
- }
- }
- }
- function markSelectedContent() {
- const selection = getSelection();
- let selectionFound;
- for (let indexRange = 0; indexRange < selection.rangeCount; indexRange++) {
- let range = selection.getRangeAt(indexRange);
- if (range && range.commonAncestorContainer) {
- const treeWalker = document.createTreeWalker(range.commonAncestorContainer);
- let rangeSelectionFound = false;
- let finished = false;
- while (!finished) {
- if (rangeSelectionFound || treeWalker.currentNode == range.startContainer || treeWalker.currentNode == range.endContainer) {
- rangeSelectionFound = true;
- if (range.startContainer != range.endContainer || range.startOffset != range.endOffset) {
- selectionFound = true;
- markSelectedNode(treeWalker.currentNode);
- }
- }
- if (selectionFound && treeWalker.currentNode == range.startContainer) {
- markSelectedParents(treeWalker.currentNode);
- }
- if (treeWalker.currentNode == range.endContainer) {
- finished = true;
- } else {
- treeWalker.nextNode();
- }
- }
- if (selectionFound && treeWalker.currentNode == range.endContainer && treeWalker.currentNode.querySelectorAll) {
- for (
- let offset = range.startContainer === range.endContainer ? range.startOffset : 0;
- offset < range.endOffset;
- offset++
- ) {
- const node = range.endContainer.childNodes[offset];
- if (node) {
- markSelectedNode(node);
- if (node.querySelectorAll) {
- node.querySelectorAll("*").forEach(markSelectedNode);
- }
- }
- }
- }
- }
- }
- return selectionFound;
- }
- function markSelectedNode(node) {
- const element = node.nodeType == Node.ELEMENT_NODE ? node : node.parentElement;
- element.setAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME, "");
- }
- function markSelectedParents(node) {
- if (node.parentElement) {
- markSelectedNode(node);
- markSelectedParents(node.parentElement);
- }
- }
- function unmarkSelection() {
- document.querySelectorAll("[" + SELECTED_CONTENT_ATTRIBUTE_NAME + "]").forEach(selectedContent => selectedContent.removeAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME));
- }
- function selectArea() {
- return new Promise(resolve => {
- let selectedRanges = [];
- addEventListener("mousemove", mousemoveListener, true);
- addEventListener("click", clickListener, true);
- addEventListener("keyup", keypressListener, true);
- document.addEventListener("contextmenu", contextmenuListener, true);
- getSelection().removeAllRanges();
- function contextmenuListener(event) {
- selectedRanges = [];
- select();
- event.preventDefault();
- }
- function mousemoveListener(event) {
- const targetElement = getTarget(event);
- if (targetElement) {
- selectedAreaElement = targetElement;
- moveAreaSelector(targetElement);
- }
- }
- function clickListener(event) {
- event.preventDefault();
- event.stopPropagation();
- if (event.button == 0) {
- select(selectedAreaElement, event.ctrlKey);
- } else {
- cancel();
- }
- }
- function keypressListener(event) {
- if (event.key == "Escape") {
- cancel();
- }
- }
- function cancel() {
- if (selectedRanges.length) {
- getSelection().removeAllRanges();
- }
- selectedRanges = [];
- cleanupAndResolve();
- }
- function select(selectedElement, multiSelect) {
- if (selectedElement) {
- if (!multiSelect) {
- restoreSelectedRanges();
- }
- const range = document.createRange();
- range.selectNodeContents(selectedElement);
- cleanupSelectionRanges();
- getSelection().addRange(range);
- saveSelectedRanges();
- if (!multiSelect) {
- cleanupAndResolve();
- }
- } else {
- cleanupAndResolve();
- }
- }
- function cleanupSelectionRanges() {
- const selection = getSelection();
- for (let indexRange = selection.rangeCount - 1; indexRange >= 0; indexRange--) {
- const range = selection.getRangeAt(indexRange);
- if (range.startOffset == range.endOffset) {
- selection.removeRange(range);
- indexRange--;
- }
- }
- }
- function cleanupAndResolve() {
- getAreaSelector().remove();
- removeEventListener("mousemove", mousemoveListener, true);
- removeEventListener("click", clickListener, true);
- removeEventListener("keyup", keypressListener, true);
- selectedAreaElement = null;
- resolve(Boolean(selectedRanges.length));
- setTimeout(() => document.removeEventListener("contextmenu", contextmenuListener, true), 0);
- }
- function restoreSelectedRanges() {
- getSelection().removeAllRanges();
- selectedRanges.forEach(range => getSelection().addRange(range));
- }
- function saveSelectedRanges() {
- selectedRanges = [];
- for (let indexRange = 0; indexRange < getSelection().rangeCount; indexRange++) {
- const range = getSelection().getRangeAt(indexRange);
- selectedRanges.push(range);
- }
- }
- });
- }
- function getTarget(event) {
- let newTarget, target = event.target, boundingRect = target.getBoundingClientRect();
- newTarget = determineTargetElement("floor", target, event.clientX - boundingRect.left, getMatchedParents(target, "left"));
- if (newTarget == target) {
- newTarget = determineTargetElement("ceil", target, boundingRect.left + boundingRect.width - event.clientX, getMatchedParents(target, "right"));
- }
- if (newTarget == target) {
- newTarget = determineTargetElement("floor", target, event.clientY - boundingRect.top, getMatchedParents(target, "top"));
- }
- if (newTarget == target) {
- newTarget = determineTargetElement("ceil", target, boundingRect.top + boundingRect.height - event.clientY, getMatchedParents(target, "bottom"));
- }
- target = newTarget;
- while (target && target.clientWidth <= SELECT_PX_THRESHOLD && target.clientHeight <= SELECT_PX_THRESHOLD) {
- target = target.parentElement;
- }
- return target;
- }
- function moveAreaSelector(target) {
- requestAnimationFrame(() => {
- const selectorElement = getAreaSelector();
- const boundingRect = target.getBoundingClientRect();
- const scrollingElement = document.scrollingElement || document.documentElement;
- selectorElement.style.setProperty("top", (scrollingElement.scrollTop + boundingRect.top - 10) + "px");
- selectorElement.style.setProperty("left", (scrollingElement.scrollLeft + boundingRect.left - 10) + "px");
- selectorElement.style.setProperty("width", (boundingRect.width + 20) + "px");
- selectorElement.style.setProperty("height", (boundingRect.height + 20) + "px");
- });
- }
- function getAreaSelector() {
- let selectorElement = document.querySelector(SELECTION_ZONE_TAGNAME);
- if (!selectorElement) {
- selectorElement = createElement(SELECTION_ZONE_TAGNAME, document.body);
- selectorElement.style.setProperty("box-sizing", "border-box", "important");
- selectorElement.style.setProperty("background-color", "#3ea9d7", "important");
- selectorElement.style.setProperty("border", "10px solid #0b4892", "important");
- selectorElement.style.setProperty("border-radius", "2px", "important");
- selectorElement.style.setProperty("opacity", ".25", "important");
- selectorElement.style.setProperty("pointer-events", "none", "important");
- selectorElement.style.setProperty("position", "absolute", "important");
- selectorElement.style.setProperty("transition", "all 100ms", "important");
- selectorElement.style.setProperty("cursor", "pointer", "important");
- selectorElement.style.setProperty("z-index", "2147483647", "important");
- selectorElement.style.removeProperty("border-inline-end");
- selectorElement.style.removeProperty("border-inline-start");
- selectorElement.style.removeProperty("inline-size");
- selectorElement.style.removeProperty("block-size");
- selectorElement.style.removeProperty("inset-block-start");
- selectorElement.style.removeProperty("inset-inline-end");
- selectorElement.style.removeProperty("inset-block-end");
- selectorElement.style.removeProperty("inset-inline-start");
- }
- return selectorElement;
- }
- function createMaskElement() {
- try {
- let maskElement = document.querySelector(MASK_TAGNAME);
- if (!maskElement) {
- maskElement = createElement(MASK_TAGNAME, document.documentElement);
- const shadowRoot = maskElement.attachShadow({ mode: "open" });
- const styleElement = document.createElement("style");
- styleElement.textContent = `
- @keyframes single-file-progress {
- 0% {
- left: -50px;
- }
- 100% {
- left: 0;
- }
- }
- .${PROGRESSBAR_CLASSNAME} {
- position: fixed;
- top: 0;
- left: 0;
- width: 0;
- height: 8px;
- z-index: 2147483646;
- opacity: .5;
- overflow: hidden;
- transition: width 200ms ease-in-out;
- }
- .${PROGRESSBAR_CONTENT_CLASSNAME} {
- position: absolute;
- left: 0;
- animation: single-file-progress 3s linear infinite reverse;
- background:
- white
- linear-gradient(-45deg, rgba(0, 0, 0, 0.075) 25%,
- transparent 25%,
- transparent 50%,
- rgba(0, 0, 0, 0.075) 50%,
- rgba(0, 0, 0, 0.075) 75%,
- transparent 75%, transparent)
- repeat scroll 0% 0% / 50px 50px padding-box border-box;
- width: calc(100% + 50px);
- height: 100%;
- }
- .${MASK_CONTENT_CLASSNAME} {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 2147483646;
- opacity: 0;
- background-color: black;
- transition: opacity 250ms;
- }
- `;
- shadowRoot.appendChild(styleElement);
- let maskElementContent = document.createElement("div");
- maskElementContent.classList.add(MASK_CONTENT_CLASSNAME);
- shadowRoot.appendChild(maskElementContent);
- maskElement.offsetWidth;
- maskElementContent.style.setProperty("opacity", .3);
- maskElement.offsetWidth;
- }
- return maskElement;
- } catch (error) {
- // ignored
- }
- }
- function createProgressBarElement(maskElement) {
- try {
- let progressBarElement = maskElement.shadowRoot.querySelector("." + PROGRESSBAR_CLASSNAME);
- if (!progressBarElement) {
- let progressBarContent = document.createElement("div");
- progressBarContent.classList.add(PROGRESSBAR_CLASSNAME);
- maskElement.shadowRoot.appendChild(progressBarContent);
- const progressBarContentElement = document.createElement("div");
- progressBarContentElement.classList.add(PROGRESSBAR_CONTENT_CLASSNAME);
- progressBarContent.appendChild(progressBarContentElement);
- }
- } catch (error) {
- // ignored
- }
- }
- function createLogsWindowElement() {
- try {
- logsWindowElement = document.querySelector(LOGS_WINDOW_TAGNAME);
- if (!logsWindowElement) {
- logsWindowElement = createElement(LOGS_WINDOW_TAGNAME);
- const shadowRoot = logsWindowElement.attachShadow({ mode: "open" });
- const styleElement = document.createElement("style");
- styleElement.textContent = `
- @keyframes single-file-pulse {
- 0% {
- opacity: .25;
- }
- 100% {
- opacity: 1;
- }
- }
- .${LOGS_CLASSNAME} {
- position: fixed;
- bottom: 24px;
- left: 8px;
- z-index: 2147483647;
- opacity: 0.9;
- padding: 4px;
- background-color: white;
- min-width: ${LOG_PANEL_WIDTH}px;
- min-height: 16px;
- transition: height 100ms;
- }
- .${LOGS_LINE_CLASSNAME} {
- display: flex;
- justify-content: space-between;
- padding: 2px;
- font-family: arial, sans-serif;
- color: black;
- background-color: white;
- }
- .${LOGS_LINE_TEXT_ELEMENT_CLASSNAME} {
- font-size: 13px;
- opacity: 1;
- transition: opacity 200ms;
- }
- .${LOGS_LINE_STATUS_ELEMENT_CLASSNAME} {
- font-size: 11px;
- min-width: 15px;
- text-align: center;
- position: relative;
- top: 1px;
- }
- `;
- shadowRoot.appendChild(styleElement);
- const logsContentElement = document.createElement("div");
- logsContentElement.classList.add(LOGS_CLASSNAME);
- shadowRoot.appendChild(logsContentElement);
- }
- } catch (error) {
- // ignored
- }
- }
- function updateLog(id, textContent, textStatus, options) {
- try {
- if (options.logsEnabled) {
- const logsContentElement = logsWindowElement.shadowRoot.querySelector("." + LOGS_CLASSNAME);
- let lineElement = logsContentElement.querySelector("[data-id='" + id + "']");
- if (!lineElement) {
- lineElement = document.createElement("div");
- lineElement.classList.add(LOGS_LINE_CLASSNAME);
- logsContentElement.appendChild(lineElement);
- lineElement.setAttribute("data-id", id);
- const textElement = document.createElement("div");
- textElement.classList.add(LOGS_LINE_TEXT_ELEMENT_CLASSNAME);
- lineElement.appendChild(textElement);
- textElement.textContent = textContent;
- const statusElement = document.createElement("div");
- statusElement.classList.add(LOGS_LINE_STATUS_ELEMENT_CLASSNAME);
- lineElement.appendChild(statusElement);
- }
- updateLogLine(lineElement, textContent, textStatus);
- }
- } catch (error) {
- // ignored
- }
- }
- function updateLogLine(lineElement, textContent, textStatus) {
- const textElement = lineElement.childNodes[0];
- const statusElement = lineElement.childNodes[1];
- textElement.textContent = textContent;
- statusElement.style.setProperty("color", textStatus == "✓" ? "#055000" : "black");
- if (textStatus == "✓") {
- textElement.style.setProperty("opacity", ".5");
- statusElement.style.setProperty("opacity", ".5");
- statusElement.style.setProperty("animation", "none");
- } else {
- statusElement.style.setProperty("animation", "1s ease-in-out 0s infinite alternate none running single-file-pulse");
- }
- statusElement.textContent = textStatus;
- }
- function updateProgressBar(index, maxIndex) {
- try {
- const maskElement = document.querySelector(MASK_TAGNAME);
- if (maskElement) {
- const progressBarElement = maskElement.shadowRoot.querySelector("." + PROGRESSBAR_CLASSNAME);
- if (progressBarElement && maxIndex) {
- const width = Math.floor((index / maxIndex) * 100) + "%";
- if (progressBarElement.style.getPropertyValue("width") != width) {
- progressBarElement.style.setProperty("width", width);
- progressBarElement.offsetWidth;
- }
- }
- }
- } catch (error) {
- // ignored
- }
- }
- function clearLogs() {
- createLogsWindowElement();
- }
- function getMatchedParents(target, property) {
- let element = target, matchedParent, parents = [];
- do {
- const boundingRect = element.getBoundingClientRect();
- if (element.parentElement) {
- const parentBoundingRect = element.parentElement.getBoundingClientRect();
- matchedParent = Math.abs(parentBoundingRect[property] - boundingRect[property]) <= SELECT_PX_THRESHOLD;
- if (matchedParent) {
- if (element.parentElement.clientWidth > SELECT_PX_THRESHOLD && element.parentElement.clientHeight > SELECT_PX_THRESHOLD &&
- ((element.parentElement.clientWidth - element.clientWidth > SELECT_PX_THRESHOLD) || (element.parentElement.clientHeight - element.clientHeight > SELECT_PX_THRESHOLD))) {
- parents.push(element.parentElement);
- }
- element = element.parentElement;
- }
- } else {
- matchedParent = false;
- }
- } while (matchedParent && element);
- return parents;
- }
- function determineTargetElement(roundingMethod, target, widthDistance, parents) {
- if (Math[roundingMethod](widthDistance / SELECT_PX_THRESHOLD) <= parents.length) {
- target = parents[parents.length - Math[roundingMethod](widthDistance / SELECT_PX_THRESHOLD) - 1];
- }
- return target;
- }
- function createElement(tagName, parentElement) {
- const element = document.createElement(tagName);
- element.className = SINGLE_FILE_UI_ELEMENT_CLASS;
- if (parentElement) {
- parentElement.appendChild(element);
- }
- CSS_PROPERTIES.forEach(property => element.style.setProperty(property, "initial", "important"));
- return element;
- }
|