Get the milestone when a merged Chromium Gerrit tab is active (#722)
This commit is contained in:
Родитель
afea3db429
Коммит
73ef3a90c7
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "Milestones",
|
||||
"version": "1.0",
|
||||
"manifest_version": 3,
|
||||
"action": {"default_popup": "popup.html"},
|
||||
"description": "Chromium Release Milestones",
|
||||
"host_permissions": [ "https://crrie.com/" ],
|
||||
"permissions": [ "activeTab" ]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<script src="popup.js"></script>
|
|
@ -0,0 +1,21 @@
|
|||
chrome.tabs.query({active: true}).then(tabs => getMilestone(tabs));
|
||||
|
||||
function getMilestone(tabs) {
|
||||
const div = document.createElement("div");
|
||||
document.body.appendChild(div);
|
||||
const url = tabs[0].url;
|
||||
const origin = 'https://chromium-review.googlesource.com';
|
||||
const search = `^${origin}/c/chromium/src/\\+/(\\d+)`;
|
||||
const match = url.match(search);
|
||||
if (match != undefined && match.length == 2) {
|
||||
getMilestoneForRevid(match[1]).then((milestone) =>
|
||||
milestone != '' ? (div.innerText = `m${milestone}`) : window.close());
|
||||
} else {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
function getMilestoneForRevid(revid) {
|
||||
return fetch(`https://crrie.com/c/?r=${revid}`)
|
||||
.then((res) => res.text());
|
||||
}
|
Загрузка…
Ссылка в новой задаче