Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created July 12, 2025 08:22
Show Gist options
  • Save netsi1964/346f42a44101605f44d09ba22aa55aec to your computer and use it in GitHub Desktop.
Save netsi1964/346f42a44101605f44d09ba22aa55aec to your computer and use it in GitHub Desktop.
Extract PayPal transaction data directly from your browser with a single click! This bookmarklet parses PayPal's transaction history page and exports the data as JSON.

Bookmarklet: PayPal Transaction Extractor

Extract PayPal transaction data directly from your browser with a single click! This bookmarklet parses PayPal's transaction history page and exports the data as JSON.

πŸš€ Quick Start

  1. Copy the bookmarklet code below
  2. Create a new bookmark in your browser
  3. Paste the code as the URL
  4. Click the bookmark when on PayPal's transaction page

πŸ“‹ Features

  • βœ… Extract transaction ID, date, recipient, amount, currency, and status
  • βœ… Handles both DKK and foreign currencies
  • βœ… Automatically downloads JSON file with smart date-range filename
  • βœ… Displays formatted data in console
  • βœ… Sorts transactions by date (newest first)
  • βœ… Includes direct links to transaction details

πŸ”– Bookmarklet Code

javascript:(function(){console.log('πŸš€ Starting PayPal transaction extraction...');const transactionRows=document.querySelectorAll('tr[data-testid]');console.log(`πŸ“Š Found ${transactionRows.length} potential transactions`);const transactions=[];transactionRows.forEach(row=>{const testId=row.getAttribute('data-testid');if(!testId||testId.length<10)return;const dateCell=row.querySelector(`td[data-testid="${testId}-date"]`);const descriptionCell=row.querySelector(`td[data-testid="${testId}-description"]`);const nameCell=row.querySelector(`td[data-testid="${testId}-name"]`);const grossCell=row.querySelector(`td[data-testid="${testId}-gross"]`);const statusCell=row.querySelector(`td[data-testid="${testId}-status"]`);if(!dateCell||!descriptionCell||!nameCell||!grossCell)return;const date=dateCell.textContent.trim();const description=descriptionCell.textContent.trim();const status=statusCell?statusCell.textContent.trim():'N/A';const nameLink=nameCell.querySelector('a');const recipient=nameLink?nameLink.textContent.trim():nameCell.textContent.trim();const transactionLink=nameLink?nameLink.getAttribute('href'):null;const fullTransactionLink=transactionLink?`https://www.paypal.com${transactionLink}`:null;const amountDiv=grossCell.querySelector('div');const amountText=amountDiv?amountDiv.textContent.trim():grossCell.textContent.trim();let amount=null;let currency=null;let amountDKK=null;let originalAmount=null;let originalCurrency=null;const amountRegex=/([0-9.,]+)\s*([A-Z$€£Β₯β‚Ήβ‚½]+)\s*([A-Z]{3})?/;const match=amountText.match(amountRegex);if(match){amount=parseFloat(match[1].replace(',','.'));currency=match[3]||(match[2]==='$'?'USD':match[2]==='€'?'EUR':match[2]==='Β£'?'GBP':match[2]);if(currency==='DKK'){amountDKK=amount;}else{originalAmount=amount;originalCurrency=currency;}}const convertDate=(dateStr)=>{const[datePart,timePart]=dateStr.split(', ');const[day,month,year]=datePart.split('/');const[hour,minute]=timePart.split('.');return new Date(year,month-1,day,hour,minute).toISOString();};const transaction={transactionId:testId,date:date,dateISO:convertDate(date),description:description,recipient:recipient,status:status,amount:amount,currency:currency,amountDKK:amountDKK,originalAmount:originalAmount,originalCurrency:originalCurrency,amountText:amountText,transactionLink:fullTransactionLink};transactions.push(transaction);});transactions.sort((a,b)=>new Date(b.dateISO)-new Date(a.dateISO));console.log(`βœ… Extracted ${transactions.length} transactions:`);console.log('πŸ“‹ Transaction data:',transactions);window.paypalTransactions=transactions;console.table(transactions.map(t=>({Date:t.date,Recipient:t.recipient,Amount:t.amountText,Status:t.status,Description:t.description})));const jsonOutput=JSON.stringify(transactions,null,2);console.log('\nπŸ“„ JSON Output (copy this):');console.log(jsonOutput);const getFileName=()=>{if(transactions.length===0)return`paypal-transactions-${new Date().toISOString().split('T')[0]}.json`;const dates=transactions.map(t=>new Date(t.dateISO));const minDate=new Date(Math.min(...dates));const maxDate=new Date(Math.max(...dates));const formatDate=d=>d.toISOString().split('T')[0];return`Paypal-from-${formatDate(minDate)}-to-${formatDate(maxDate)}.json`;};const blob=new Blob([jsonOutput],{type:'application/json'});const url=URL.createObjectURL(blob);const a=document.createElement('a');a.href=url;a.download=getFileName();document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);console.log('πŸ’Ύ JSON file downloaded automatically!');console.log('🎯 Data also available in: window.paypalTransactions');return transactions;})();

πŸ“– How to Create the Bookmark

Chrome/Edge/Safari:

  1. Copy the entire bookmarklet code above
  2. Right-click on your bookmarks bar (show with Ctrl+Shift+B if hidden)
  3. Select "Add page" or "Add bookmark"
  4. Name: PayPal Extractor
  5. URL: Paste the copied JavaScript code
  6. Save the bookmark

Firefox:

  1. Copy the entire bookmarklet code above
  2. Right-click on your bookmarks bar
  3. Select "New Bookmark"
  4. Name: PayPal Extractor
  5. Location: Paste the copied JavaScript code
  6. Save

