DayOne: feat: Update with Proxyman compatibility and new JSON

This commit is contained in:
PorridgePi
2023-09-18 13:44:02 +08:00
parent a2588234b2
commit e52ddbdc12

350
DayOne.js
View File

@@ -1,60 +1,306 @@
const featureBundle = { let isPremium = true; // if false, will use plus
"bundleName": "premium",
let feature_enrollments = [{
"id": 0,
"feature": "publish",
"createDate": "2011-11-11T00:00:00.000Z",
"status": "active",
"isActive": true
},
{
"id": 0,
"feature": "backup",
"createDate": "2011-11-11T00:00:00.000Z",
"status": "active",
"isActive": true
},
{
"id": 0,
"feature": "sync",
"createDate": "2011-11-11T00:00:00.000Z",
"status": "active",
"isActive": true
}
]
let subscription = {
"premium": isPremium,
"plus_on_ios": true,
"plus_on_mac": true,
"source": [
"Receipt"
],
"auto_renew": false,
"is_trial": false,
"expires": (isPremium ? "2099-12-31T23:59:59.999Z" : null),
"product_id": (isPremium ? "com.bloombuilt.dayoneios.subscription.premium.yearly" : null),
"is_eligible_for_trial": true,
"is_in_billing_retry_period": false
}
let bundle = {
"bundleName": (isPremium ? "premium" : "grandfathered"),
"reason": "purchase", "reason": "purchase",
"features": [{ "features": [{
"name": "imagesPerEntry", "name": "imagesPerEntry",
"limit": 30, "limit": (isPremium ? 30 : 10),
"canUpgrade": false "canUpgrade": !isPremium
}, { },
"name": "journalLimit", {
"limit": 100, "name": "imagesPerSharedEntry",
"canUpgrade": false "limit": 30,
}, { "canUpgrade": false
"name": "audioPerEntry", },
"limit": 10, {
"canUpgrade": false "name": "journalLimit",
}, { "limit": (isPremium ? 200 : 10),
"name": "backup", "canUpgrade": !isPremium
"limit": null, },
"canUpgrade": false ...(isPremium ? [{
}, { "name": "audioPerEntry",
"name": "sync", "limit": 10,
"limit": null, "canUpgrade": false
"canUpgrade": false }] : []),
}, { {
"name": "syncMac", "name": "sync",
"limit": null, "limit": null,
"canUpgrade": false "canUpgrade": false
}, { },
"name": "printingDiscount", {
"limit": null, "name": "backup",
"canUpgrade": false "limit": null,
}, { "canUpgrade": false
"name": "prioritySupport", },
"limit": null, ...(!isPremium ? [{
"canUpgrade": false "name": "discountedSubscription",
}] "limit": null,
"canUpgrade": false
}] : []),
...(isPremium ? [{
"name": "printingDiscount",
"limit": null,
"canUpgrade": false
}, {
"name": "prioritySupport",
"limit": null,
"canUpgrade": false
}, {
"name": "drawingsPerEntry",
"limit": 30,
"canUpgrade": false
}, {
"name": "scanToPDF",
"limit": 30,
"canUpgrade": false
}, {
"name": "videosPerEntry",
"limit": 30,
"canUpgrade": false
}, {
"name": "journalViaSMS",
"limit": null,
"canUpgrade": false
}] : [])
],
"featuresFull": [{
"name": "journalLimit",
"limit": (isPremium ? 200 : 10),
"canUpgrade": !isPremium
},
{
"name": "backup",
"enabled": true,
"canUpgrade": false
},
{
"name": "sync",
"enabled": true,
"canUpgrade": false
},
{
"name": "discountedSubscription",
"enabled": !isPremium,
"canUpgrade": false
},
{
"name": "printingDiscount",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "prioritySupport",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "scanToPDF",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "attachmentsPerEntry",
"limit": (isPremium ? 30 : 10),
"canUpgrade": !isPremium
},
{
"name": "journalViaSMS",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachPhoto",
"enabled": true,
"canUpgrade": false
},
{
"name": "canAttachVideo",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachAudio",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachDrawing",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachPDF",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachSharedPhoto",
"enabled": true,
"canUpgrade": false
},
{
"name": "canAttachSharedVideo",
"enabled": true,
"canUpgrade": false
},
{
"name": "canAttachSharedAudio",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachSharedDrawing",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "canAttachSharedPDF",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "attachmentsPerSharedEntry",
"limit": 30,
"canUpgrade": false
},
{
"name": "instagram",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "ifttt",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "colors",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "emailToJournal",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "appIcons",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "moonPhase",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "foursquareNearbyVenues",
"enabled": isPremium,
"canUpgrade": !isPremium
},
{
"name": "createSharedJournal",
"enabled": isPremium,
"canUpgrade": !isPremium
}
]
} }
const featureEnrollments_Sync = { let account_status = {
"id": 0, "subscriptionName": (isPremium ? "premium" : "grandfathered"),
"feature": "sync", "bundleReason": "purchase",
"createDate": "2011-11-11T00:00:00.000Z", "expirationDate": (isPremium ? 4102415999999 : null),
"status": "active", "giftedByName": null,
"isActive": true "source": (isPremium ? "receipt" : "min")
} }
var bodyOG = $response.body; async function onResponse(context, url, request, response) {
var body = JSON.parse(bodyOG); response.headers["Content-Type"] = "application/json";
response.statusCode = 200;
response.statusPhrase = "OK";
body["featureBundle"] = featureBundle let body = response.body;
body["subscription"]["premium"] = true
body["subscription"]["plus_on_mac"] = true
body["subscription"]["source"] = ["Receipt"]
body["subscription"]["auto_renew"] = true
body["subscription"]["expires"] = "2021-06-20T14:28:46.000Z"
body["subscription"]["product_id"] = "com.bloombuilt.dayoneios.subscription.premium.yearly_discounted_trial"
bodyOG = JSON.stringify(body); if (url.includes("account-status")) { // /account-status
console.log(bodyOG); body = account_status;
$done(bodyOG); } else { // /users OR /v2/users/receipt
body.subscription = subscription;
if (url.includes("v2")) { // /v2/users/receipt
body.bundle = bundle;
} else { // /users
body.featureBundle = bundle;
body.featureEnrollments = feature_enrollments;
}
}
response.body = body;
return response;
}
const isSurge = typeof $httpClient != "undefined";
const isQuanX = typeof $task != "undefined";
const isLoon = typeof $loon != "undefined";
const isJSBox = typeof $app != "undefined" && typeof $http != "undefined";
const isNode = typeof require == "function" && !isJSBox;
if (isSurge || isQuanX) {
url = $request.url;
$request.body = typeof $request.body != "undefined" ? JSON.parse($request.body) : {};
$response.body = typeof $response.body != "undefined" ? JSON.parse($response.body) : {};
response = onResponse(null, url, $request, $response);
if (isQuanX) {
$request.status = "HTTP/1.1 " + $request.statusCode + " " + $request.statusPhrase;
$response.status = "HTTP/1.1 " + $response.statusCode + " " + $response.statusPhrase;
$request.body = JSON.stringify($request.body);
$response.body = JSON.stringify($response.body);
}
$done({
status: $response.status,
headers: $response.headers,
body: $response.body
});
}