This commit is contained in:
Bruno F. Fontes 2023-10-13 17:51:43 -03:00
commit 7480634fa2
Signed by: brunofontes
GPG Key ID: 4DAA810052CF68B6
17 changed files with 89 additions and 0 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# Dicionarios.cc Browser Extension
## Contributing
Please get in touch with your idea before submiting a pull request.
## Deployment
### How to
Run the `chrome.sh` and/or the `ff.sh` scripts to generate the `manifest.json` file. It will also generate a `chrome.zip` or `ff.zip` with all inner files. Just upload it to the _EDIT_ websites below and submit to revision.

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
images/Screenshot logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

5
src/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# Compiled manifest file
manifest.json
# zip files
*.zip

18
src/background.js Normal file
View File

@ -0,0 +1,18 @@
// Add context menu
function setupContextMenu() {
chrome.contextMenus.create({
title: 'Search: %s',
contexts: ['selection'],
id: 'define-word',
});
}
setupContextMenu();
// Context menu was clicked...
chrome.contextMenus.onClicked.addListener((info) => {
selectedWord = info.selectionText;
url = "https://dicionarios.cc/" + selectedWord
chrome.tabs.create({ url: url});
});

7
src/chrome.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash --
sed -z 's|<<firefox[^<]*<</firefox>>||g' generic_manifest.json > manifest.json
sed -i 's|<</chrome>>||g' manifest.json
sed -i 's|<<chrome>>||g' manifest.json
./zip.sh chrome.zip

7
src/ff.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash --
sed -z 's|<<chrome[^<]*<</chrome>>||g' generic_manifest.json > manifest.json
sed -i 's|<</firefox>>||g' manifest.json
sed -i 's|<<firefox>>||g' manifest.json
./zip.sh ff.zip

33
src/generic_manifest.json Normal file
View File

@ -0,0 +1,33 @@
{
"manifest_version": 3,
"name": "Dicionarios.cc",
"version": "0.0.1",
"description": "An easy shortcut to Dicionarios.cc",
"icons": {
"16": "img/logo-16.png",
"48": "img/logo-48.png",
"96": "img/logo-96.png",
"128": "img/logo-128.png",
"140": "img/logo-140.png",
"260": "img/logo-260.png"
},
"background": {<<firefox>>
"scripts": ["background.js"]<</firefox>><<chrome>>
"service_worker": "background.js"<</chrome>>
},
"permissions": [
"contextMenus"
],
"action": {
"default_title": "Dicionarios.cc",
"default_popup": "https://dicionarios.cc"
}<<firefox>>,
"browser_specific_settings": {
"gecko": {
"id": "{0ad357e8-8322-49d9-b1af-dc18934d8b78}"
},
"gecko_android": {
"id": "{0ad357e8-8322-49d9-b1af-dc18934d8b78}"
}
}<</firefox>>
}

BIN
src/img/logo-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
src/img/logo-140.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
src/img/logo-16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
src/img/logo-260.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
src/img/logo-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
src/img/logo-96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

7
src/zip.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
FILE="addon.zip"
[[ $1 ]] && FILE="$1"
rm "$FILE" &>/dev/null && echo "Deleting addon.zip" || echo
zip -r "$FILE" ./*.html ./*.js ./*.css img/* manifest.json