├── .gitignore
├── LICENSE.txt
├── README.md
├── contentscript.js
├── manifest.json
├── package.json
└── static
└── vscode.svg
/.gitignore:
--------------------------------------------------------------------------------
1 | package-lock.json
2 | node_modules
3 | web-ext-artifacts
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Joseph Diragi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # Open in Visual Studio Code
6 |
7 | A browser extension that adds an "Open in Visual Studio Code" option to GitHub repos.
8 |
9 | This extension is in no way endorsed by Microsoft or the Visual Studio Code team. I'm not even sure they'd be okay with me publishing this if they knew about it. Please don't bring any issues with this extension up in any Visual Studio Code support forums of any kind. Any issues you run into with this extension should be brought up in the issues section of this repository and nowhere else. Please don't get me in trouble ❤️.
10 |
11 | ## Installing
12 |
13 | **Firefox**: https://addons.mozilla.org/en-US/firefox/addon/open-in-visual-studio-code/
14 |
15 | **Chrome**: Download the latest release [here](https://github.com/TheNightmanCodeth/open-in-code/releases/latest)
16 |
17 | **Safari**: Download the latest release [here](https://github.com/TheNightmanCodeth/open-in-code/releases/latest)
18 |
19 | ## Building & Installing From Source
20 |
21 | ### Build
22 | > npm run build
23 |
24 | ### Install
25 | Once the build completes there will be a `web-ext-artifacts` folder containing the extension.
26 |
27 | **Firefox**
28 | - Open the Add-ons Manager (Alt + t > a)
29 | - Click on the gear icon
30 | - Select "Install Add-on From File..."
31 | - Locate the addon and install
32 |
33 | **Chrome**
34 | - Unzip the archive in `web-ext-artifacts`
35 | - Navigate to `chrome://extensions`
36 | - Ensure `Developer Mode` is activated
37 | - Click `Load Unpacked` and open the unzipped plugin directory
38 |
39 | **Safari**
40 | Check out [this guide](https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari) for more detailed instructions.
41 | - Make sure you have the latest version of XCode and Command Line Tools installed
42 | - Unzip the build in `web-ext-artifacts`
43 | - Open a Terminal and run:
44 | - `xcrun safari-web-extension-converter /path/to/unzipped-artifact`
45 | - [Run with XCode and install in Safari](https://developer.apple.com/documentation/safariservices/safari_web_extensions/running_your_safari_web_extension)
46 |
47 | ## Contributing
48 |
49 | Pull requests and issues are always welcome. If you run into a bug, open an issue **here**. If you know how to fix the bug, submit a pull request and reference the issue in the description.
50 |
51 | ## Changelog
52 |
53 | ### 1.0.2
54 | - Fixes bug that caused users to need to refresh page to see entries in modal
55 | - First Safari release
56 |
57 | ### 1.0.1
58 | - Fix multiple "Open in..." items being added to modal
59 |
60 | ### 1.0.0
61 | - Initial release 🎉
62 |
63 | ## Supporting Me
64 |
65 | If you find this extension useful and are feeling generous cosider buying me a coffee!
66 |
67 | Venmo: @j_diggity
68 |
69 | Cash App: $JADiggity
70 |
71 | ETH (Ethereum network only!!!): 0x0d8B0B097B77F262D110003E9d2c030cd26Da95F
72 |
--------------------------------------------------------------------------------
/contentscript.js:
--------------------------------------------------------------------------------
1 | (() => {
2 | mutationObserver = window.MutationObserver || window.WebKitMutationObserver;
3 | var observer = new MutationObserver(function(mutations, observer) {
4 | let ghCodeDropdown = getDropUL();
5 | if (ghCodeDropdown != undefined) {
6 | ghCodeDropdown.appendChild(openInCodeElement(`${document.URL}.git`));
7 | }
8 | })
9 |
10 | observer.observe(document, {
11 | subtree: true,
12 | attributes: true
13 | });
14 |
15 | function openInCodeElement(repo) {
16 | // If the LI is already here, return
17 | if (document.getElementById("openincode") != null) return;
18 | // List item
19 | const openInCodeLI = document.createElement("li");
20 | openInCodeLI.id = "openincode";
21 | openInCodeLI.classList.add(...["Box-row", "Box-row--hover-gray", "p-3", "mt-0"]);
22 | // List child element / link
23 | const openInCodeA = document.createElement("a");
24 | openInCodeA.classList.add(...["d-flex", "flex-items-center", "color-fg-default", "text-bold", "no-underline"]);
25 | openInCodeA.rel = "nofollow";
26 | // TODO: Add option to clone with SSH
27 | openInCodeA.href = `vscode://vscode.git/clone?url=${encodeURI(repo)}`;
28 | // Add logo
29 | const logo = document.createElement("img");
30 | logo.src = browser.runtime.getURL("static/vscode.svg");
31 | logo.setAttribute("viewBox", "0 0 16 16");
32 | logo.setAttribute("class", "mr-2");
33 | logo.width = 16;
34 | logo.height = 16;
35 | openInCodeA.appendChild(logo);
36 | // Add label
37 | openInCodeA.appendChild(document.createTextNode("Open in Visual Studio Code"));
38 | // Add openInCodeA to LI
39 | openInCodeLI.appendChild(openInCodeA);
40 | return openInCodeLI;
41 | }
42 |
43 | function getDropUL() {
44 | // Find get-repo modal
45 | const dropDownDiv = document.querySelectorAll('[data-target="get-repo.modal"]');
46 | // There will only be one code dropdown
47 | if (dropDownDiv.length != 1) return;
48 | let getRepoModal = dropDownDiv[0];
49 | // Find the