Danbooru

[Browser Extension] Upload to Danbooru

Posted under General

Bookmarklet: the browser extension.

Feedback/suggestions are welcome.

Links

Usage

Context menu: right click on any image, select "Upload to Danbooru".
Page action: just visit any Danbooru-supported page, then click 📦 cardboard box icon in the address bar.

There is options page available, it can be accessed from the extension details page after install. You can set custom server url (e.g https://testbooru.donmai.us/) or change how upload page is opened.

Note: In Chrome page action is not in the address bar, it needs to be enabled by clicking 🧩 extensions icon to the right of the address bar and pinning it manually.
Note: Although this extension allows you to upload images from any website, you should be careful to not to upload image sample from sites not supported by Danbooru. List of the supported sites can be found here.

Permissions rundown

  • activeTab - access to the current tab, used to extract image/page urls and to detect gallery pages (executes simple script running document.querySelectorAll())
  • declarativeContent (Chrome only) - configure url matching rules for page action
  • contextMenus - create context menu entry
  • storage - store settings

Changelog

  • v1.0.0 (27.07.2020) - Proof of Concept.
  • v1.0.1 (28.07.2020) - Chrome support.
  • v1.1.0 (29.07.2020) - Better referrer extraction heuristics with fallback to old bookmarklet behavior in dire situations.
  • v1.1.1 (30.07.2020) - Version bump for addons.mozilla.org release.
  • v1.2.0 (18.08.2020) - Refactor, test coverage, add page actions.
  • v1.2.1 (18.08.2020) - Chrome support for page actions.
  • v1.2.2 (22.08.2020) - (Chrome) Use declarativeContent api for toggling page action (requires less dangerous permission, should improve performance), fix warnings.
  • v1.2.3 (02.09.2020) - (Chrome) Open tabs next to the current one in Chrome.
  • v1.2.4 (24.09.2020) - Fix twitter batch detection when quote with images is present (example tweet, thanks @BrokenEagle98 for pointing out).
  • v1.3.0 (12.12.2020) - Sync supported sites with latest Danbooru. Add batch support for Pixiv Fanbox and mobile Nijie.
  • v1.3.1 (09.05.2021) - Add page action for Skeb. Introduce url normalizers for bilibili, discord, pinterest, fantia and pixiv fanbox/boost CDN urls.
  • v2.0.0 (17.01.2022) - Add page actions for Foundation.app, Lofter and Plurk. Add batch support for Skeb and Pawoo. (Chrome) manifest v3. Migrated batch detection to content scripts instead of direct code execution.
  • v2.1.0 (23.01.2022) - (Internal) Batch detectors are now lazy-loaded. (Chrome) Extension no longer requests host permissions on install.
  • v2.1.1 (30.01.2022) - Experimental Firefox for Android support.
  • v2.1.2 (12.02.2022) - Fixed crash when opening upload url with empty (never saved) settings.
  • v3.0.0 (14.03.2022) - Removed batch detector feature (effectively deprecated by media assets). Referrer is no longer extracted through content script injection.
  • v3.0.1 (14.03.2022) - Improve referrer extraction heuristics.
  • v3.1.0 (16.03.2022) - Split settings for page action/context menu. Add placeholder for Danbooru URL in settings. Fix context menu setup in Firefox.
  • v3.2.0 (17.07.2022) - Make context menu entry toggleable from the settings. (Chrome) Drop declarativeContent permission. (Chrome) Open Danbooru upload page for unsupported schemes on page action click.
  • v3.3.0 (14.03.2023) - Add new page action matching rules for enty, picdig, baraag, bilibili, arca.live, fandom.com, 4chan, gelbooru/safebooru/rule34 and instagram. Add dark theme support in settings.
  • v3.3.1 (12.05.2023) - Add new page action matching rules for misskey (.io, .art, .design), update bilibili matching rules.

Updated

Getting the following error when trying to load the unpacked extension on Chrome.

Failed to load extension
File
~\GitHub\Extensions\upload_to_danbooru
Error
Could not load icon 'icons/icon16.png' specified in 'page_action'.
Could not load manifest.
System
  • OS: Windows 8.1 (64-bit)
  • Browser: Chrome 84.0.4147.125 (Official Build) (64-bit) (cohort: Stable)
  • Extension: upload_to_danbooru-1.2.1-chrome.zip
Edit:

This issue has been resolved. It was a PEBKAC error.

Updated

Danbooru does not support bookmarklet uploads from bilibili (aside from direct links) atm. Ideally it should be implemented Danbooru-side first.

But otherwise for t.bilibili.com (like post #4498750), probably yes. Normalizing url looks trivial enough. For videos and manga - unlikely.

I encountered 2 errors when trying to load version 2.0.0 on Chrome.

1. Unrecognized manifest key

https://cdn.discordapp.com/attachments/618878216815247372/933063232107741184/unknown.png

After I deleted that manifest key, I tried it again but encountered the next error.

2. Cannot read properties of undefined

https://cdn.discordapp.com/attachments/618878216815247372/933063524555558953/unknown.png

Edit:
  • (2022-01-18)
    • ZipFile added upload_to_danbooru-2.0.0-chrome.zip to the release which fixed the issue.

Updated

1