Skip to content

Commit

Permalink
More websites/rules
Browse files Browse the repository at this point in the history
  • Loading branch information
qsniyg committed Oct 2, 2023
1 parent a2971d9 commit 96e34c6
Show file tree
Hide file tree
Showing 2 changed files with 453 additions and 15 deletions.
252 changes: 243 additions & 9 deletions src/userscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3141,7 +3141,8 @@ var $$IMU_EXPORT$$;
type InfoMediaInfo = {
type: "image"|"video",
delivery?: VideoDelivery,
is_live?: boolean
is_live?: boolean,
codec?: string|null
};

type InfoExtraObject = {
Expand Down Expand Up @@ -31774,6 +31775,9 @@ var $$IMU_EXPORT$$;
// https://assetsio.reedpopcdn.com/Cyberpunk2077_Phantom_Liberty_PS5_The_Heart_of_Dogtown_RGB_clean_WEB.png?width=690&quality=70&format=jpg&auto=webp
// https://assetsio.reedpopcdn.com/Cyberpunk2077_Phantom_Liberty_PS5_The_Heart_of_Dogtown_RGB_clean_WEB.png
domain === "assetsio.reedpopcdn.com" ||
// thanks to anonymous for reporting:
// https://www.sony.com/image/a0c3f28f7a8cdb42cf1bc6616116dec8?fmt=jpeg&wid=1160&qlt=43
(domain_nowww === "sony.com" && /\/image\/+[0-9a-f]{5,}\?/.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 @@ -34348,6 +34352,25 @@ var $$IMU_EXPORT$$;
return src.replace(/\/sys\/[^/]*\/item\//, "/sys/original/item/");
}

if (domain_nosub === "baidu.com" && /^img[0-9]*\./.test(domain)) {
// thanks to anonymous for reporting:
// https://img0.baidu.com/it/u=3571861246,1567596953&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=313
// http://img0.baidu.com/it/u=3571861246,1567596953&fm=253
if (/\/it\/+u=/.test(src)) {
let fm = src.match(/[?&](fm=[0-9]+)(?:[&#].*)?$/);
if (fm) {
return src.replace(/[?&#].*/, "&" + fm[1]);
}
}
}

if (domain_nosub === "baidu.com" && /^pics[0-9]*\./.test(domain)) {
// thanks to anonymous for reporting:
// https://pics5.baidu.com/feed/5fdf8db1cb13495425890cb1b5cc5253d3094ada.jpeg@f_auto?token=87cce86ae4f92f9445cdeb9c28b22a4c
// https://pics5.baidu.com/feed/5fdf8db1cb13495425890cb1b5cc5253d3094ada.jpeg
return src.replace(/(\/feed\/+[0-9a-f]{5,}(?:\.[a-z]+)?)@.*/, "$1");
}

// p2.xiaohx.net
// test urls can be found, but all are 403, even from the website
// https://www.xiaohx.org/ (new address)
Expand Down Expand Up @@ -74631,7 +74654,7 @@ var $$IMU_EXPORT$$;
process: function(done, resp, cache_key, match) {
var id = match[1];

var obj = {
var obj:BigImageInfoSObject = {
extra: {
page: resp.finalUrl
}
Expand All @@ -74652,9 +74675,18 @@ var $$IMU_EXPORT$$;
obj.extra.created_date = media.uploadDate;
obj.extra.updated_date = media.lastUpdated;
obj.extra.author_username = media.permaSubdomain; // or gridName
obj.url = force_https(add_http(media.responsiveUrl));

return done(obj, 6*60*60);
let urls = [];

if (media.videoUrl)
urls.push({
url: force_https(add_http(media.videoUrl)),
video: true
});

urls.push(force_https(add_http(media.responsiveUrl)));

return done(fillobj_urls(urls, obj), 6*60*60);
}
});
if (newsrc) return newsrc;
Expand Down Expand Up @@ -77227,7 +77259,11 @@ var $$IMU_EXPORT$$;
.replace(/\/images\/+preview\/+[0-9a-f]+\/+[0-9]+x(?:[0-9]+)?-/, "/images/content2/");
}

if (domain_nowww === "uploadbeta.com") {
if (domain_nowww === "uploadbeta.com" ||
// thanks to anonymous for reporting:
// https://rot47.net/_s/upload/2013/11/07/6ce7768ebb7d8d89deffeb9de95acbc1.jpg225.jpg
// https://rot47.net/_s/upload/2013/11/07/6ce7768ebb7d8d89deffeb9de95acbc1.jpg
domain_nowww === "rot47.net") {
// https://uploadbeta.com/_s/upload/2016/01/10/343ee2817ebb2861af1641ad8d5ed66f.jpg225.jpg
// https://uploadbeta.com/_s/upload/2016/01/10/343ee2817ebb2861af1641ad8d5ed66f.jpg
return src.replace(/(\/_s\/+upload\/+[0-9]{4}\/+(?:[0-9]{2}\/+){2}[0-9a-f]+\.[a-zA-Z]+)[0-9]+\.[^/.]*(?:[?#].*)?$/,
Expand Down Expand Up @@ -95393,10 +95429,11 @@ var $$IMU_EXPORT$$;
}
}

if (domain_nowww === "dood.to") {
if (domain_nowww === "dood.to" ||
domain_nowww === "doods.pro") {
newsrc = website_query({
website_regex: /^[a-z]+:\/\/[^/]+\/+e\/+([0-9a-z]{10,})(?:[?#].*)?$/,
query_for_id: "https://dood.to/e/${id}",
website_regex: /^[a-z]+:\/\/[^/]+\/+[de]\/+([0-9a-z]{10,})(?:[?#].*)?$/,
query_for_id: "https://" + domain + "/e/${id}",
process: function(done, resp, cache_key) {
var match = resp.responseText.match(/\$\.get\('(\/pass_md5\/[^']+)', function/);
if (!match) {
Expand Down Expand Up @@ -106528,6 +106565,35 @@ var $$IMU_EXPORT$$;
newsrc = src.replace(/^[a-z]+:\/\/[^/]+\/+aggregator-api\/+download\/+\?(?:.*&)?url=(http[^&]+)(?:[&#].*)?$/, "$1");
if (newsrc !== src)
return decodeuri_ifneeded(newsrc);

// thanks to anonymous for reporting:
// https://www.alamy.com/chinese-actress-liu-yan-poses-at-the-opening-ceremony-for-taipingyuan-international-furniture-expo-mall-in-chengdu-city-southwest-chinas-sichuan-pro-image263490474.html
newsrc = website_query({
website_regex: /^[a-z]+:\/\/[^/]+\/+[^/]+-image([0-9]+)\.html(?:[?#].*)?$/,
query_for_id: "https://www.alamy.com/a-image${id}.html",
process: function(done, resp, cache_key) {
let match = resp.responseText.match(/<script id="__NEXT_DATA__"[^>]*>({.*?})<\/script>/);
if (!match) {
console_error(cache_key, "Unable to find NEXT_DATA in", resp);
return done(null, false);
}

let json = JSON_parse(match[1]);
let product = json.props.pageProps.product;

let extra:InfoExtraObject = {
page: product.uri,
caption: product.meta.mediatitle,
created_date: new Date(product.firstcreated).getTime() // firstcreated < uploaddate
};

let urls = [];
urls.push(product.renditions.zoom.href.replace(/\/zooms\/+[0-9]+\/+/, "/zooms/15/"));

return done(fillobj_urls(urls, {extra: extra}), 6*60*60);
}
});
if (newsrc) return newsrc;
}

if (domain_nosub === "alamy.com" && /^c[0-9]*\./.test(domain)) {
Expand Down Expand Up @@ -108107,6 +108173,169 @@ var $$IMU_EXPORT$$;
return src.replace(/(\/d\/+image\/+[a-z]+\?(?:.*&)?size=)[^&#]+([&#].*)?$/, "$1src$2");
}

if (domain === "aws-br-pic.kwai.net" ||
// https://ak-br-pic.kwai.net/kimg/EKzM1y8qmQEKAnMzEg1waG90by1vdmVyc2VhGoMBdXBpYy8yMDIzLzA3LzE3LzA0L0JNakF5TXpBM01UY3dORFEwTVRkZk1UVXdNREF3TWpJMk5ESTBOekV4WHpFMU1ERXdNelE0TURZNU9EZzJPVjh5WHpNPV9vdXVfQmExYzVmZTM3NWRiYjIwY2E1NTk3ZDlhMTFjNmRlY2YyLndlYnA.webp
// https://ak-br-pic.kwai.net/upic/2023/07/17/04/BMjAyMzA3MTcwNDQ0MTdfMTUwMDAwMjI2NDI0NzExXzE1MDEwMzQ4MDY5ODg2OV8yXzM=_ouu_Ba1c5fe375dbb20ca5597d9a11c6decf2.webp
domain === "ak-br-pic.kwai.net" ||
// https://tx-br-pic.kwai.net/kimg/EKzM1y8qmQEKAnMzEg1waG90by1vdmVyc2VhGoMBdXBpYy8yMDIzLzA3LzE3LzA0L0JNakF5TXpBM01UY3dORFEwTVRkZk1UVXdNREF3TWpJMk5ESTBOekV4WHpFMU1ERXdNelE0TURZNU9EZzJPVjh5WHpNPV9vdXVfQmExYzVmZTM3NWRiYjIwY2E1NTk3ZDlhMTFjNmRlY2YyLndlYnA.webp
// https://tx-br-pic.kwai.net/upic/2023/07/17/04/BMjAyMzA3MTcwNDQ0MTdfMTUwMDAwMjI2NDI0NzExXzE1MDEwMzQ4MDY5ODg2OV8yXzM=_ouu_Ba1c5fe375dbb20ca5597d9a11c6decf2.webp
domain === "tx-br-pic.kwai.net") {
// https://aws-br-pic.kwai.net/kimg/EKzM1y8qmQEKAnMzEg1waG90by1vdmVyc2VhGoMBdXBpYy8yMDIzLzA3LzE3LzA0L0JNakF5TXpBM01UY3dORFEwTVRkZk1UVXdNREF3TWpJMk5ESTBOekV4WHpFMU1ERXdNelE0TURZNU9EZzJPVjh5WHpNPV9vdXVfQmExYzVmZTM3NWRiYjIwY2E1NTk3ZDlhMTFjNmRlY2YyLndlYnA.webp
// https://aws-br-pic.kwai.net/upic/2023/07/17/04/BMjAyMzA3MTcwNDQ0MTdfMTUwMDAwMjI2NDI0NzExXzE1MDEwMzQ4MDY5ODg2OV8yXzM=_ouu_Ba1c5fe375dbb20ca5597d9a11c6decf2.webp
// aws forces download
match = src.match(/\/kimg\/+([^/.?#]{30,})\./);
if (match) {
try {
let decoded = base64_decode(match[1]);
let newstr = null;
for (let i = 1; i < decoded.length; i++) {
if (decoded[i] === "u" && decoded.charCodeAt(i-1) === 1) {
newstr = decoded.substr(i);
if (/^upic\//.test(newstr))
break;

newstr = null;
}
}

return "https://" + domain + "/" + newstr;
} catch (e) {
console_error(e);
}
}
}

if (domain_nowww === "kwai.com") {
let query_kwai = function(id, cb) {
let cache_key = "kwai:" + id;
api_query(cache_key, {
url: "https://www.kwai.com/rest/o/w/pwa/photo/get",
headers: {
Accept: "application/json, text/plain, */*",
"Cache-Control": "no-cache",
"Content-Type": "application/json",
Origin: "https://www.kwai.com",
Pragma: "no-cache",
Referer: "https://www.kwai.com/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site"
},
imu_mode: "xhr",
method: "POST",
data: '{"photoId":"' + id + '"}',
json: true
}, cb, function(done, resp, cache_key) {
if (!resp || !resp.feeds || !resp.feeds[0]) {
console_error(cache_key, "Unable to query", id, resp);
return done(null, false);
}

let feed = resp.feeds[0];

let extra:InfoExtraObject = {
created_date: feed.timestamp,
author_username: feed.kwai_id,
id: feed.photo_id_str,
caption: feed.caption
};

let urls = [];

if (feed.main_mv_urls_rate) {
feed.main_mv_urls_rate.sort(function(a, b) {
return b.rate - a.rate;
});

let biggest = feed.main_mv_urls_rate[0];
let codec = null;
if (/_265$/.test(biggest.level)) {
codec = "hevc";
}

urls.push({
url: biggest.urls[0].url,
media_info: {
type: "video",
codec
}
});
}

if (feed.main_mv_urls) {
urls.push({
url: feed.main_mv_urls[0].url,
video: true
});
}

if (feed.cover_thumbnail_urls) {
urls.push(feed.cover_thumbnail_urls[0].url);
}

return done(fillobj_urls(urls, {extra}), 60*60);
});
};

newsrc = website_query({
website_regex: /^[a-z]+:\/\/[^/]+\/+@[^/]+\/+video\/+([0-9]+)(?:[?#].*)?$/,
run: function(cb, match) {
query_kwai(match[1], cb);
}
});
if (newsrc) return newsrc;
}

if (host_domain_nowww === "kwai.com" && options.element) {
if (options.element.tagName === "IMG" && options.element.parentElement && options.element.parentElement.tagName === "A" &&
options.element.parentElement.href && /^[a-z]+:\/\/[^/]+\/+@[^/]+\/+video\/+[0-9]+/.test(options.element.parentElement.href)) {
return {
url: options.element.parentElement.href,
is_pagelink: true
};
}
}

if (domain_nowww === "minecraft.wiki") {
// thanks to anonymous for reporting:
// https://minecraft.wiki/images/thumb/Minecraft_brewing_en.png/300px-Minecraft_brewing_en.png?0be9b
// https://minecraft.wiki/images/Minecraft_brewing_en.png
return src.replace(/(\/images\/+)thumb\/+([^/]+)\/+[^/]+(?:[?#].*)?$/, "$1$2");
}

if (domain_nowww === "musik-sammler.de") {
// https://www.musik-sammler.de/cover/1540000/1539691_1635313476_75.jpg
// https://www.musik-sammler.de/cover/1540000/1539691_1635313476_300.jpg
// https://www.musik-sammler.de/cover/1540000/1539691_1635313476.jpg
return src.replace(/(\/cover\/+[0-9]+\/+[0-9]+_[0-9]+)_[0-9]+\./, "$1.");
}

if (domain === "cdn.cimri.io") {
// thanks to anonymous for reporting:
// https://cdn.cimri.io/image/1000x1000/samsunggalaxytabasmxgbinkoyugriwifitabletpc_661449112.jpg
// https://cdn.cimri.io/image/0x0/samsunggalaxytabasmxgbinkoyugriwifitabletpc_661449112.jpg
return {
url: src.replace(/(\/image\/+)[0-9]+x[0-9]+\/+/, "$10x0/"),
head_wrong_contenttype: true
};
}

if (domain_nowww === "rssso.com") {
// thanks to anonymous for reporting:
// http://www.rssso.com/Files/SrcImg/?url=https://pics5.baidu.com/feed/5fdf8db1cb13495425890cb1b5cc5253d3094ada.jpeg@f_auto?token=87cce86ae4f92f9445cdeb9c28b22a4c
// https://pics5.baidu.com/feed/5fdf8db1cb13495425890cb1b5cc5253d3094ada.jpeg
newsrc = src.replace(/^.*?\/Files\/+SrcImg\/+\?(?:.*&)?url=(.*)/i, "$1");
if (newsrc !== src)
return decodeuri_ifneeded(newsrc);
}

if (domain_nowww === "guforecords.com") {
// thanks to anonymous for reporting:
// http://www.guforecords.com/imgApp/thumbs/1511106574_350x350.png
// http://www.guforecords.com/imgApp/1511106574.png
return src.replace(/(\/imgApp\/+)thumbs\/+([0-9]+)_[0-9]+x[0-9]+\./, "$1$2.");
}




Expand Down Expand Up @@ -115561,7 +115790,7 @@ var $$IMU_EXPORT$$;
return mediainfo.type ? mediainfo : null;
};

var is_media_type_supported = function(media_info, processing) {
var is_media_type_supported = function(media_info:InfoMediaInfo, processing) {
if (!media_info) {
console_error("is_media_type_supported called without media_info");
return true;
Expand All @@ -115579,6 +115808,11 @@ var $$IMU_EXPORT$$;
return false;
}

if (media_info.codec === "hevc") {
// TODO: check for HEVC support
return false;
}

if (!media_info.delivery) {
return true;
}
Expand Down
Loading

0 comments on commit 96e34c6

Please sign in to comment.