Skip to content

Commit

Permalink
Improve baidu.com support (fixes #1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
qsniyg committed Dec 23, 2022
1 parent d6a91f4 commit d764b07
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/userscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32041,6 +32041,7 @@ var $$IMU_EXPORT$$;
// thanks to llacb47 on github: https://github.com/qsniyg/maxurl/issues/432
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.rsquare.w330.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.rvertical.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.rdeep-vertical.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.w330.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.jpg
// https://pyxis.nymag.com/v1/imgs/92c/88f/d4a2dede7120bc943ed95943b6ac5fe212-trump.rsquare-zoom.w100.jpg
Expand All @@ -32051,7 +32052,7 @@ var $$IMU_EXPORT$$;
// https://pyxis.nymag.com/v1/imgs/8b0/b62/f1212d7c71c261c4d2582d4e9bcbc155c4-steve-underwood.jpg
// https://pyxis.nymag.com/v1/imgs/0ce/fd4/5fb0f096041f7bdbc2395f36c1f56ecf00-Sept30-Oct13-Testimonies.2x.rsocial.w600.jpg
// https://pyxis.nymag.com/v1/imgs/0ce/fd4/5fb0f096041f7bdbc2395f36c1f56ecf00-Sept30-Oct13-Testimonies.jpg
return src.replace(/(\/v1\/+imgs\/+[0-9a-f]{3}\/+[0-9a-f]{3}\/+[0-9a-f]{10,}[^/.?#]*\.)(?:(?:r(?:square|horizontal|vertical|social)(?:-[a-z]+)?|[wh][0-9]+|[0-9]+x)\.){0,}([a-z]+)(?:[?#].*)?$/, "$1$2");
return src.replace(/(\/v1\/+imgs\/+[0-9a-f]{3}\/+[0-9a-f]{3}\/+[0-9a-f]{10,}[^/.?#]*\.)(?:(?:r(?:deep-)?(?:square|horizontal|vertical|social)(?:-[a-z]+)?|[wh][0-9]+|[0-9]+x)\.){0,}([a-z]+)(?:[?#].*)?$/, "$1$2");
}

if (domain === "assets.nydailynews.com" ||
Expand Down Expand Up @@ -33209,15 +33210,20 @@ var $$IMU_EXPORT$$;
if (domain === "imgsrc.baidu.com" ||
// http://tiebapic.baidu.com/forum/wh%3D200%2C90%3B/sign=2a1cbd806bd98d1076810433110f9437/7531232dd42a2834305a1d774cb5c9ea14cebfb1.jpg
// http://tiebapic.baidu.com/forum/pic/item/7531232dd42a2834305a1d774cb5c9ea14cebfb1.jpg
// thanks to n0099 on github: https://github.com/qsniyg/maxurl/issues/1100
// https://tiebapic.baidu.com/forum/pic/item/4ba6b7fd5266d016e17995ecd22bd40734fa350b.jpg?tbpicau=2022-12-25-05_2ae0f8dbe307e91d5228fb7b90bdc060
// https://imgsrc.baidu.com/forum/pic/item/4ba6b7fd5266d016e17995ecd22bd40734fa350b.jpg
domain === "tiebapic.baidu.com" ||
// http://c.hiphotos.baidu.com/forum/w%3D272%3Bq%3D80%3Bg%3D0/sign=9a65dccd7f8da9774e2f812c826a8924/bf848226cffc1e175a7793cf4690f603728de936.jpg?&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fpic%2Fitem%2Fbf848226cffc1e175a7793cf4690f603728de936.jpg
// http://imgsrc.baidu.com/forum/pic/item/bf848226cffc1e175a7793cf4690f603728de936.jpg
// http://f.hiphotos.baidu.com/zhidao/wh=600,800/sign=be7fdbc3034f78f0805e92f54901266d/a9d3fd1f4134970a75dc55b895cad1c8a6865dfd.jpg
// http://f.hiphotos.baidu.com/zhidao/pic/item/a9d3fd1f4134970a75dc55b895cad1c8a6865dfd.jpg
// https://imgsrc.baidu.com/zhidao/pic/item/a9d3fd1f4134970a75dc55b895cad1c8a6865dfd.jpg
(domain_nosub === "baidu.com" && domain.match(/^(?:[a-z]\.)?hiphotos\./)) ||
// thanks to fireattack on github: https://github.com/qsniyg/maxurl/issues/22
// https://imgsa.baidu.com/forum/w%3D580/sign=b48af07db34543a9f51bfac42e168a7b/2b3e91160924ab1890b8cfbe31fae6cd7a890b60.jpg
// https://imgsa.baidu.com/forum/pic/item/2b3e91160924ab1890b8cfbe31fae6cd7a890b60.jpg
// https://imgsrc.baidu.com/forum/pic/item/2b3e91160924ab1890b8cfbe31fae6cd7a890b60.jpg
domain === "imgsa.baidu.com") {
// http://imgsrc.baidu.com/forum/wh%3D200%2C90%3B/sign=a5aa97f7bb7eca80125031e5a113bbe4/f7582e381f30e924af22ade547086e061c95f734.jpg
// http://imgsrc.baidu.com/forum/wh=200,90;/sign=a5aa97f7bb7eca80125031e5a113bbe4/f7582e381f30e924af22ade547086e061c95f734.jpg
Expand All @@ -33239,6 +33245,17 @@ var $$IMU_EXPORT$$;
newsrc = src
.replace("/abpic/item/", "/pic/item/")
.replace(/\/[^/]*(?:=|%3D)[^/]*\/sign=[^/]*\//, "/pic/item/");

if (newsrc !== src)
return {
url: newsrc,
head_wrong_contenttype: true
};

if (domain !== "imgsrc.baidu.com") {
return remove_queries(src.replace(/:\/\/[^/]+\/+/, "://imgsrc.baidu.com/"), ["tbpicau"]);
}

return {
url: newsrc,
head_wrong_contenttype: true
Expand Down
16 changes: 15 additions & 1 deletion userscript.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -29335,6 +29335,7 @@ var $$IMU_EXPORT$$;
// thanks to llacb47 on github: https://github.com/qsniyg/maxurl/issues/432
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.rsquare.w330.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.rvertical.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.rdeep-vertical.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.w330.jpg
// https://pyxis.nymag.com/v1/imgs/729/cc9/040edf97c4ef041ec1f48829be69842eed-24-Doja-Cat.jpg
// https://pyxis.nymag.com/v1/imgs/92c/88f/d4a2dede7120bc943ed95943b6ac5fe212-trump.rsquare-zoom.w100.jpg
Expand All @@ -29345,7 +29346,7 @@ var $$IMU_EXPORT$$;
// https://pyxis.nymag.com/v1/imgs/8b0/b62/f1212d7c71c261c4d2582d4e9bcbc155c4-steve-underwood.jpg
// https://pyxis.nymag.com/v1/imgs/0ce/fd4/5fb0f096041f7bdbc2395f36c1f56ecf00-Sept30-Oct13-Testimonies.2x.rsocial.w600.jpg
// https://pyxis.nymag.com/v1/imgs/0ce/fd4/5fb0f096041f7bdbc2395f36c1f56ecf00-Sept30-Oct13-Testimonies.jpg
return src.replace(/(\/v1\/+imgs\/+[0-9a-f]{3}\/+[0-9a-f]{3}\/+[0-9a-f]{10,}[^/.?#]*\.)(?:(?:r(?:square|horizontal|vertical|social)(?:-[a-z]+)?|[wh][0-9]+|[0-9]+x)\.){0,}([a-z]+)(?:[?#].*)?$/, "$1$2");
return src.replace(/(\/v1\/+imgs\/+[0-9a-f]{3}\/+[0-9a-f]{3}\/+[0-9a-f]{10,}[^/.?#]*\.)(?:(?:r(?:deep-)?(?:square|horizontal|vertical|social)(?:-[a-z]+)?|[wh][0-9]+|[0-9]+x)\.){0,}([a-z]+)(?:[?#].*)?$/, "$1$2");
}
if (domain === "assets.nydailynews.com" ||
// http://assets.nydailynews.com/polopoly_fs/1.1756087.1397507807!/img/httpImage/image.jpg_gen/derivatives/article_750/ccweb15s-2-web.jpg
Expand Down Expand Up @@ -30395,15 +30396,20 @@ var $$IMU_EXPORT$$;
if (domain === "imgsrc.baidu.com" ||
// http://tiebapic.baidu.com/forum/wh%3D200%2C90%3B/sign=2a1cbd806bd98d1076810433110f9437/7531232dd42a2834305a1d774cb5c9ea14cebfb1.jpg
// http://tiebapic.baidu.com/forum/pic/item/7531232dd42a2834305a1d774cb5c9ea14cebfb1.jpg
// thanks to n0099 on github: https://github.com/qsniyg/maxurl/issues/1100
// https://tiebapic.baidu.com/forum/pic/item/4ba6b7fd5266d016e17995ecd22bd40734fa350b.jpg?tbpicau=2022-12-25-05_2ae0f8dbe307e91d5228fb7b90bdc060
// https://imgsrc.baidu.com/forum/pic/item/4ba6b7fd5266d016e17995ecd22bd40734fa350b.jpg
domain === "tiebapic.baidu.com" ||
// http://c.hiphotos.baidu.com/forum/w%3D272%3Bq%3D80%3Bg%3D0/sign=9a65dccd7f8da9774e2f812c826a8924/bf848226cffc1e175a7793cf4690f603728de936.jpg?&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fpic%2Fitem%2Fbf848226cffc1e175a7793cf4690f603728de936.jpg
// http://imgsrc.baidu.com/forum/pic/item/bf848226cffc1e175a7793cf4690f603728de936.jpg
// http://f.hiphotos.baidu.com/zhidao/wh=600,800/sign=be7fdbc3034f78f0805e92f54901266d/a9d3fd1f4134970a75dc55b895cad1c8a6865dfd.jpg
// http://f.hiphotos.baidu.com/zhidao/pic/item/a9d3fd1f4134970a75dc55b895cad1c8a6865dfd.jpg
// https://imgsrc.baidu.com/zhidao/pic/item/a9d3fd1f4134970a75dc55b895cad1c8a6865dfd.jpg
(domain_nosub === "baidu.com" && domain.match(/^(?:[a-z]\.)?hiphotos\./)) ||
// thanks to fireattack on github: https://github.com/qsniyg/maxurl/issues/22
// https://imgsa.baidu.com/forum/w%3D580/sign=b48af07db34543a9f51bfac42e168a7b/2b3e91160924ab1890b8cfbe31fae6cd7a890b60.jpg
// https://imgsa.baidu.com/forum/pic/item/2b3e91160924ab1890b8cfbe31fae6cd7a890b60.jpg
// https://imgsrc.baidu.com/forum/pic/item/2b3e91160924ab1890b8cfbe31fae6cd7a890b60.jpg
domain === "imgsa.baidu.com") {
// http://imgsrc.baidu.com/forum/wh%3D200%2C90%3B/sign=a5aa97f7bb7eca80125031e5a113bbe4/f7582e381f30e924af22ade547086e061c95f734.jpg
// http://imgsrc.baidu.com/forum/wh=200,90;/sign=a5aa97f7bb7eca80125031e5a113bbe4/f7582e381f30e924af22ade547086e061c95f734.jpg
Expand All @@ -30424,6 +30430,14 @@ var $$IMU_EXPORT$$;
newsrc = src
.replace("/abpic/item/", "/pic/item/")
.replace(/\/[^/]*(?:=|%3D)[^/]*\/sign=[^/]*\//, "/pic/item/");
if (newsrc !== src)
return {
url: newsrc,
head_wrong_contenttype: true
};
if (domain !== "imgsrc.baidu.com") {
return remove_queries(src.replace(/:\/\/[^/]+\/+/, "://imgsrc.baidu.com/"), ["tbpicau"]);
}
return {
url: newsrc,
head_wrong_contenttype: true
Expand Down

0 comments on commit d764b07

Please sign in to comment.