SHOW:
|
|
- or go back to the newest paste.
| 1 | - | javascript:(function(){let baseUrl="https://www.amazon.com/auto-deliveries/ajax/cancelSubscriptionAction?actionType=cancelSubscription&canceledNextDeliveryDate=1730880000000&subscriptionId=";let spans=document.querySelectorAll(%27span[data-action="edit-link-subscription-tablet"]%27);let subscriptionIds=[...spans].map(span=>{let data=span.getAttribute(%27data-edit-link-subscription-tablet%27);let match=data.match(/subscriptionId=([^&"]+)/);return match?match[1]:null;}).filter(id=>id);console.log(`Found ${subscriptionIds.length} subscription IDs.`);function openNextUrl(index){if(index>=subscriptionIds.length){console.log(%27All URLs have been opened.%27);return;}let id=subscriptionIds[index];let url=baseUrl+id;console.log(`Opening URL: ${url}`);let newWindow=window.open(url,%27_blank%27);setTimeout(()=>{openNextUrl(index+1);},1000);}openNextUrl(0);})(); |
| 1 | + | await Promise.all([...document.querySelectorAll('[data-subscription-id]')]
|
| 2 | .map(el => el.getAttribute('data-subscription-id'))
| |
| 3 | .map(async (subscriptionId) => {
| |
| 4 | try {
| |
| 5 | const res = await fetch(`https://www.amazon.com.au/auto-deliveries/ajax/cancelSubscription?deviceType=desktop&deviceContext=web&subscriptionId=${subscriptionId}`)
| |
| 6 | const cancelPanel = await res.text() | |
| 7 | ||
| 8 | const div = document.createElement('div')
| |
| 9 | div.innerHTML = cancelPanel | |
| 10 | document.body.appendChild(div) | |
| 11 | ||
| 12 | const form = div.querySelector("form[name='cancelForm']")
| |
| 13 | if (form) {
| |
| 14 | const formData = new FormData(form) | |
| 15 | const formEntries = Object.fromEntries(formData.entries()) | |
| 16 | ||
| 17 | await fetch(form.action, {
| |
| 18 | method: form.method, | |
| 19 | headers: {
| |
| 20 | 'Content-Type': 'application/x-www-form-urlencoded', | |
| 21 | }, | |
| 22 | body: new URLSearchParams(formEntries) | |
| 23 | }) | |
| 24 | ||
| 25 | div.remove() | |
| 26 | } | |
| 27 | ||
| 28 | return 'ok' | |
| 29 | } catch (reason) {
| |
| 30 | return `error: ${reason}`
| |
| 31 | } | |
| 32 | }) | |
| 33 | ) |