Example milestone cleanup (#727)

* Add README and screenshot
* Adjust variable name casing for clarity
* Add copyright headers
* Reformat with clang-format
* Adds the 'milestones' example to the index
* Clarify extension's name and description
This commit is contained in:
Simeon Vincent
2022-06-23 17:41:37 -07:00
committed by GitHub
parent 73ef3a90c7
commit dcff87af05
6 changed files with 62 additions and 8 deletions

View File

@@ -68,6 +68,18 @@ Read more on [Getting Started](https://developer.chrome.com/extensions/getstarte
</ul>
</td>
</tr>
<tr>
<td style="vertical-align:top;">
Chromium Milestones<br>
<a href="examples/milestones"><code>examples/milestones</code></a>
</td>
<td style="vertical-align:top;">
<ul>
<li><a href="https://developer.chrome.com/docs/extensions/reference/action/#manifest">default_popup</a></li>
<li><a href="https://developer.chrome.com/docs/extensions/reference/tabs/#method-query">tabs.query</a></li>
</ul>
</td>
</tr>
<tr>
<td style="vertical-align:top;">
Cookie Clearer <br>

View File

@@ -0,0 +1,11 @@
Clicking this extension's action button while viewing a Chromium code review will open a small popup that shows what (if any) Chromium version the review was merged into. If the CR has not yet been merged or if the extension cannot find the version it was merged into, the action popup will automatically close itself.
# Demo
1. Install this extension
2. Visit https://chromium-review.googlesource.com/c/chromium/src/+/3635900
3. Click the extension's action icon
Once the extension retrieves the merged milestone information, it will appear in the extnesion's popup as shown below
![The extension's popup shows that this change request was merged in milestone 104](./screenshot.png)

View File

@@ -1,9 +1,9 @@
{
"name": "Milestones",
"name": "Chromium Milestones",
"version": "1.0",
"manifest_version": 3,
"action": {"default_popup": "popup.html"},
"description": "Chromium Release Milestones",
"description": "Shows the Chromium release milestone a given code review was merged into.",
"host_permissions": [ "https://crrie.com/" ],
"permissions": [ "activeTab" ]
}

View File

@@ -1 +1,17 @@
<!DOCTYPE html>
<!--
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script src="popup.js"></script>

View File

@@ -1,4 +1,18 @@
chrome.tabs.query({active: true}).then(tabs => getMilestone(tabs));
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
chrome.tabs.query({active : true}).then(tabs => getMilestone(tabs));
function getMilestone(tabs) {
const div = document.createElement("div");
@@ -8,14 +22,15 @@ function getMilestone(tabs) {
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());
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());
async function getMilestoneForRevId(revId) {
const res = await fetch(`https://crrie.com/c/?r=${revId}`);
return await res.text();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB