Skip to content

Commit

Permalink
Remove unused load detection
Browse files Browse the repository at this point in the history
Suggested by: John Bieling (a reviewer)
  • Loading branch information
moisseev committed Jun 25, 2023
1 parent c1aea10 commit b71492a
Showing 1 changed file with 39 additions and 47 deletions.
86 changes: 39 additions & 47 deletions experiments/displayReceivedHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,51 @@ var displayReceivedHeader = class extends ExtensionCommon.ExtensionAPI {
}

function addHeadersToWindowById(windowId, tabIndex) {
function addHeaders(document) {
const expandedHeaders2 = document
.getElementById(majorVersion < 100 ? "expandedHeaders2" : "extraHeadersArea");

if (expandedHeaders2) {
const element = document.createElement(majorVersion < 100 ? "tr" : "div");
element.hidden = true;
element.id = "expandedReceivedRow";
element.classList.add("message-header-row");

const headerRowTitleLabel = document.createXULElement("label");
headerRowTitleLabel.id = "expandedReceivedLabel";
headerRowTitleLabel.classList.add(majorVersion < 100
? "headerName"
: "message-header-label");
headerRowTitleLabel.value = "Received";
headerRowTitleLabel.control = "receivedReceivedHeader";

if (majorVersion < 100) {
const headerRowTitle = document.createElement("th");
headerRowTitle.appendChild(headerRowTitleLabel);
element.appendChild(headerRowTitle);
} else {
element.appendChild(headerRowTitleLabel);
}
const document = getDocumentByTabIndex(windowId, tabIndex);
const expandedHeaders2 = document
.getElementById(majorVersion < 100 ? "expandedHeaders2" : "extraHeadersArea");

if (expandedHeaders2) {
const element = document.createElement(majorVersion < 100 ? "tr" : "div");
element.hidden = true;
element.id = "expandedReceivedRow";
element.classList.add("message-header-row");

const headerRowTitleLabel = document.createXULElement("label");
headerRowTitleLabel.id = "expandedReceivedLabel";
headerRowTitleLabel.classList.add(majorVersion < 100
? "headerName"
: "message-header-label");
headerRowTitleLabel.value = "Received";
headerRowTitleLabel.control = "receivedReceivedHeader";

if (majorVersion < 100) {
const headerRowTitle = document.createElement("th");
headerRowTitle.appendChild(headerRowTitleLabel);
element.appendChild(headerRowTitle);
} else {
element.appendChild(headerRowTitleLabel);
}

const expandedReceivedBox = document.createElement("div");
expandedReceivedBox.id = "expandedReceivedBox";
const expandedReceivedBox = document.createElement("div");
expandedReceivedBox.id = "expandedReceivedBox";

const headerRowValue = document.createElement("div");
headerRowValue.id = "receivedReceivedHeader";
const headerRowValue = document.createElement("div");
headerRowValue.id = "receivedReceivedHeader";

expandedReceivedBox.appendChild(headerRowValue);
element.appendChild(expandedReceivedBox);
expandedHeaders2.appendChild(element);
expandedReceivedBox.appendChild(headerRowValue);
element.appendChild(expandedReceivedBox);
expandedHeaders2.appendChild(element);

if (majorVersion >= 100) {
expandedReceivedBox.addEventListener("contextmenu", (event) => {
const popup = document.getElementById("simpleCopyPopup");
popup.headerField = event.target;
popup.openPopupAtScreen(event.screenX, event.screenY, true);
});
}
} else {
throw Error("Could not find the expandedHeaders2 element");
if (majorVersion >= 100) {
expandedReceivedBox.addEventListener("contextmenu", (event) => {
const popup = document.getElementById("simpleCopyPopup");
popup.headerField = event.target;
popup.openPopupAtScreen(event.screenX, event.screenY, true);
});
}
}

const document = getDocumentByTabIndex(windowId, tabIndex);
if (majorVersion < 111 || document.readyState === "complete") {
addHeaders(document);
} else {
document.onload = () => addHeaders(document);
throw Error("Could not find the expandedHeaders2 element");
}
}

Expand Down

0 comments on commit b71492a

Please sign in to comment.