Skip to content

Commit ab6f550

Browse files
committed
Don't make user click button, just show link immediately
1 parent 0bd8a89 commit ab6f550

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

GithubToAdoExt/popup/popup.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
</head>
1313
<noscript>Oh... you disabled Javascript or client side scripting, so this extention won't work</noscript>
1414
<body>
15-
<p id="content">
16-
<button id="linkButton">Get Link</button>
17-
</p>
15+
<p id="content"></p>
1816
<script type="text/javascript" src="scripts.js"></script>
1917
</body>
2018
</html>

GithubToAdoExt/popup/scripts.js

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
function getTabs()
2-
{
3-
chrome.tabs.query({currentWindow: true, active: true}, doThingWithTabs);
4-
}
1+
window.onload = (event) => {
2+
// Gets the current tabs
3+
chrome.tabs.query({currentWindow: true, active: true}, getAdoLink);
4+
};
55

6-
function doThingWithTabs(tabs)
6+
function getAdoLink(tabs)
77
{
8+
// Check the URL of the current tab to see if it's a MUX GitHub URL
89
let fullUrl = tabs[0].url;
910
if (isValidUrl(fullUrl))
1011
{
@@ -14,40 +15,35 @@ function doThingWithTabs(tabs)
1415
// Create link with search URL
1516
document.getElementById("content").innerHTML =
1617
"<a href='" + searchUrl + "' "
17-
+ "target='_blank' rel='noopener' " // Opens link in new tab
18-
+ "title='Open ADO link in new tab'>Link</a>";
18+
+ "target='_blank' rel='noopener' " // Opens link in new tab
19+
+ "title='Open ADO link in new tab' " // Hover text
20+
+ ">ADO Link</a>"; // Display text
1921
}
2022
else
2123
{
22-
//document.write("Not a WinUI GitHub page");
2324
document.getElementById("content").innerHTML = "Not a WinUI GitHub page";
2425
}
2526
}
2627

2728
function isValidUrl(fullUrl)
2829
{
29-
let firstPart = "https://github.com/microsoft/microsoft-ui-xaml/issues/";
30-
let isValid = (fullUrl.startsWith(firstPart)) ? true : false;
31-
return isValid;
30+
// Leave out ending slash so the full list of issues (no number) is considered valid
31+
let firstPart = "https://github.com/microsoft/microsoft-ui-xaml/issues";
32+
return fullUrl.startsWith(firstPart);
3233
}
3334

3435
function getGithubNumberFromUrl(fullUrl)
3536
{
36-
let number;
3737
let firstPart = "https://github.com/microsoft/microsoft-ui-xaml/issues/";
38-
let len = firstPart.length;
39-
number = fullUrl.substring(len);
40-
return number;
38+
return fullUrl.substring(firstPart.length);
4139
}
4240

4341
function createAdoSearchUrl(githubNumber)
4442
{
4543
let urlStart = "https://microsoft.visualstudio.com/OS/_search?";
46-
let searchTest = "text=https%3A//github.com/microsoft/microsoft-ui-xaml/issues/";
47-
// github item number goes here
44+
let searchText = "text=https%3A//github.com/microsoft/microsoft-ui-xaml/issues/";
45+
// github item number goes here (if there is one, otherwise we return a query for all the MUX GitHub issues)
4846
let itemType = "&type=workitem&lp=workitems-Project";
49-
let searchUrl = urlStart + searchTest + githubNumber + itemType;
47+
let searchUrl = urlStart + searchText + githubNumber + itemType;
5048
return searchUrl;
5149
}
52-
53-
document.getElementById("linkButton").addEventListener("click", getTabs);

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ A Chromium extension for linking to MSFT internal ADO items from WinUI 3 GitHub
33

44
## How install
55
Currently, the only way to install this extention into Edge is to sideload it as an unpackaged extension.
6-
1. Download the repo, or just the GithubToAdoExt directory.
7-
2. Open the Extensions pane in Edge (this can be found under the ... menu in the upper right)
8-
3. Ensure that "Developer mode" is turned on (bottom left corner. If it's not there, hit the hamburger menu in the upper left.)
6+
1. Download the repo, or just the GithubToAdoExt directory
7+
2. Open the Extensions pane in Edge (this can be found under the "..." menu in the upper right)
8+
3. Ensure that "Developer mode" is turned on. (There is a toggle in the bottom left corner.
9+
If it's not there, hit the hamburger menu in the upper left.)
910
4. Click the "Load unpackaged" icon
1011
5. Select the GithubToAdoExt folder
1112

1213
The extension should now be installed, and you should see the WinUI logo in your Edge toolbar.
1314

1415
## How to use
15-
- Go to the WinUI GitHub page you want to find the ADO item for.
16+
- Go to the WinUI GitHub page you want to find the ADO item for
1617
- Click the extension's icon in the toolbar
17-
- Click GetLink
18-
- Click the link
19-
If you are not on a WinUI GitHub page, you will see an error stating such.
18+
- Clicking the link provided will open the ADO item in a new tab
19+
20+
If you are not on a WinUI GitHub page, you will see an error stating such. Using the extension from
21+
the main GitHub issues page will bring you to a query for all ADO issues mirrored from the MUX GitHub.

0 commit comments

Comments
 (0)