├── LICENSE
├── README.md
├── images
├── git_io_128.png
├── git_io_16.png
├── git_io_32.png
└── git_io_48.png
├── manifest.json
├── popup
├── popup.html
└── styles.css
└── script
├── background.js
├── functions.js
├── jquery.js
└── script.js
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Mahdyar Hasanpour
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### This extension won't work anymore according to GitHub's Blog: [Git.io no longer accepts new URLs](https://github.blog/changelog/2022-01-11-git-io-no-longer-accepts-new-urls/).
2 | -------
3 | # Git.io extension
4 | A cross-browser extension for GitHub's URL shortener (git.io).
5 | ## Download
6 |
7 |
8 |
9 | ## Supported domains
10 | - `https://github.com/*`
11 | - `https://*.github.com/*`
12 | - `https://*.github.io`
13 | - `https://*.github.io/*`
14 | - `https://*.githubusercontent.com/*`
15 |
16 | ## Preview
17 | ### Random Address
18 | 
19 | ### Custom Address
20 | 
21 |
22 | ## Development
23 | On Chrome/Chromium-based browsers, you can:
24 | 1. Enable `Developer mode`. ([How?](https://developer.chrome.com/docs/extensions/mv2/faq/#faq-dev-01))
25 | 2. Clone the repository:
26 | ```
27 | git clone https://github.com/mahdyar/git.io-extension.git
28 | ```
29 | 3. Go to `chrome://extensions/` and click on `Load unpacked` and load the folder from previous step.
30 |
--------------------------------------------------------------------------------
/images/git_io_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahdyar/git.io-extension/422ec7d167d34ca6dc87b91c7dec47ac9d0041af/images/git_io_128.png
--------------------------------------------------------------------------------
/images/git_io_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahdyar/git.io-extension/422ec7d167d34ca6dc87b91c7dec47ac9d0041af/images/git_io_16.png
--------------------------------------------------------------------------------
/images/git_io_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahdyar/git.io-extension/422ec7d167d34ca6dc87b91c7dec47ac9d0041af/images/git_io_32.png
--------------------------------------------------------------------------------
/images/git_io_48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mahdyar/git.io-extension/422ec7d167d34ca6dc87b91c7dec47ac9d0041af/images/git_io_48.png
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Git.io",
3 | "version": "1.4",
4 | "description": "Shorten your GitHub urls to a git.io url.",
5 | "browser_action": {
6 | "default_popup": "popup/popup.html",
7 | "default_icon": {
8 | "16": "images/git_io_16.png",
9 | "32": "images/git_io_32.png",
10 | "48": "images/git_io_48.png",
11 | "128": "images/git_io_128.png"
12 | }
13 | },
14 | "commands": {
15 | "shorten-url-copy-to-clipboard": {
16 | "suggested_key": {
17 | "default": "Ctrl+Shift+L",
18 | "mac": "Command+Shift+L"
19 | },
20 | "description": "Shorten the url and copy it to the clipboard."
21 | }
22 | },
23 | "icons": {
24 | "16": "images/git_io_16.png",
25 | "32": "images/git_io_32.png",
26 | "48": "images/git_io_48.png",
27 | "128": "images/git_io_128.png"
28 | },
29 | "background": {
30 | "scripts": [
31 | "script/jquery.js",
32 | "script/functions.js",
33 | "script/background.js"
34 | ]
35 | },
36 | "permissions": ["tabs", "activeTab", "https://git.io/*"],
37 | "manifest_version": 2
38 | }
39 |
--------------------------------------------------------------------------------
/popup/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
> Custom address
11 |
12 |
18 | > Random address
21 |
22 |
23 |
24 |
48 |
49 |
50 |
51 |
52 | It only works on GitHub domains.
53 | (?)
59 |
60 |
61 |
62 |
Shortcut
63 |
(Configure)
66 |
Windows/Linux: Ctrl+Shift+L
67 |
Mac: Command+Shift+L
68 |
69 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/popup/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | width: 300px;
3 | height: 300px;
4 | background-color: #f1f2f4;
5 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
6 | Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
7 | color: #2a4757;
8 | overflow: hidden;
9 | }
10 | header {
11 | width: 100%;
12 | height: 40px;
13 | line-height: 40px;
14 | position: absolute;
15 | top: 0;
16 | left: 0;
17 | font-weight: bold;
18 | text-align: center;
19 | }
20 | .input {
21 | background-color: #ffffff;
22 | padding: 5px 15px;
23 | box-shadow: rgb(167 182 190 / 20%) 0px 10px 35px;
24 | border-image: initial;
25 | border-radius: 100px;
26 | border: 2px solid rgb(245, 245, 245);
27 | }
28 | #container {
29 | margin: 0;
30 | position: absolute;
31 | top: 20%;
32 | left: 50%;
33 | -ms-transform: translate(-50%, -20%);
34 | transform: translate(-50%, -20%);
35 | width: 100%;
36 | }
37 | #active-tab-url {
38 | margin: 50px auto 0;
39 | text-align: center;
40 | width: 60%;
41 | white-space: nowrap;
42 | overflow: hidden;
43 | text-overflow: ellipsis;
44 | cursor: pointer;
45 | }
46 | #shorten-btn {
47 | color: #ffffff;
48 | display: block;
49 | margin: 10px auto;
50 | border: transparent 2px solid;
51 | border-radius: 10px 0 10px 0;
52 | padding: 5px 10px;
53 | outline: none;
54 | font-size: 11px;
55 | }
56 | .is-not-shortened {
57 | background-color: #aaaaaa;
58 | }
59 | .is-not-shortened:hover {
60 | background-color: #4e11c9;
61 | cursor: pointer;
62 | }
63 | .is-shortened {
64 | background-color: #aaaaaa;
65 | }
66 | footer {
67 | position: absolute;
68 | bottom: 0;
69 | left: 0;
70 | color: #441e47;
71 | width: 100%;
72 | height: 25px;
73 | line-height: 25px;
74 | padding-left: 10px;
75 | font-size: 11px;
76 | }
77 | footer a {
78 | color: #441e47;
79 | text-decoration: none;
80 | }
81 | #loading {
82 | display: none;
83 | margin: 10px auto;
84 | text-align: center;
85 | }
86 | .address-btn {
87 | margin-left: 45px;
88 | font-size: 9px;
89 | cursor: pointer;
90 | display: block;
91 | margin-top: 5px;
92 | }
93 | #custom-address-input {
94 | margin: 5px 45px 0;
95 | text-align: left;
96 | width: 25%;
97 | outline: none;
98 | font-size: 11px;
99 | }
100 | #custom-address {
101 | display: none;
102 | }
103 | #not-a-github-url {
104 | text-align: center;
105 | display: none;
106 | margin: 0;
107 | position: absolute;
108 | top: 50%;
109 | left: 50%;
110 | -ms-transform: translate(-50%, -50%);
111 | transform: translate(-50%, -50%);
112 | width: 70%;
113 | }
114 | #shortcuts {
115 | position: absolute;
116 | bottom: 15%;
117 | left: 10px;
118 | font-size: 11px;
119 | }
120 | .shortcut{
121 | background-color: #ffffff;
122 | padding: 1px;
123 | font-size: 10px;
124 | }
125 | footer {
126 | position: absolute;
127 | bottom: 5px;
128 | left: 0;
129 | border-top: 1px solid #e1e4e8;
130 | width: 100%;
131 | padding: 4px 5px;
132 | text-align: center;
133 | }
134 | footer svg {
135 | height: 15px;
136 | width: 15px;
137 | display: inline-block;
138 | margin: 5px auto;
139 | line-height: 50px;
140 | }
141 | a {
142 | text-decoration: none;
143 | color: inherit;
144 | }
145 | @media (prefers-color-scheme: dark) {
146 | body {
147 | background-color: #2d333b;
148 | color: #ffffff;
149 | }
150 | .input {
151 | background-color: #22272d;
152 | box-shadow: #22272d 0px 10px 35px;
153 | border: 2px solid #22272d;
154 | color: inherit;
155 | }
156 | .shortcut{
157 | background-color: #22272d;
158 | }
159 | #shorten-btn {
160 | color: #2d333b;
161 | }
162 | .is-not-shortened {
163 | background-color: #ccd9e5;
164 | }
165 | .is-not-shortened:hover {
166 | background-color: #6e3bce;
167 | }
168 | .is-shortened {
169 | background-color: #ccd9e5;
170 | }
171 | footer {
172 | border-top: 1px solid #444c56;
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/script/background.js:
--------------------------------------------------------------------------------
1 | chrome.commands.onCommand.addListener(function (command) {
2 | if (command == "shorten-url-copy-to-clipboard") {
3 | chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
4 | let url = tabs[0].url;
5 | let parser = document.createElement("a");
6 | parser.href = url;
7 | if (isGithubURL(parser.hostname)) {
8 | $.ajax({
9 | url: "https://git.io",
10 | method: "POST",
11 | data: {
12 | url: url,
13 | },
14 | success: function (data, textStatus, request) {
15 | if (data == url) {
16 | let shortenedUrl = request.getResponseHeader("Location");
17 | chrome.tabs.executeScript(tabs[0].id, {
18 | code: `navigator.clipboard.writeText("${shortenedUrl}"); `,
19 | });
20 | alert("Shotened URL copied to clipboard!");
21 | } else {
22 | alert("Somthing went wrong! try again.");
23 | }
24 | },
25 | error: function (request, status, error) {
26 | alert("Somthing went wrong! try again.");
27 | },
28 | });
29 | } else {
30 | alert(
31 | "It only works on GitHub domains.\n Go to mhdyr.ir/gs for more information!"
32 | );
33 | }
34 | });
35 | }
36 | });
37 |
--------------------------------------------------------------------------------
/script/functions.js:
--------------------------------------------------------------------------------
1 | function isGithubURL(hostname) {
2 | return (
3 | /^.*.github.com$/.test(hostname) ||
4 | hostname == "github.com" ||
5 | /^.*.github.io$/.test(hostname) ||
6 | /^.*.githubusercontent.com$/.test(hostname)
7 | );
8 | }
9 |
--------------------------------------------------------------------------------
/script/script.js:
--------------------------------------------------------------------------------
1 | let hasCustomAddress = false;
2 | let isShortened = false;
3 | chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
4 | let url = tabs[0].url;
5 | let parser = document.createElement("a");
6 | parser.href = url;
7 | if (isGithubURL(parser.hostname)) {
8 | $("#active-tab-url").text(url);
9 | $("#shorten-btn").click(function () {
10 | if (hasCustomAddress && $("#custom-address-input").val() == "") {
11 | alert(
12 | "You should enter a custom address, if you changed your mind just use the random address button."
13 | );
14 | } else if (!isShortened) {
15 | let data = hasCustomAddress
16 | ? {
17 | url: url,
18 | code: $("#custom-address-input").val(),
19 | }
20 | : {
21 | url: url,
22 | };
23 | $(this).hide();
24 | $("#loading").show();
25 | $.ajax({
26 | url: "https://git.io",
27 | method: "POST",
28 | data: data,
29 | success: function (data, textStatus, request) {
30 | if (data == url) {
31 | let shortenedUrl = request.getResponseHeader("Location");
32 | $("#active-tab-url").text(shortenedUrl);
33 | $("#loading").hide();
34 | $("#custom-address-btn").hide();
35 | $("#custom-address").hide();
36 | $("#shorten-btn")
37 | .text("shortened!")
38 | .removeClass("is-not-shortened")
39 | .addClass("is-shortened")
40 | .show();
41 | isShortened = true;
42 | } else {
43 | alert("Somthing went wrong! try again.");
44 | }
45 | },
46 | error: function (request, status, error) {
47 | alert("Somthing went wrong! try again.");
48 | $("#shorten-btn").show();
49 | $("#loading").hide();
50 | },
51 | });
52 | }
53 | });
54 | $("#active-tab-url").click(function () {
55 | if (isShortened) {
56 | $("#custom-address-btn").text("Copied to clipboard!").slideDown();
57 | navigator.clipboard.writeText($(this).text());
58 | }
59 | });
60 | } else {
61 | $("#container").hide();
62 | $("#shortcuts").hide();
63 | $("#not-a-github-url").show();
64 | }
65 | });
66 |
67 | $("#custom-address-btn").click(function () {
68 | $(this).slideUp(100);
69 | $("#custom-address").slideDown(100);
70 | hasCustomAddress = true;
71 | });
72 |
73 | $("#random-address-btn").click(function () {
74 | $("#custom-address").slideUp(100);
75 | $("#custom-address-btn").slideDown(100);
76 | hasCustomAddress = false;
77 | });
78 |
79 | $("#shortcuts a").click(function (e) {
80 | e.preventDefault();
81 | var newURL = "chrome://extensions/shortcuts";
82 | chrome.tabs.create({ url: newURL });
83 | return false;
84 | });
85 |
--------------------------------------------------------------------------------