Skip to content

Commit

Permalink
Add Chrome support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZipFile committed Jul 29, 2020
1 parent b2bebd1 commit 8a7adbd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
web-ext-artifacts/
browser-polyfill.js
*.pem
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ cp node_modules/webextension-polyfill/dist/browser-polyfill.js .
web-ext build -n upload_to_danbooru.zip -i README.md
```

### Chrome

```sh
npm install --global crx3
test -f key.pem || openssl genrsa -out key.pem 4096
crx3 -p key.pem -o web-ext-artifacts/upload_to_danbooru.crx < web-ext-artifacts/upload_to_danbooru.zip
```

## Install

```sh
firefox web-ext-artifacts/upload_to_danbooru.zip
```

### Chrome

Open `chrome://extensions`, enable `Developer mode`, then drop
`web-ext-artifacts/upload_to_danbooru.crx` onto the page.
3 changes: 2 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ browser.contextMenus.onClicked.addListener(async function(info, tab) {

const settings = await browser.storage.sync.get(['url', 'openIn']);
const danbooruUrl = settings.url || DefaultDanbooruURL;
const batch = info.modifiers.some((key) => key === "Ctrl");
const batch = (info.modifiers || []).some((key) => key === "Ctrl");
let url, active = true;

if (batch) {
Expand All @@ -30,6 +30,7 @@ browser.contextMenus.onClicked.addListener(async function(info, tab) {
switch (settings.openIn) {
case "current":
await browser.tabs.update(tab.id, {url: url.href});
break;
case "background":
active = false
default:
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Upload to Danbooru",
"description": "Add a context menu option for images to upload to Danbooru.",
"version": "1.0.0",
"version": "1.0.1",
"options_ui": {
"page": "options.html",
"browser_style": true
Expand Down

0 comments on commit 8a7adbd

Please sign in to comment.