Skip to content

Commit

Permalink
Use regexes for sites that accept multiple slashes in paths
Browse files Browse the repository at this point in the history
  • Loading branch information
qsniyg committed Sep 15, 2024
1 parent 8fadccd commit 9b5210f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
23 changes: 10 additions & 13 deletions src/userscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58102,8 +58102,7 @@ var $$IMU_EXPORT$$;
return src.replace(/\/gallery\/[^/]+\//, "/gallery/big/");
}

if (domain_nowww === "vev.ru" &&
string_indexof(src, "/uploads/images/") >= 0) {
if (domain_nowww === "vev.ru" && /\/uploads\/+images\//.test(src)) {
// http://www.vev.ru/uploads/images/00/01/43/2014/04/14/Rihanna-2014-MTV-Movie-Awards.jpg
// http://vev.ru/uploads/images/00/01/43/2014/04/14/Rihanna-2014-MTV-Movie-Awards_original.jpg
return src.replace(/(?:_[a-z]+)?(\.[^/.]*)$/, "_original$1");
Expand Down Expand Up @@ -58582,10 +58581,10 @@ var $$IMU_EXPORT$$;
if (domain === "s.olj.me" ||
// https://static.addiyar.com/storage/attachments/1430/rihanna_892120_large.jpg
// https://static.addiyar.com/storage/attachments/1430/rihanna_892120.jpg
(domain === "static.addiyar.com" && string_indexof(src, "/storage/attachments/") >= 0) ||
(domain === "static.addiyar.com" && /\/storage\/+attachments\//.test(src)) ||
// https://static2.annahar.com/storage/attachments/397/Rihanna-Dior_sunglasses_959864_940431_large.jpg
// https://static2.annahar.com/storage/attachments/397/Rihanna-Dior_sunglasses_959864_940431.jpg
(domain_nosub === "annahar.com" && domain.match(/^static[0-9]*\.annahar/) && string_indexof(src, "/storage/attachments/") >= 0)) {
(domain_nosub === "annahar.com" && /^static[0-9]*\./.test(domain) && /\/storage\/+attachments\//.test(src))) {
// https://s.olj.me/storage/attachments/885/p015-5_727183_thumbnail.jpg
// https://s.olj.me/storage/attachments/885/p015-5_727183.jpg
// https://s.olj.me/storage/attachments/885/p015-5_727183.jpg/r/400
Expand Down Expand Up @@ -58814,12 +58813,12 @@ var $$IMU_EXPORT$$;
.replace(/(\/images\/+artists\/+covers\/+)(?:small|medium)\/+/, "$1large/");
}

if (domain_nowww === "sarajevo.travel" &&
string_indexof(src, "/assets/photos/") >= 0) {
if (domain_nowww === "sarajevo.travel") {
// https://sarajevo.travel/assets/photos/events/small/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
// https://sarajevo.travel/assets//photos/events/medium/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
// https://sarajevo.travel/assets/photos/events/big/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
// https://www.sarajevo.travel/assets/photos/events/original/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
return src.replace(/\/[a-z]+\/([^/]*)$/, "/original/$1");
return src.replace(/(\/assets\/+photos\/+[^/]+\/+)[a-z]+\/+([^/]+(?:[?#].*)?)$/, "$1original/$2");
}

if (domain === "avatars.mds.yandex.net" ||
Expand Down Expand Up @@ -59105,7 +59104,7 @@ var $$IMU_EXPORT$$;
string_indexof(src, "/resize/wp-content/") >= 0) {
// https://d2u7zfhzkfu65k.cloudfront.net/resize/wp-content/uploads/2018/5/8/15/f21a56c81474b277e24bca7575e94dc7.jpg?w=70&q=85
// https://d3kszy5ca3yqvh.cloudfront.net/wp-content/uploads/2018/5/8/15/f21a56c81474b277e24bca7575e94dc7.jpg
return src.replace(/:\/\/[^/]*\/resize\//, "://d3kszy5ca3yqvh.cloudfront.net/");
return src.replace(/:\/\/[^/]+\/+resize\//, "://d3kszy5ca3yqvh.cloudfront.net/");
}

if (domain === "imgbp.hotp.jp") {
Expand Down Expand Up @@ -60007,10 +60006,8 @@ var $$IMU_EXPORT$$;
return src.replace(/(:\/\/[^/]*\/)(item\/image\/|article\/)[a-z]+(\/[^/]*)$/, "$1$2original$3");
}

if ((domain_nosub === "styapokupayu.ru" &&
string_indexof(src, "/images/") >= 0) ||
(domain_nosub === "yapokupayu.ru" &&
string_indexof(src, "/system/images/") >= 0)) {
if ((domain_nosub === "styapokupayu.ru" && string_indexof(src, "/images/") >= 0) ||
(domain_nosub === "yapokupayu.ru" && /\/system\/+images\//.test(src))) {
// http://st4.styapokupayu.ru/images/blog_post_images/000/137/597_large.jpg
// http://st4.styapokupayu.ru/images/blog_post_images/000/137/597_original.jpg
// http://st10.styapokupayu.ru/images/product/026/756/403_medium.jpg
Expand Down Expand Up @@ -63013,7 +63010,7 @@ var $$IMU_EXPORT$$;
// https://static.dir.bg/uploads/images/2018/08/07/1484000/768x.jpg?_=1533643044
// https://static.dir.bg/uploads/images/2018/08/07/1484000/orig.jpg?_=1533643044
domain === "static.dir.bg") &&
string_indexof(src, "/uploads/images/") >= 0) {
/\/uploads\/+images\//.test(src)) {
// https://www.webnews.bg/uploads/images/70/8070/368070/768x432.jpg
// https://www.webnews.bg/uploads/images/70/8070/368070/orig.jpg
return src.replace(/\/[0-9]+x(?:[0-9]+)?(\.[^/.]*)$/, "/orig$1");
Expand Down
23 changes: 10 additions & 13 deletions userscript.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -52955,8 +52955,7 @@ var $$IMU_EXPORT$$;
// http://static4.devote.se/gallery/big/20150708/257a5fd7c37599cc814b4760d98eeb81.jpg
return src.replace(/\/gallery\/[^/]+\//, "/gallery/big/");
}
if (domain_nowww === "vev.ru" &&
string_indexof(src, "/uploads/images/") >= 0) {
if (domain_nowww === "vev.ru" && /\/uploads\/+images\//.test(src)) {
// http://www.vev.ru/uploads/images/00/01/43/2014/04/14/Rihanna-2014-MTV-Movie-Awards.jpg
// http://vev.ru/uploads/images/00/01/43/2014/04/14/Rihanna-2014-MTV-Movie-Awards_original.jpg
return src.replace(/(?:_[a-z]+)?(\.[^/.]*)$/, "_original$1");
Expand Down Expand Up @@ -53377,10 +53376,10 @@ var $$IMU_EXPORT$$;
if (domain === "s.olj.me" ||
// https://static.addiyar.com/storage/attachments/1430/rihanna_892120_large.jpg
// https://static.addiyar.com/storage/attachments/1430/rihanna_892120.jpg
(domain === "static.addiyar.com" && string_indexof(src, "/storage/attachments/") >= 0) ||
(domain === "static.addiyar.com" && /\/storage\/+attachments\//.test(src)) ||
// https://static2.annahar.com/storage/attachments/397/Rihanna-Dior_sunglasses_959864_940431_large.jpg
// https://static2.annahar.com/storage/attachments/397/Rihanna-Dior_sunglasses_959864_940431.jpg
(domain_nosub === "annahar.com" && domain.match(/^static[0-9]*\.annahar/) && string_indexof(src, "/storage/attachments/") >= 0)) {
(domain_nosub === "annahar.com" && /^static[0-9]*\./.test(domain) && /\/storage\/+attachments\//.test(src))) {
// https://s.olj.me/storage/attachments/885/p015-5_727183_thumbnail.jpg
// https://s.olj.me/storage/attachments/885/p015-5_727183.jpg
// https://s.olj.me/storage/attachments/885/p015-5_727183.jpg/r/400
Expand Down Expand Up @@ -53582,12 +53581,12 @@ var $$IMU_EXPORT$$;
.replace(/_[0-9]+(\.[^/.]*)$/, "_org$1")
.replace(/(\/images\/+artists\/+covers\/+)(?:small|medium)\/+/, "$1large/");
}
if (domain_nowww === "sarajevo.travel" &&
string_indexof(src, "/assets/photos/") >= 0) {
if (domain_nowww === "sarajevo.travel") {
// https://sarajevo.travel/assets/photos/events/small/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
// https://sarajevo.travel/assets//photos/events/medium/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
// https://sarajevo.travel/assets/photos/events/big/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
// https://www.sarajevo.travel/assets/photos/events/original/tuborg-open-sara-jo-amp-sky-wikler-1503493807.jpg
return src.replace(/\/[a-z]+\/([^/]*)$/, "/original/$1");
return src.replace(/(\/assets\/+photos\/+[^/]+\/+)[a-z]+\/+([^/]+(?:[?#].*)?)$/, "$1original/$2");
}
if (domain === "avatars.mds.yandex.net" ||
// https://avatars.yandex.net/get-music-content/113160/ad3c5bfa.p.3425928/m1000x1000?webp=false
Expand Down Expand Up @@ -53840,7 +53839,7 @@ var $$IMU_EXPORT$$;
string_indexof(src, "/resize/wp-content/") >= 0) {
// https://d2u7zfhzkfu65k.cloudfront.net/resize/wp-content/uploads/2018/5/8/15/f21a56c81474b277e24bca7575e94dc7.jpg?w=70&q=85
// https://d3kszy5ca3yqvh.cloudfront.net/wp-content/uploads/2018/5/8/15/f21a56c81474b277e24bca7575e94dc7.jpg
return src.replace(/:\/\/[^/]*\/resize\//, "://d3kszy5ca3yqvh.cloudfront.net/");
return src.replace(/:\/\/[^/]+\/+resize\//, "://d3kszy5ca3yqvh.cloudfront.net/");
}
if (domain === "imgbp.hotp.jp") {
// https://imgbp.hotp.jp/CSP/IMG_SRC/60/26/B011156026/B011156026_271-361.jpg
Expand Down Expand Up @@ -54631,10 +54630,8 @@ var $$IMU_EXPORT$$;
// http://image.entertainment-topics.jp/article/original/137930.jpg?time=1529115899
return src.replace(/(:\/\/[^/]*\/)(item\/image\/|article\/)[a-z]+(\/[^/]*)$/, "$1$2original$3");
}
if ((domain_nosub === "styapokupayu.ru" &&
string_indexof(src, "/images/") >= 0) ||
(domain_nosub === "yapokupayu.ru" &&
string_indexof(src, "/system/images/") >= 0)) {
if ((domain_nosub === "styapokupayu.ru" && string_indexof(src, "/images/") >= 0) ||
(domain_nosub === "yapokupayu.ru" && /\/system\/+images\//.test(src))) {
// http://st4.styapokupayu.ru/images/blog_post_images/000/137/597_large.jpg
// http://st4.styapokupayu.ru/images/blog_post_images/000/137/597_original.jpg
// http://st10.styapokupayu.ru/images/product/026/756/403_medium.jpg
Expand Down Expand Up @@ -57309,7 +57306,7 @@ var $$IMU_EXPORT$$;
// https://static.dir.bg/uploads/images/2018/08/07/1484000/768x.jpg?_=1533643044
// https://static.dir.bg/uploads/images/2018/08/07/1484000/orig.jpg?_=1533643044
domain === "static.dir.bg") &&
string_indexof(src, "/uploads/images/") >= 0) {
/\/uploads\/+images\//.test(src)) {
// https://www.webnews.bg/uploads/images/70/8070/368070/768x432.jpg
// https://www.webnews.bg/uploads/images/70/8070/368070/orig.jpg
return src.replace(/\/[0-9]+x(?:[0-9]+)?(\.[^/.]*)$/, "/orig$1");
Expand Down

0 comments on commit 9b5210f

Please sign in to comment.