Fix DownloadCollection.user.js for new Bandcamp collection page (v1.5)#39
Open
rmilev wants to merge 1 commit into
Open
Fix DownloadCollection.user.js for new Bandcamp collection page (v1.5)#39rmilev wants to merge 1 commit into
rmilev wants to merge 1 commit into
Conversation
The collection page changed shape in 2025/2026: it now ships only the
first ~20 items in the DOM behind a "view all N items" button and
loads the rest via the /api/fancollection/1/collection_items endpoint.
window.CollectionGrids.collection.paginate() no longer exists, the
"Retry pagination" button would throw, and the old DOM-scroll auto-scan
never completes.
Rewire the script to:
* seed item state from the page's #pagedata blob (item_cache,
redownload_urls, last_token, fan_id, item_count),
* page through the fancollection API in 20-item batches (with a
small delay — Bandcamp returns more_available:false on rapid
back-to-back requests) to load the rest,
* key items by {sale_item_type_char}{sale_item_id} because the API
response returns items as an array rather than a keyed object,
* look up redownload URLs by the item's sale_item_type prefix
(Bandcamp keys them 'p'/'a'/'t', not just 'p'),
* drop the now-broken "Retry pagination" button,
* split the Download/Range controls into two rows so they group
logically, and
* force readable button/input colors — Bandcamp's site CSS now
leaves them invisible.
Tested against a 416-item collection: all items load and all
purchased items resolve to their download URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bandcamp changed the collection page some time in 2025/2026 and the existing
DownloadCollection.user.jsno longer works: scanning finds 0–20 items, Auto-scan never completes, and the "Retry pagination" button throws.This PR rewires the script around Bandcamp's current page model:
view all N itemsbutton. The rest live behindPOST /api/fancollection/1/collection_items(request body:{fan_id, older_than_token, count}; response:{items, redownload_urls, last_token, more_available, ...}).window.CollectionGrids.collection.paginate()no longer exists, so the old "Retry pagination" button is dead code.document.querySelector('#pagedata').dataset.blob(item_cache.collection,collection_data.{redownload_urls,last_token,item_count},fan_data.fan_id).What changed
#pagedataon script load (fan id, initial item cache, initial redownload URLs, initial pagination cursor, total item count).fetchAllItems()pages through the fancollection API in 20-item batches with a ~150ms gap between requests — without the gap Bandcamp returnsmore_available: falseon the second call. Verified end-to-end on a 416-item collection.itemKey(item)rebuilds the{type_char}{id}key for items returned by the API (the response uses an array, not the keyed-object format that#pagedata.item_cacheuses).findDownloadUrl(item)looks up redownload URLs by{sale_item_type}{sale_item_id}rather than always assuming apprefix — Bandcamp keys'p'for packages,'a'for albums,'t'for tracks..collection-item-container(which only ever contains the first batch).fetchAllItemsand then triggers Scan, instead of the old click-then-scroll loop that doesn't terminate on the new page.paginate()call would throw..controlsrows so they group logically.@versionbumped to 1.5.Test plan
bandcamp.com/<your-username>with a 416-item collection40 / 416 → 60 / 416 → ... → 416 / 416download?from=&payment_id=&sig=&sitem_id=format