Skip to content

Instantly share code, notes, and snippets.

@gglnx
Created February 12, 2021 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gglnx/5615ac4ecd148c96ce3b30cdf385ed2e to your computer and use it in GitHub Desktop.
Save gglnx/5615ac4ecd148c96ce3b30cdf385ed2e to your computer and use it in GitHub Desktop.
Download all data request files from Amazon

Open the Privacy Central Data Request page.

Run this in your console

(await Promise.all(
    Array.from(document.querySelectorAll('[data-action="get-document-link-and-download"]'))
        .map(async ($el) => {
            const data = JSON.parse($el.dataset.getDocumentLinkAndDownload);
            const requestData = {
                customerID: data.customerID,
                documentVersionID: data.documentVersionID,
                friendlyName: data.contentName,
                requestID: data.requestID,
                documentStatus: data.documentStatus,
                documentID: data.documentID,
                documentRetainTill: data.documentRetainTill,
                documentSize: data.documentSize,
                documentMIMEType: data.documentMIMEType,
                documentCreationDate: data.documentCreationDate,
                documentValidTill: data.documentValidTill,
                csrfToken: data.csrfToken,
            };

            const url = new URL(document.location);
            url.pathname = '/gp/privacycentral/dsar/ajax/download-action.html';
            Object.keys(requestData)
                .forEach(key => url.searchParams.append(key, requestData[key]));

            const request = await fetch(url);
            const response = await request.json();
            
            return response.documentURL;
        })
)).join("\n");

Copy the output into a download.txt and then download all with wget -i download.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment