Skip to content

Commit eb0f9f7

Browse files
committed
[fix] 67 - make tabs permission optional
1 parent ba968bb commit eb0f9f7

File tree

9 files changed

+79
-31
lines changed

9 files changed

+79
-31
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.zip
22
manifest.json
33
.vscode/
4-
node_modules/
4+
node_modules/
5+
build

Readme.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,30 @@ Also allows you to hide "Shorts" tab.
2323

2424
## Installation
2525

26-
### Firefox
26+
For firefox install from [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/hide-youtube-shorts/) webpage
2727

28-
Install from [Mozilla Add-ons](https://addons.mozilla.org/en-US/firefox/addon/hide-youtube-shorts/) webpage
28+
For chrome install from [Chrome web store](https://chrome.google.com/webstore/detail/hide-shorts-for-youtube/ankepacjgoajhjpenegknbefpmfffdic) webpage
2929

30-
or add the Add-on temporarily:
31-
1. Download the project
32-
2. Rename 'manifest-firefox.json' file to 'manifest.json'
33-
3. In Firefox browser go to the debugging page by typing in url <b>[about:debugging#/runtime/this-firefox](about:debugging#/runtime/this-firefox)</b>
34-
4. Click on <b>Load Temporary Add-on...</b>
35-
5. Select a file (eg. 'manifest.json' file) inside of downloaded git project. Or you can ZIP contents of the project and select it instead.
30+
## Debugging
3631

37-
### Google Chrome
32+
Prepare files for chrome and firefox versions by running `npm run prepare` command. This will create new directories `./build/hys-c` (for chrome) `./build/hys-f` (for firefox) with respected files.
3833

39-
Install from [Chrome web store](https://chrome.google.com/webstore/detail/hide-shorts-for-youtube/ankepacjgoajhjpenegknbefpmfffdic) webpage
34+
You can also run `npm run zip` command to prepare and create zip archives for both chrome and firefox versions. Both will be placed in `./build` directory
35+
36+
### Firefox
37+
38+
Add the Add-on temporarily:
39+
1. In Firefox browser go to the debugging page by typing in url <b>[about:debugging#/runtime/this-firefox](about:debugging#/runtime/this-firefox)</b>
40+
2. Click on <b>Load Temporary Add-on...</b>
41+
3. Select a file `./build/hys-f/manifest.json` file. Or you can ZIP contents of the project and select it instead.
42+
43+
### Google Chrome
4044

41-
or add the Add-on manually:
42-
1. Download the project
43-
2. Rename 'manifest-chrome.json' file to 'manifest.json'
44-
3. In Chrome browser go to the Extensions page (or type in url <b>[chrome://extensions/](chrome://extensions/)</b>)
45-
4. Enable the <b>Developer Mode</b>
46-
5. Click the <b>Load unpacked</b> button
47-
6. Select the directory of downloaded git project.
45+
Add the Add-on manually:
46+
1. In Chrome browser go to the Extensions page (or type in url <b>[chrome://extensions/](chrome://extensions/)</b>)
47+
2. Enable the <b>Developer Mode</b>
48+
3. Click the <b>Load unpacked</b> button
49+
4. Select built directory `./build/hys-c`.
4850

4951
## License
5052

manifest-chrome.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"manifest_version": 3,
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"icons": {
77
"64": "icons/hideshort-64.png"
88
},
9-
"permissions" : [
10-
"storage",
9+
"permissions": [
10+
"storage"
11+
],
12+
"optional_permissions": [
1113
"tabs"
1214
],
1315
"content_scripts": [
@@ -23,7 +25,7 @@
2325
}
2426
],
2527
"background": {
26-
"service_worker": "./src/background/background-chrome.js",
28+
"service_worker": "./src/background/background.js",
2729
"type": "module"
2830
},
2931
"default_locale": "en",

manifest-firefox.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"manifest_version": 2,
3-
"version": "1.9.0",
3+
"version": "1.9.1",
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"icons": {
77
"64": "icons/hideshort-64.png"
88
},
9-
"permissions" : [
10-
"storage",
9+
"permissions": [
10+
"storage"
11+
],
12+
"optional_permissions": [
1113
"tabs"
1214
],
1315
"content_scripts": [
@@ -23,7 +25,15 @@
2325
}
2426
],
2527
"background": {
26-
"scripts": [ "./src/background/background-firefox.js" ]
28+
"scripts": [ "./src/background/background.js" ]
29+
},
30+
"browser_specific_settings": {
31+
"gecko": {
32+
"id": "{88ebde3a-4581-4c6b-8019-2a05a9e3e938}",
33+
"data_collection_permissions": {
34+
"required": ["none"]
35+
}
36+
}
2737
},
2838
"default_locale": "en",
2939
"browser_action": {

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
{
22
"scripts": {
3-
"test": "jest",
4-
"zip-firefox": "cp manifest-firefox.json manifest.json; zip -r hide-youtube-shorts-firefox.zip _locales/* icons/* src/* manifest.json LICENCE.md Readme.md; rm manifest.json",
5-
"zip-chrome": "cp manifest-chrome.json manifest.json; zip -r hide-youtube-shorts-chrome.zip _locales/* icons/* src/* manifest.json LICENCE.md Readme.md; rm manifest.json",
3+
"prepare-firefox": "mkdir -p ./build/hys-f; cp -r manifest-firefox.json _locales icons src LICENCE.md Readme.md ./build/hys-f; mv ./build/hys-f/src/background/background-firefox.js ./build/hys-f/src/background/background.js; mv ./build/hys-f/src/menu/permissions-firefox.js ./build/hys-f/src/menu/permissions.js; mv ./build/hys-f/manifest-firefox.json ./build/hys-f/manifest.json; find ./build/hys-f -name \"*-chrome.js\" -type f -delete",
4+
"prepare-chrome": "mkdir -p ./build/hys-c; cp -r manifest-chrome.json _locales icons src LICENCE.md Readme.md ./build/hys-c; mv ./build/hys-c/src/background/background-chrome.js ./build/hys-c/src/background/background.js; mv ./build/hys-c/src/menu/permissions-chrome.js ./build/hys-c/src/menu/permissions.js; mv ./build/hys-c/manifest-chrome.json ./build/hys-c/manifest.json; find ./build/hys-c -name \"*-firefox.js\" -type f -delete",
5+
"prepare": "npm run prepare-firefox; npm run prepare-chrome",
6+
7+
"zip-firefox": "npm run prepare-firefox; cd ./build/hys-f; zip -r ../hide-youtube-shorts-firefox.zip ./**; cd -",
8+
"zip-chrome": "npm run prepare-chrome; cd ./build/hys-c; zip -r ../hide-youtube-shorts-chrome.zip ./**; cd -",
69
"zip": "npm run zip-firefox; npm run zip-chrome;",
10+
11+
"clean": "rm -r ./build",
12+
713
"firefox-lint": "web-ext lint",
8-
"debug-android": "web-ext run -t firefox-android"
14+
"debug-android": "web-ext run -t firefox-android",
15+
"test": "jest"
916
},
1017
"devDependencies": {
1118
"jest": "^30.1.2",

src/menu/permissions-chrome.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function shortsInOriginalVideoPlayerCheckboxPermission(e) {
2+
if (e.target.checked) {
3+
chrome.permissions.request(
4+
{permissions: ['tabs']},
5+
(granted) => {
6+
chrome.storage.local.set({ shortsInOriginalVideoPlayer: granted });
7+
});
8+
}
9+
else {
10+
chrome.permissions.remove({permissions: ['tabs']});
11+
chrome.storage.local.set({ shortsInOriginalVideoPlayer: false });
12+
}
13+
}

src/menu/permissions-firefox.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function shortsInOriginalVideoPlayerCheckboxPermission(e) {
2+
if (e.target.checked) {
3+
browser.permissions.request({permissions: ['tabs']})
4+
.then((granted) => {
5+
chrome.storage.local.set({ shortsInOriginalVideoPlayer: granted });
6+
});
7+
}
8+
else {
9+
browser.permissions.remove({permissions: ['tabs']});
10+
chrome.storage.local.set({ shortsInOriginalVideoPlayer: false });
11+
}
12+
}

src/menu/popup.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ <h2>Hide Youtube-Shorts</h2>
162162
<span style="text-align: right;" id="ext-version"></span>
163163
</a>
164164
</div>
165+
<script src="permissions.js"></script>
165166
<script src="popup.js"></script>
166167
</body>
167168
</html>

src/menu/popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ window.onload = function () {
6767
if (value.shortsInOriginalVideoPlayer != undefined)
6868
shortsInOriginalVideoPlayerInputCheckbox.checked = value.shortsInOriginalVideoPlayer;
6969
shortsInOriginalVideoPlayerInputCheckbox.addEventListener("input", function (e) {
70-
chrome.storage.local.set({ shortsInOriginalVideoPlayer: e.target.checked });
70+
shortsInOriginalVideoPlayerCheckboxPermission(e)
7171
})
7272

7373
// timeout

0 commit comments

Comments
 (0)