From f5c1f457c45d00a098a4db898b9c0f2c63475f06 Mon Sep 17 00:00:00 2001 From: qsniyg Date: Tue, 7 Nov 2023 20:18:41 +0000 Subject: [PATCH] Support cara --- CHANGELOG.txt | 2 +- src/userscript.ts | 91 ++++++++++++++++++++++++++++++++++++++++++++++ userscript.user.js | 85 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ebc67705..22cc484a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 --- diff --git a/src/userscript.ts b/src/userscript.ts index 348b5ea0..0b93d28b 100644 --- a/src/userscript.ts +++ b/src/userscript.ts @@ -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\//) || @@ -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 diff --git a/userscript.user.js b/userscript.user.js index d5e01b54..450964b2 100644 --- a/userscript.user.js +++ b/userscript.user.js @@ -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\//) || @@ -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