Skip to content

Instantly share code, notes, and snippets.

@kxxoling
Created October 12, 2018 08:08
Show Gist options
  • Save kxxoling/72f6763c60f8e6fc893648d0fb8307b6 to your computer and use it in GitHub Desktop.
Save kxxoling/72f6763c60f8e6fc893648d0fb8307b6 to your computer and use it in GitHub Desktop.
document.querySelectorAll(".diff-table").forEach(table => {
table.onmouseover = evt => {
if (evt.target.tagName !== "TD") {
return;
}
const cellIndex = evt.target.cellIndex;
table
.querySelectorAll(`tr td.blob-code:nth-child(${cellIndex === 1 ? 2 : 4})`)
.forEach(el => {
el.style["userSelect"] = "auto";
});
table
.querySelectorAll(`tr td.blob-code:nth-child(${cellIndex === 1 ? 4 : 2})`)
.forEach(el => {
el.style["userSelect"] = "none";
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment