Skip to content

Instantly share code, notes, and snippets.

@alejandrocoding
Last active June 24, 2020 18:11
Show Gist options
  • Save alejandrocoding/f072191220f9d928e75041749ca222f7 to your computer and use it in GitHub Desktop.
Save alejandrocoding/f072191220f9d928e75041749ca222f7 to your computer and use it in GitHub Desktop.
Content script adding p element to show latest commit
try {
const authorAnchor = document.querySelector('.commit-author') as HTMLAnchorElement;
const commit = (authorAnchor.nextElementSibling as HTMLAnchorElement).href.split('commit/')[1];
const p = document.createElement('p');
p.classList.add('my-commit-msg');
p.innerText = `Latest commit was: ${commit}`;
anchorMyBtn.parentNode.parentNode.prepend(p);
} catch {
console.error('Error retrieving last commit');
}
.my-commit-msg {
text-align: center;
padding: 10px;
margin-bottom: 25px;
border: 1px solid transparent;
border-radius: 5px;
background-color: aquamarine;
color: #333;
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment