Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Assets

## Generating images

- Open `icon.svg` in Inkscape
- File - Export...
- **Batch Export** tab
- Make sure all layers are checked, **Directory** is set to `.`
- Click **Export**
- To place the images in `icons` directory run:

```sh
bash build.sh
```
31 changes: 31 additions & 0 deletions assets/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

main () {
cd "$(realpath $(dirname "$0"))"

# Find ffmpeg binary
local ffmpeg_binary;
ffmpeg_binary="ffmpeg"
if command -v ffmpeg7 >/dev/null 2>&1; then
ffmpeg_binary="ffmpeg7"
elif command -v ffmpeg6 >/dev/null 2>&1; then
ffmpeg_binary="ffmpeg6"
elif command -v ffmpeg5 >/dev/null 2>&1; then
ffmpeg_binary="ffmpeg5"
fi

# Don't want any errors for dir not existing
[ -f ../icons ] || mkdir -p ../icons

# Create icon files
"$ffmpeg_binary" -i ./batch_Normal.png -vf scale=48:48 -y ../icons/icon-48.png
"$ffmpeg_binary" -i ./batch_Enabled.png -vf scale=19:19 -y ../icons/icon-enabled-19.png
"$ffmpeg_binary" -i ./batch_Enabled.png -vf scale=38:38 -y ../icons/icon-enabled-38.png
"$ffmpeg_binary" -i ./batch_Disabled.png -vf scale=19:19 -y ../icons/icon-disabled-19.png
"$ffmpeg_binary" -i ./batch_Disabled.png -vf scale=38:38 -y ../icons/icon-disabled-38.png

# Strip metadata
exiftool -all= -overwrite_original ../icons/icon-*.png
}

main
270 changes: 270 additions & 0 deletions assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon-disabled-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon-disabled-38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon-enabled-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon-enabled-38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var browser = typeof browser !== "undefined" ? browser : chrome;
var enableRedirect = true;

function validate_onion_host(hostname) {
if (!hostname.endsWith("onion")) {
Expand All @@ -24,6 +25,9 @@ function validate_onion_host(hostname) {
}

function tor_redirect(details) {
// If disabled, don't care to redirect
if (!enableRedirect) return;

var onion_location_header = details.responseHeaders.find(function (header) {
return header['name'].toLowerCase() == 'onion-location';
});
Expand Down Expand Up @@ -82,3 +86,29 @@ browser.runtime.onMessage.addListener(function (message, sender, sendResponse) {
}
}
});

// Make sure correct icon and title (toolbar button tooltip) is shown
function updateIcon() {
browser.browserAction.setIcon({
path: enableRedirect ? {
19: "icons/icon-enabled-19.png",
38: "icons/icon-enabled-38.png"
} : {
19: "icons/icon-disabled-19.png",
38: "icons/icon-disabled-38.png"
}
});
browser.browserAction.setTitle({
// Screen readers can see the title
title: enableRedirect ? 'Onion Everywhere\n(Enabled - Click to toggle)' : 'Onion Everywhere\n(Disabled - Click to toggle)'
});
}
// Show proper icon and title on load
updateIcon();

// On toolbar button click
browser.browserAction.onClicked.addListener(function (tab) {
// Toggle
enableRedirect = ! enableRedirect;
updateIcon();
});
9 changes: 8 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "54.0"
"strict_min_version": "79.0"
}
},
"background": {
"scripts": ["index.js"]
},
"permissions": ["webRequest", "webRequestBlocking", "tabs", "<all_urls>"],
"browser_action": {
"default_icon": "icons/icon-48.png",
"default_title": "Onion Everywhere"
},
"icons": {
"48": "icons/icon-48.png"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
Expand Down