Skip to content

Instantly share code, notes, and snippets.

View wilmtang's full-sized avatar

William Tang wilmtang

View GitHub Profile
@wilmtang
wilmtang / cancelAmazonSub.js
Last active November 23, 2025 08:23
Cancels all subscriptions in Amazon Subscribe and Save
// This script cancels all subscriptions in Amazon Subscribe and Save, which is fairly annoying to do manually one by one (it's def intentional)
// Inspired by reddit post https://www.reddit.com/r/amazonprime/comments/1d3agri/mass_cancel_move_all_subscribe_save_items_in_bulk
// Improved on getting subscriptionId, and fetching the urls (so it doesn't open a new tab on every unsub)
// Ussage
// 1. Visit this URL showing all subs: https://www.amazon.com/auto-deliveries/subscriptionList?listFilter=active
// 2. Press the "Show more subscriptions" button until you can see every item you're subscribed to
// 3. Open developer tool(cmd + opt + i) and paste the following into Javascript console. Then hit Enter
// 4. Profit
struct Resource<T> {
let url: URL
// Other properties and methods
}
class NetworkManager {
func load<T>(resource: Resource<T>, withCompletion completion: @escaping (T?) -> Void) {
let session = URLSession(configuration: .ephemeral, delegate: nil, delegateQueue: .main)
let task = session.dataTask(with: resource.url, completionHandler: { (data: Data?, response: URLResponse?, error: Error?) -> Void in
guard let data = data else {
@wilmtang
wilmtang / Detect_IE7_for_ajax.html
Last active September 6, 2015 09:03
Detect IE7 for ajax
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5