Skip to content

Commit 83bf536

Browse files
committed
fix: checkboxes not working when browser back event
add auto initialize all of the supported services (no longer need to press the Gitd Start button) remove Github.com turbo event listeners
1 parent 06f2505 commit 83bf536

File tree

6 files changed

+129
-67
lines changed

6 files changed

+129
-67
lines changed

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
# Gitd Download Manager Browser Extension
2+
23
It is a browser extension that allows you to download only the files/folders you want without having to download all of the public repository. Github.com, Bitbucket.org, Gitlab.com provides all of the public repos in git services to download selected files and folders as a zip files with a single click, without the need for any API key or token.
34

45
The "Gitd Start" button is ready for use on every screen you see.
56

67
> Note: Gitd Download Manager browser extension creates download lists using Gitdownloadmanager.com api service.
78
8-
![screenshot](screenshots/gitd-manager-github-download.jpeg)
9+
![video](gif/gitdmanager.gif)
910

1011
## Features
12+
1113
- Support only Github.com, Bitbucket.org, Gitlab.com public repositories page
1214
- Not neeeded ApiKey/ApiToken
1315
- Support single or multiple files download
1416
- Download selected contents as a zip file with one click
1517
- Support all branches
1618
- Maximum Selection Limit: 5
17-
- Maximum Download Files: 5000
19+
- Maximum Download Files: 5000
20+
21+
![screenshot](screenshots/gitd-manager-github-download.jpeg)
1822

1923
## Next Features
24+
2025
- No limitations for selection and downloading files count
2126
- Support branch names with includes slash
2227
- Support Bitbucket.org commitId url (Maybe)
2328

2429
## Compatibility
30+
2531
- Chrome (Manifestv3)
2632
- Firefox (Manifestv2)
2733
- Microsoft Edge (Manifestv3)
2834

2935
## Installation
36+
3037
### 1. Chrome Store/Firefox Add-Ons
3138