🎯 Usage

  1. Navigate to your PayPal transaction history page
  2. Click the bookmarklet in your bookmarks bar
  3. Open Developer Console (F12) to see the results
  4. The JSON file will be automatically downloaded

πŸ“ Smart File Naming

The downloaded JSON file will automatically be named based on the date range of your transactions:

  • Format: Paypal-from-YYYY-MM-DD-to-YYYY-MM-DD.json
  • Example: Paypal-from-2024-01-19-to-2024-02-24.json
  • Fallback: If no transactions found, uses current date: paypal-transactions-YYYY-MM-DD.json

This makes it easy to identify which time period the data covers!

πŸ“Š Sample JSON Output

[
  {
    "transactionId": "234792349M9284",
    "date": "19/01/2021, 12.56",
    "dateISO": "2021-01-19T12:56:00.000Z",
    "description": "Payment to",
    "recipient": "WWW",
    "status": "Completed",
    "amount": 1.00,
    "currency": "USD",
    "amountDKK": null,
    "originalAmount": 1.00,
    "originalCurrency": "USD",
    "amountText": "1,00 $ USD",
    "transactionLink": "https://www.paypal.com/unifiedtransactions/details/payment/234792349M9284"
  }
]

πŸ”§ Technical Details

  • Data Source: Extracts from PayPal's HTML table structure
  • Compatibility: Works with modern browsers (Chrome, Firefox, Safari, Edge)
  • Security: Runs entirely in your browser, no data sent to external servers
  • Format: Exports as JSON with ISO date formatting
  • Sorting: Automatically sorts transactions by date (newest first)

🀝 Contributing

Feel free to fork this gist and improve the bookmarklet! Some ideas for enhancements:

  • Add support for more transaction types
  • Include fee information
  • Add currency conversion
  • Export to CSV format

πŸ“œ License

This bookmarklet is provided as-is for personal use. Use at your own risk.

javascript:(function(){console.log('πŸš€ Starting PayPal transaction extraction...');const transactionRows=document.querySelectorAll('tr[data-testid]');console.log(`πŸ“Š Found ${transactionRows.length} potential transactions`);const transactions=[];transactionRows.forEach(row=>{const testId=row.getAttribute('data-testid');if(!testId||testId.length<10)return;const dateCell=row.querySelector(`td[data-testid="${testId}-date"]`);const descriptionCell=row.querySelector(`td[data-testid="${testId}-description"]`);const nameCell=row.querySelector(`td[data-testid="${testId}-name"]`);const grossCell=row.querySelector(`td[data-testid="${testId}-gross"]`);const statusCell=row.querySelector(`td[data-testid="${testId}-status"]`);if(!dateCell||!descriptionCell||!nameCell||!grossCell)return;const date=dateCell.textContent.trim();const description=descriptionCell.textContent.trim();const status=statusCell?statusCell.textContent.trim():'N/A';const nameLink=nameCell.querySelector('a');const recipient=nameLink?nameLink.textContent.trim():nameCell.textContent.trim();const transactionLink=nameLink?nameLink.getAttribute('href'):null;const fullTransactionLink=transactionLink?`https://www.paypal.com${transactionLink}`:null;const amountDiv=grossCell.querySelector('div');const amountText=amountDiv?amountDiv.textContent.trim():grossCell.textContent.trim();let amount=null;let currency=null;let amountDKK=null;let originalAmount=null;let originalCurrency=null;const amountRegex=/([0-9.,]+)\s*([A-Z$€£Β₯β‚Ήβ‚½]+)\s*([A-Z]{3})?/;const match=amountText.match(amountRegex);if(match){amount=parseFloat(match[1].replace(',','.'));currency=match[3]||(match[2]==='$'?'USD':match[2]==='€'?'EUR':match[2]==='Β£'?'GBP':match[2]);if(currency==='DKK'){amountDKK=amount;}else{originalAmount=amount;originalCurrency=currency;}}const convertDate=(dateStr)=>{const[datePart,timePart]=dateStr.split(', ');const[day,month,year]=datePart.split('/');const[hour,minute]=timePart.split('.');return new Date(year,month-1,day,hour,minute).toISOString();};const transaction={transactionId:testId,date:date,dateISO:convertDate(date),description:description,recipient:recipient,status:status,amount:amount,currency:currency,amountDKK:amountDKK,originalAmount:originalAmount,originalCurrency:originalCurrency,amountText:amountText,transactionLink:fullTransactionLink};transactions.push(transaction);});transactions.sort((a,b)=>new Date(b.dateISO)-new Date(a.dateISO));console.log(`βœ… Extracted ${transactions.length} transactions:`);console.log('πŸ“‹ Transaction data:',transactions);window.paypalTransactions=transactions;console.table(transactions.map(t=>({Date:t.date,Recipient:t.recipient,Amount:t.amountText,Status:t.status,Description:t.description})));const jsonOutput=JSON.stringify(transactions,null,2);console.log('\nπŸ“„ JSON Output (copy this):');console.log(jsonOutput);const getFileName=()=>{if(transactions.length===0)return`paypal-transactions-${new Date().toISOString().split('T')[0]}.json`;const dates=transactions.map(t=>new Date(t.dateISO));const minDate=new Date(Math.min(...dates));const maxDate=new Date(Math.max(...dates));const formatDate=d=>d.toISOString().split('T')[0];return`Paypal-from-${formatDate(minDate)}-to-${formatDate(maxDate)}.json`;};const blob=new Blob([jsonOutput],{type:'application/json'});const url=URL.createObjectURL(blob);const a=document.createElement('a');a.href=url;a.download=getFileName();document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);console.log('πŸ’Ύ JSON file downloaded automatically!');console.log('🎯 Data also available in: window.paypalTransactions');return transactions;})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment