-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbucket.js
33 lines (26 loc) · 1.44 KB
/
bitbucket.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const buildsSummarySection = document.querySelector(`div[data-testid="expanded-BuildStatus"]`);
const addBuildLinks = () => {
const buildLinks = buildsSummarySection.getElementsByTagName('a');
for (let buildLink of buildLinks) {
const isBambooLink = !!buildLink.pathname.match(/([0-9A-Z]+-[0-9A-Z]+-[0-9A-Z]+)/g);
if (isBambooLink) {
const linkClassName = "gimme-logs-link";
const buildSummary = buildLink.parentNode.parentNode.parentNode;
const __elementsOrNullWithLink = buildSummary.getElementsByClassName(linkClassName);
const hasGimmeLogsLink = __elementsOrNullWithLink && __elementsOrNullWithLink.length > 0
// Prevent infinite looping with appending a child to what is being observed for mutations
if (!hasGimmeLogsLink) {
const link = document.createElement("a");
link.href = `${buildLink.href + '/log'}`;
link.className = linkClassName
link.style.marginLeft = 'auto'
link.style.textAlign = 'center'
link.innerHTML = `🪵 LOGS`;
buildSummary.appendChild(link);
}
}
}
};
const buildsSummaryMutationObserverConfig = { childList: true, subtree: true };
const buildsSummaryMutationObserver = new MutationObserver(addBuildLinks);
buildsSummaryMutationObserver.observe(buildsSummarySection, buildsSummaryMutationObserverConfig);