3239
Go to [Gitd Download Manager](https://chrome.google.com/webstore/detail/gitd-download-manager/cbnplpkljokdodpligcaolkmodfondhl) Chrome Store Page
@@ -35,10 +42,11 @@ Go to [Gitd Download Manager](https://addons.mozilla.org/en-US/firefox/addon/git
3542

3643
Go to [Gitd Download Manager](https://microsoftedge.microsoft.com/addons/detail/-/-) Microsoft Edge Add-Ons Page
3744

38-
### 2. Production Build For Chrome Store / Firefox Add-on / Microsoft Edge
45+
### 2. Production Build For Chrome Store / Firefox Add-on / Microsoft Edge
3946

4047
- Go to the folder where the `README.md` file is located and run `./build.prod.sh <NEW_VERSION>` (./build.prod.sh 1.0.1) command after go to "build/prod/<NEW_VERSION>/" folder for zip files of all versions.
41-
```
48+
49+
```bash
4250
./build/prod/1.0.1/gitd-1.0.1-v2.dev.zip -> Firefox Extension - Development version - Manifest version 2
4351
./build/prod/1.0.1/gitd-1.0.1-v2.zip -> Firefox Extension - Production Version - Manifest version 2
4452
./build/prod/1.0.1/gitd-1.0.1-v3.dev.zip -> Chrome Store Extension - Development version - Manifest version 3
@@ -51,7 +59,7 @@ Go to [Gitd Download Manager](https://microsoftedge.microsoft.com/addons/detail/
5159

5260
- Run `./build.<env>.sh <NEW_VERSION>` (./build.dev.sh 1.0.1) command after go to "build/dev/<NEW_VERSION>/" folder for zip files of all versions.
5361

54-
```
62+
```bash
5563
./build/prod/1.0.1/gitd-1.0.1-v2.dev.zip -> Firefox Extension - Development version - Manifest version 2
5664
./build/prod/1.0.1/gitd-1.0.1-v2.zip -> Firefox Extension - Production Version - Manifest version 2
5765
./build/prod/1.0.1/gitd-1.0.1-v3.dev.zip -> Chrome Store Extension - Development version - Manifest version 3
@@ -68,18 +76,23 @@ Go to [Gitd Download Manager](https://microsoftedge.microsoft.com/addons/detail/
6876
6. Go to github.com, gitlab.com or bitbucket.org website
6977

7078
### Usage
79+
7180
- In the right corner of the browser, the "Gitd Start" button notifies you that the plugin is active.
7281
- The plugin is automatically installed on Github.com and adds checkboxes, but on other websites you have to press the "Gitd Start" button.
7382

7483
### Find Open Source Projects: Public Repository
84+
7585
[Github.com](https://github.com/search/advanced) advanced search page.
7686
[Gitlab.com](https://gitlab.com/explore/projects) advanced search page.
7787
[Bitbucket.org](https://bitbucket.org/repo/all) simple search page.
88+
[Gitea.com](https://gitea.com/explore/repos) simple search page. (NOT SUPPORTED YET)
7889

7990
## Licence
91+
8092
See LICENSE for more details.
8193

82-
# Thanks
94+
## Thanks
95+
8396
[Alpinejs](https://alpinejs.dev) for DOM manipulation
8497

8598
[fflate](https://github.com/101arrowz/fflate) for generate zip packages
@@ -91,18 +104,33 @@ See LICENSE for more details.
91104
[Liozon/Edge add-on badge.md](https://gist.github.com/Liozon/cf898c47628bfecd9896f79e6c9a8db8) for Microsoft Edge Add-On Badge
92105

93106
## Source
107+
94108
[Firefox Manifest Docs](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json) * perfect docs
95109

96110
[Google Chrome Manifest Docs](https://developer.chrome.com/docs/extensions/mv3/manifest/) * not recomended **sorry**
97111

98112
[Microsoft Edge Manifest Docs](https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/getting-started/manifest-format) * firefox alternate
99113

100114
## Changelog
115+
116+
v1.0.5
117+
118+
- fix checkboxes not working when browser back event
119+
- add auto initialize all of the supported services (no longer need to press the Gitd Start button)
120+
- remove Github.com turbo event listeners
121+
122+
v1.0.4
123+
124+
- update only manifest description
125+
101126
v1.0.3
127+
102128
- update manifest description
103129

104130
v1.0.3
131+
105132
- compatible with github both page design
106133

107134
v1.0.2
108-
- compatible with github new design
135+
136+
- compatible with github new design

extension/contentScript.js

Lines changed: 88 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
1313
// inject templates
1414
injectGitdTemplates()
1515

16+
setTimeout(function() {
17+
// Trigger the button element with a click
18+
triggerGitdStart()
19+
}, 1500)
20+
1621
break;
1722
/*case "IM_LOADING":
1823
// Dom Content Loading but not finish
@@ -26,6 +31,11 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
2631
// inject templates
2732
injectGitdTemplates()
2833

34+
setTimeout(function() {
35+
// Trigger the button element with a click
36+
triggerGitdStart()
37+
}, 1500)
38+
2939
// inject gitdmanager
3040
injectGitdScripts("lib/gitdmanager.js")
3141

@@ -61,62 +71,18 @@ window.addEventListener("submit-action", function(evt) {
6171

6272
// via: chrome dev tools: getEventListeners(window) -> return all events
6373
// only for github "turbo:load" event listen
64-
window.addEventListener("turbo:load", function(evt) {
65-
if (isDebugActive()) console.log("content-script", "turbo:load", evt)
66-
67-
setTimeout(function() {
68-
let newDesign = false
69-
70-
// checkbox add
71-
let navItem = document.querySelectorAll("div.js-navigation-item > div:first-child > svg") // old design
72-
if (navItem.length == 0) {
73-
navItem = document.querySelectorAll("table > tbody > tr > td > div.react-directory-filename-column > svg") // new design
74-
newDesign = true
75-
}
76-
77-
if (navItem.length > 0) {
78-
79-
// inject checkbox
80-
for (const key in navItem) {
81-
if (Object.hasOwnProperty.call(navItem, key)) {
82-
const element = navItem[key];
83-
84-
// type: none: 0 - file: 1 - folder: 2
85-
let itemType = element.getAttribute("aria-label") // old desing
86-
if (newDesign) {
87-
itemType = element.getAttribute("class") // new design
88-
}
89-
90-
if (itemType === "Directory") {
91-
itemType = 2
92-
} else if (itemType === "File") {
93-
itemType = 1
94-
} else if (itemType == "icon-directory") {
95-
itemType = 2
96-
} else {
97-
itemType = 1
98-
}
99-
100-
let pathElement = element.parentElement.nextElementSibling?.querySelector("div > span > a") // old desing
101-
if (newDesign) {
102-
pathElement = element.parentElement.querySelector("div.overflow-hidden > h3 > div > a") // new design
103-
}
104-
105-
if (!!pathElement) {
106-
let insertPosition = "beforebegin"
107-
if (newDesign) {
108-
insertPosition = "afterbegin"
109-
}
110-
111-
element.parentElement.insertAdjacentHTML(insertPosition, "<div role=\"gridcell\" class=\"mr-3 flex-shrink-0\"><input class=\"gitd-tree-checkbox\" type=\"checkbox\" data-name=\""+pathElement.innerText+"\" data-type=\""+itemType+"\" @click=\"toggleSelectList\"></div>")
112-
}
113-
}
114-
}
115-
}
74+
// window.addEventListener("turbo:load", function(evt) {
75+
// if (isDebugActive()) console.log("content-script", "turbo:load", evt)
11676

117-
}, 1500)
77+
// setTimeout(function() {
78+
// // inject templates
79+
// injectGitdTemplates()
11880

119-
}, false);
81+
// // init checkboxes
82+
// initQuickSelectionCheckboxes()
83+
// }, 1500)
84+
85+
// }, false);
12086

12187
// debug mode listener
12288
window.addEventListener("debug-mode-changed", function(evt) {
@@ -147,5 +113,71 @@ function injectGitdScripts(scrPath) {
147113
s.parentNode.removeChild(s);
148114
};
149115
(document.body || document.documentElement).appendChild(s)
150-
if (isDebugActive()) console.log(s);
151-
}
116+
if (isDebugActive()) console.log("injectGitdScripts", s);
117+
}
118+
119+
// trigger gitdStartButton
120+
function triggerGitdStart() {
121+
let gitdStartButton = document.getElementById("gitdStartButton")
122+
if (!!gitdStartButton) {
123+
if (isDebugActive()) console.log("gitdStartButton", "trigger", "click", gitdStartButton)
124+
gitdStartButton.click()
125+
}
126+
}
127+
128+
// init quick selection checkboxes
129+
// function initQuickSelectionCheckboxes() {
130+
// // check gitd-init attribute
131+
// if (document.querySelector(".gitd-tree-checkbox") === null) {
132+
133+
// // check new design
134+
// let newDesign = false
135+
136+
// // checkbox add
137+
// let navItem = document.querySelectorAll("div.js-navigation-item > div:first-child > svg") // old design
138+
// if (navItem.length == 0) {
139+
// navItem = document.querySelectorAll("table > tbody > tr > td > div.react-directory-filename-column > svg") // new design
140+
// newDesign = true
141+
// }
142+
143+
// if (navItem.length > 0) {
144+
145+
// // inject checkbox
146+
// for (const key in navItem) {
147+
// if (Object.hasOwnProperty.call(navItem, key)) {
148+
// const element = navItem[key];
149+
150+
// // type: none: 0 - file: 1 - folder: 2
151+
// let itemType = element.getAttribute("aria-label") // old desing
152+
// if (newDesign) {
153+
// itemType = element.getAttribute("class") // new design
154+
// }
155+
156+
// if (itemType === "Directory") {
157+
// itemType = 2
158+
// } else if (itemType === "File") {
159+
// itemType = 1
160+
// } else if (itemType == "icon-directory") {
161+
// itemType = 2
162+
// } else {
163+
// itemType = 1
164+
// }
165+
166+
// let pathElement = element.parentElement.nextElementSibling?.querySelector("div > span > a") // old desing
167+
// if (newDesign) {
168+
// pathElement = element.parentElement.querySelector("div.overflow-hidden > h3 > div > a") // new design
169+
// }
170+
171+
// if (!!pathElement) {
172+
// let insertPosition = "beforebegin"
173+
// if (newDesign) {
174+
// insertPosition = "afterbegin"
175+
// }
176+
177+
// element.parentElement.insertAdjacentHTML(insertPosition, "<div role=\"gridcell\" class=\"mr-3 flex-shrink-0\"><input class=\"gitd-tree-checkbox\" type=\"checkbox\" data-name=\""+pathElement.innerText+"\" data-type=\""+itemType+"\" @click=\"toggleSelectList\"></div>")
178+
// }
179+
// }
180+
// }
181+
// }
182+
// }
183+
// }

extension/lib/gitdmanager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ document.addEventListener('alpine:init', () => {
4242

4343
activateGitdInit() {
4444
if (this.isDebugActive()) console.log("toggleGitdInit");
45+
46+
this.gitdInit = true
47+
this.gitdInitText = "Gitd Ready"
4548

4649
// check gitd-init attribute
4750
if (document.querySelector(".gitd-tree-checkbox") === null) {
48-
this.gitdInit = true
49-
this.gitdInitText = "Gitd Ready"
51+
if (this.isDebugActive()) console.log("toggleGitdInit", "checkbox init started");
5052

5153
// hostname
5254
let hostname = window.location.hostname

extension/lib/templates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
let gitdInitTemplate = `<div class="gitd-shortcut-button">
4-
<button @click="activateGitdInit" type="button" class="gitd-btn gitd-btn-sm gitd-btn-warning">
4+
<button id="gitdStartButton" @click="activateGitdInit" type="button" class="gitd-btn gitd-btn-sm gitd-btn-warning">
55
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="bi bi-card-checklist" viewBox="0 0 16 16">
66
<path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h13zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"/>
77
<path d="M7 5.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm-1.496-.854a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0zM7 9.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm-1.496-.854a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 0 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0z"/>

extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Gitd Download Manager",
44
"short_name": "Gitd",
55
"description": "Download at Github,Bitbucket,Gitlab repository's selected files, folders as a zip file with a single click, without any api token.",
6-
"version": "1.0.4",
6+
"version": "1.0.5",
77
"homepage_url": "https://github.com/git-download-manager/gitd-extension",
88
"permissions": [
99
"webNavigation"

gif/gitdmanager.gif

1.44 MB
Loading

0 commit comments

Comments
 (0)