Skip to content

Commit

Permalink
Support cara
Browse files Browse the repository at this point in the history
  • Loading branch information
qsniyg committed Nov 7, 2023
1 parent a9f607d commit f5c1f45
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Improvements:

* Various improvements/fixes to existing rules (including Cloudinary, Google, Nitter, PeerTube)

Special thanks to sn3akyb3ar, fireattack, oifj34f34f, doio, Rotes!, ValiumBear, bigdiff, remlap, Flame, puddyplexer for their contributions and reports for this release
Special thanks to sn3akyb3ar, fireattack, oifj34f34f, doio, Rotes!, ValiumBear, bigdiff, remlap, Flame, puddyplexer, Anon_Ymou5 for their contributions and reports for this release

---

Expand Down
91 changes: 91 additions & 0 deletions src/userscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31888,6 +31888,8 @@ var $$IMU_EXPORT$$;
// https://s13emagst.akamaized.net/products/43324/43323414/images/res_75bf76c9d8450a07ecb29cb8fce9cc64.jpg?width=300&height=300&hash=CCF5DBDA23683CC1B3880BDBC810E3A9
// https://s13emagst.akamaized.net/products/43324/43323414/images/res_75bf76c9d8450a07ecb29cb8fce9cc64.jpg
(domain === "s13emagst.akamaized.net" && /\/products\/+[0-9]+\/+[0-9]+\/+images\//.test(src)) ||
// https://content.api.news/v3/images/bin/883a2c349f46b70366c8d18ea433a7df?width=100
(domain === "content.api.news" && /\/v3\/+images\/+bin\/+[0-9a-f]{10,}/.test(src)) ||
// http://us.jimmychoo.com/dw/image/v2/AAWE_PRD/on/demandware.static/-/Sites-jch-master-product-catalog/default/dw70b1ebd2/images/rollover/LIZ100MPY_120004_MODEL.jpg?sw=245&sh=245&sm=fit
// https://www.aritzia.com/on/demandware.static/-/Library-Sites-Aritzia_Shared/default/dw3a7fef87/seasonal/ss18/ss18-springsummercampaign/ss18-springsummercampaign-homepage/hptiles/tile-wilfred-lrg.jpg
src.match(/\/demandware\.static\//) ||
Expand Down Expand Up @@ -76464,6 +76466,95 @@ var $$IMU_EXPORT$$;
return newsrc;
}

if (domain_nowww === "cara.app") {
let get_cara_imageid = function(url) {
return url.replace(/.*\/posts\/+[-0-9a-f]{20,}\/[^-/.?#]+-([^-/.?#]+)-[^/]+(?:[?#].*)?$/, "$1");
};

// thanks to Anon_Ymou5 on reddit for reporting: https://www.reddit.com/r/MaxImage/comments/170nru5/image_max_url_2023100_is_released_130_new/k7vabt4/
newsrc = website_query({
website_regex: /^[a-z]+:\/\/[^/]+\/+post\/+([-0-9a-f]{20,})(?:[?#].*)?$/,
query_for_id: {
url: "https://cara.app/api/posts/${id}",
headers: {
"Accept": "application/json, text/plain, */*"
},
json: true,
imu_mode: "xhr"
},
override_cb: function(cb, data) {
if (!data) return cb(data);

var queries = common_functions["parse_imu_hash"](src);
let imageid = null;
let found_imageid = -1;
if (queries && queries.url) {
imageid = get_cara_imageid(decodeuri_ifneeded(queries.url));
}

for (let link of data.album_info.links) {
link.is_current = false;
}

let found = false;
for (let link of data.album_info.links) {
let link_id = get_cara_imageid(link.url);
if (link_id === imageid) {
found = true;
link.is_current = true;
data.url = link.url;
break;
}
}

if (!found) {
data.url = data.album_info.links[0].url;
data.album_info.links[0].is_current = true;
}

cb(data);
},
process: function(done, resp, cache_key) {
let obj:BigImageInfoSObject = {
album_info: {
type: "links",
links: []
},
extra: {
created_date: new Date(resp.data.createdAt).getTime(),
caption: resp.data.title,
author_username: resp.data.slug,
page: "https://cara.app/post/" + resp.data.id
}
};

for (let image of resp.data.images) {
if (image.isCoverImg)
continue;

obj.album_info.links.push({
url: "https://cdn.cara.app/" + image.src,
is_current: false
});
}

done(obj, 6*60*60);
}
});
if (newsrc) return newsrc;
}

if (domain === "cdn.cara.app") {
// thanks to Anon_Ymou5 on reddit for reporting: https://www.reddit.com/r/MaxImage/comments/170nru5/image_max_url_2023100_is_released_130_new/k7vabt4/
match = src.match(/\/production\/+posts\/+([-0-9a-f]{20,})\/+/);
if (match) {
return {
url: "https://cara.app/post/" + match[1] + "#imu-url=" + encodeURIComponent(src),
is_pagelink: true
};
}
}

if (domain_nosub === "fashionnetwork.com" && /^(?:[a-z]+\.)?media\./.test(domain)) {
// http://media.fashionnetwork.com/m/2884/966d/1620/d702/c1de/b152/ad09/33fa/3832/bc32/487x272.72/bc32.jpg
// http://media.fashionnetwork.com/m/2884/966d/1620/d702/c1de/b152/ad09/33fa/3832/bc32/bc32.jpg
Expand Down
85 changes: 85 additions & 0 deletions userscript.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -29120,6 +29120,8 @@ var $$IMU_EXPORT$$;
// https://s13emagst.akamaized.net/products/43324/43323414/images/res_75bf76c9d8450a07ecb29cb8fce9cc64.jpg?width=300&height=300&hash=CCF5DBDA23683CC1B3880BDBC810E3A9
// https://s13emagst.akamaized.net/products/43324/43323414/images/res_75bf76c9d8450a07ecb29cb8fce9cc64.jpg
(domain === "s13emagst.akamaized.net" && /\/products\/+[0-9]+\/+[0-9]+\/+images\//.test(src)) ||
// https://content.api.news/v3/images/bin/883a2c349f46b70366c8d18ea433a7df?width=100
(domain === "content.api.news" && /\/v3\/+images\/+bin\/+[0-9a-f]{10,}/.test(src)) ||
// http://us.jimmychoo.com/dw/image/v2/AAWE_PRD/on/demandware.static/-/Sites-jch-master-product-catalog/default/dw70b1ebd2/images/rollover/LIZ100MPY_120004_MODEL.jpg?sw=245&sh=245&sm=fit
// https://www.aritzia.com/on/demandware.static/-/Library-Sites-Aritzia_Shared/default/dw3a7fef87/seasonal/ss18/ss18-springsummercampaign/ss18-springsummercampaign-homepage/hptiles/tile-wilfred-lrg.jpg
src.match(/\/demandware\.static\//) ||
Expand Down Expand Up @@ -68991,6 +68993,89 @@ var $$IMU_EXPORT$$;
if (newsrc !== src)
return newsrc;
}
if (domain_nowww === "cara.app") {
var get_cara_imageid_1 = function(url) {
return url.replace(/.*\/posts\/+[-0-9a-f]{20,}\/[^-/.?#]+-([^-/.?#]+)-[^/]+(?:[?#].*)?$/, "$1");
};
// thanks to Anon_Ymou5 on reddit for reporting: https://www.reddit.com/r/MaxImage/comments/170nru5/image_max_url_2023100_is_released_130_new/k7vabt4/
newsrc = website_query({
website_regex: /^[a-z]+:\/\/[^/]+\/+post\/+([-0-9a-f]{20,})(?:[?#].*)?$/,
query_for_id: {
url: "https://cara.app/api/posts/${id}",
headers: {
"Accept": "application/json, text/plain, */*"
},
json: true,
imu_mode: "xhr"
},
override_cb: function(cb, data) {
if (!data)
return cb(data);
var queries = common_functions["parse_imu_hash"](src);
var imageid = null;
var found_imageid = -1;
if (queries && queries.url) {
imageid = get_cara_imageid_1(decodeuri_ifneeded(queries.url));
}
for (var _i = 0, _a = data.album_info.links; _i < _a.length; _i++) {
var link_1 = _a[_i];
link_1.is_current = false;
}
var found = false;
for (var _b = 0, _c = data.album_info.links; _b < _c.length; _b++) {
var link_2 = _c[_b];
var link_id = get_cara_imageid_1(link_2.url);
if (link_id === imageid) {
found = true;
link_2.is_current = true;
data.url = link_2.url;
break;
}
}
if (!found) {
data.url = data.album_info.links[0].url;
data.album_info.links[0].is_current = true;
}
cb(data);
},
process: function(done, resp, cache_key) {
var obj = {
album_info: {
type: "links",
links: []
},
extra: {
created_date: new Date(resp.data.createdAt).getTime(),
caption: resp.data.title,
author_username: resp.data.slug,
page: "https://cara.app/post/" + resp.data.id
}
};
for (var _i = 0, _a = resp.data.images; _i < _a.length; _i++) {
var image = _a[_i];
if (image.isCoverImg)
continue;
obj.album_info.links.push({
url: "https://cdn.cara.app/" + image.src,
is_current: false
});
}
done(obj, 6 * 60 * 60);
}
});
if (newsrc)
return newsrc;
}
if (domain === "cdn.cara.app") {
// thanks to Anon_Ymou5 on reddit for reporting: https://www.reddit.com/r/MaxImage/comments/170nru5/image_max_url_2023100_is_released_130_new/k7vabt4/
match = src.match(/\/production\/+posts\/+([-0-9a-f]{20,})\/+/);
if (match) {
return {
url: "https://cara.app/post/" + match[1] + "#imu-url=" + encodeURIComponent(src),
is_pagelink: true
};
}
}
if (domain_nosub === "fashionnetwork.com" && /^(?:[a-z]+\.)?media\./.test(domain)) {
// http://media.fashionnetwork.com/m/2884/966d/1620/d702/c1de/b152/ad09/33fa/3832/bc32/487x272.72/bc32.jpg
// http://media.fashionnetwork.com/m/2884/966d/1620/d702/c1de/b152/ad09/33fa/3832/bc32/bc32.jpg
Expand Down

0 comments on commit f5c1f45

Please sign in to comment.