commit 7480634fa249703c15e8f3534bd9b01bfcd093d6 Author: Bruno Fontes Date: Fri Oct 13 17:51:43 2023 -0300 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..6532d7f --- /dev/null +++ b/README.md @@ -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. diff --git a/images/Screenshot action button.png b/images/Screenshot action button.png new file mode 100644 index 0000000..d62f4cb Binary files /dev/null and b/images/Screenshot action button.png differ diff --git a/images/Screenshot context-menu.png b/images/Screenshot context-menu.png new file mode 100644 index 0000000..a3804c3 Binary files /dev/null and b/images/Screenshot context-menu.png differ diff --git a/images/Screenshot logo.png b/images/Screenshot logo.png new file mode 100644 index 0000000..966b6b1 Binary files /dev/null and b/images/Screenshot logo.png differ diff --git a/images/Screenshot website.png b/images/Screenshot website.png new file mode 100644 index 0000000..8ff41b8 Binary files /dev/null and b/images/Screenshot website.png differ diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..58d9a70 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,5 @@ +# Compiled manifest file +manifest.json + +# zip files +*.zip diff --git a/src/background.js b/src/background.js new file mode 100644 index 0000000..6a900a1 --- /dev/null +++ b/src/background.js @@ -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}); +}); diff --git a/src/chrome.sh b/src/chrome.sh new file mode 100644 index 0000000..396105c --- /dev/null +++ b/src/chrome.sh @@ -0,0 +1,7 @@ +#!/bin/bash -- + +sed -z 's|<>||g' generic_manifest.json > manifest.json +sed -i 's|<>||g' manifest.json +sed -i 's|<>||g' manifest.json + +./zip.sh chrome.zip diff --git a/src/ff.sh b/src/ff.sh new file mode 100644 index 0000000..10b294b --- /dev/null +++ b/src/ff.sh @@ -0,0 +1,7 @@ +#!/bin/bash -- + +sed -z 's|<>||g' generic_manifest.json > manifest.json +sed -i 's|<>||g' manifest.json +sed -i 's|<>||g' manifest.json + +./zip.sh ff.zip diff --git a/src/generic_manifest.json b/src/generic_manifest.json new file mode 100644 index 0000000..92503e0 --- /dev/null +++ b/src/generic_manifest.json @@ -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": {<> + "scripts": ["background.js"]<><> + "service_worker": "background.js"<> + }, + "permissions": [ + "contextMenus" + ], + "action": { + "default_title": "Dicionarios.cc", + "default_popup": "https://dicionarios.cc" + }<>, + "browser_specific_settings": { + "gecko": { + "id": "{0ad357e8-8322-49d9-b1af-dc18934d8b78}" + }, + "gecko_android": { + "id": "{0ad357e8-8322-49d9-b1af-dc18934d8b78}" + } + }<> +} diff --git a/src/img/logo-128.png b/src/img/logo-128.png new file mode 100644 index 0000000..6b9e383 Binary files /dev/null and b/src/img/logo-128.png differ diff --git a/src/img/logo-140.png b/src/img/logo-140.png new file mode 100644 index 0000000..a7e1f41 Binary files /dev/null and b/src/img/logo-140.png differ diff --git a/src/img/logo-16.png b/src/img/logo-16.png new file mode 100644 index 0000000..07e9a0d Binary files /dev/null and b/src/img/logo-16.png differ diff --git a/src/img/logo-260.png b/src/img/logo-260.png new file mode 100644 index 0000000..255fcad Binary files /dev/null and b/src/img/logo-260.png differ diff --git a/src/img/logo-48.png b/src/img/logo-48.png new file mode 100644 index 0000000..51c19f6 Binary files /dev/null and b/src/img/logo-48.png differ diff --git a/src/img/logo-96.png b/src/img/logo-96.png new file mode 100644 index 0000000..0049402 Binary files /dev/null and b/src/img/logo-96.png differ diff --git a/src/zip.sh b/src/zip.sh new file mode 100644 index 0000000..5447e26 --- /dev/null +++ b/src/zip.sh @@ -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