DayOne: feat: Update with Proxyman compatibility and new JSON
This commit is contained in:
354
DayOne.js
354
DayOne.js
@@ -1,60 +1,306 @@
|
|||||||
const featureBundle = {
|
let isPremium = true; // if false, will use plus
|
||||||
"bundleName": "premium",
|
|
||||||
"reason": "purchase",
|
let feature_enrollments = [{
|
||||||
"features": [{
|
"id": 0,
|
||||||
"name": "imagesPerEntry",
|
"feature": "publish",
|
||||||
"limit": 30,
|
"createDate": "2011-11-11T00:00:00.000Z",
|
||||||
"canUpgrade": false
|
"status": "active",
|
||||||
}, {
|
"isActive": true
|
||||||
"name": "journalLimit",
|
},
|
||||||
"limit": 100,
|
{
|
||||||
"canUpgrade": false
|
"id": 0,
|
||||||
}, {
|
"feature": "backup",
|
||||||
"name": "audioPerEntry",
|
"createDate": "2011-11-11T00:00:00.000Z",
|
||||||
"limit": 10,
|
"status": "active",
|
||||||
"canUpgrade": false
|
"isActive": true
|
||||||
}, {
|
},
|
||||||
"name": "backup",
|
{
|
||||||
"limit": null,
|
"id": 0,
|
||||||
"canUpgrade": false
|
"feature": "sync",
|
||||||
}, {
|
"createDate": "2011-11-11T00:00:00.000Z",
|
||||||
"name": "sync",
|
"status": "active",
|
||||||
"limit": null,
|
"isActive": true
|
||||||
"canUpgrade": false
|
}
|
||||||
}, {
|
]
|
||||||
"name": "syncMac",
|
|
||||||
"limit": null,
|
let subscription = {
|
||||||
"canUpgrade": false
|
"premium": isPremium,
|
||||||
}, {
|
"plus_on_ios": true,
|
||||||
"name": "printingDiscount",
|
"plus_on_mac": true,
|
||||||
"limit": null,
|
"source": [
|
||||||
"canUpgrade": false
|
"Receipt"
|
||||||
}, {
|
],
|
||||||
"name": "prioritySupport",
|
"auto_renew": false,
|
||||||
"limit": null,
|
"is_trial": false,
|
||||||
"canUpgrade": 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
|
||||||
}
|
}
|
||||||
|
|
||||||
const featureEnrollments_Sync = {
|
let bundle = {
|
||||||
"id": 0,
|
"bundleName": (isPremium ? "premium" : "grandfathered"),
|
||||||
"feature": "sync",
|
"reason": "purchase",
|
||||||
"createDate": "2011-11-11T00:00:00.000Z",
|
"features": [{
|
||||||
"status": "active",
|
"name": "imagesPerEntry",
|
||||||
"isActive": true
|
"limit": (isPremium ? 30 : 10),
|
||||||
|
"canUpgrade": !isPremium
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "imagesPerSharedEntry",
|
||||||
|
"limit": 30,
|
||||||
|
"canUpgrade": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "journalLimit",
|
||||||
|
"limit": (isPremium ? 200 : 10),
|
||||||
|
"canUpgrade": !isPremium
|
||||||
|
},
|
||||||
|
...(isPremium ? [{
|
||||||
|
"name": "audioPerEntry",
|
||||||
|
"limit": 10,
|
||||||
|
"canUpgrade": false
|
||||||
|
}] : []),
|
||||||
|
{
|
||||||
|
"name": "sync",
|
||||||
|
"limit": null,
|
||||||
|
"canUpgrade": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "backup",
|
||||||
|
"limit": null,
|
||||||
|
"canUpgrade": false
|
||||||
|
},
|
||||||
|
...(!isPremium ? [{
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
var bodyOG = $response.body;
|
let account_status = {
|
||||||
var body = JSON.parse(bodyOG);
|
"subscriptionName": (isPremium ? "premium" : "grandfathered"),
|
||||||
|
"bundleReason": "purchase",
|
||||||
|
"expirationDate": (isPremium ? 4102415999999 : null),
|
||||||
|
"giftedByName": null,
|
||||||
|
"source": (isPremium ? "receipt" : "min")
|
||||||
|
}
|
||||||
|
|
||||||
body["featureBundle"] = featureBundle
|
async function onResponse(context, url, request, response) {
|
||||||
body["subscription"]["premium"] = true
|
response.headers["Content-Type"] = "application/json";
|
||||||
body["subscription"]["plus_on_mac"] = true
|
response.statusCode = 200;
|
||||||
body["subscription"]["source"] = ["Receipt"]
|
response.statusPhrase = "OK";
|
||||||
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);
|
let body = response.body;
|
||||||
console.log(bodyOG);
|
|
||||||
$done(bodyOG);
|
if (url.includes("account-status")) { // /account-status
|
||||||
|
body = account_status;
|
||||||
|
} 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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user