From 4ccd2f26f11c5f63a6d661898799fc527d216356 Mon Sep 17 00:00:00 2001
From: qsniyg <qsniyg@mail.com>
Date: Sun, 4 Feb 2024 09:00:02 +0000
Subject: [PATCH] More websites/rules

Fixes #1272
---
 CHANGELOG.txt      |  4 ++--
 src/userscript.ts  | 41 ++++++++++++++++++++++++++++++++++++-----
 userscript.user.js | 38 +++++++++++++++++++++++++++++++++-----
 3 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 25ddb056..d12539ea 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -2,9 +2,9 @@
 
 Improvements:
 
- * Various improvements/fixes to existing rules (including TikTok)
+ * Various improvements/fixes to existing rules (including TikTok, Tumblr)
 
-Special thanks to fireattack, aslian, remlap, uwuceo, TristanWasTaken, Froktime, karpuzikov, nimbuz, Shaggy, hosadokha for their contributions and reports for this release
+Special thanks to fireattack, aslian, remlap, uwuceo, TristanWasTaken, Froktime, karpuzikov, nimbuz, Shaggy, hosadokha, happysurf for their contributions and reports for this release
 
 ---
 
diff --git a/src/userscript.ts b/src/userscript.ts
index d0265ac1..3bd0c3b0 100644
--- a/src/userscript.ts
+++ b/src/userscript.ts
@@ -36019,7 +36019,9 @@ var $$IMU_EXPORT$$;
 			// https://66.media.tumblr.com/2f1e06be02fe7b7cac4c7f1634a9fcc5/0117045da5da2818-ab/s1280x1920/c2e312c7c204a31974c1a45472a929e5ddc2b7de.jpg
 			// thanks to modelfe on github: https://github.com/qsniyg/maxurl/issues/88#issuecomment-637202663
 			// https://66.media.tumblr.com/7378b1813629aa8b841f6079ab9303a4/e24e926459952d1b-b1/s64x64u_c1/c7acf4139f2981e5d3ddaa6686e9240f3cf6f98d.jpg
-			if (options.do_request && options.cb && /:\/\/[^/]+\/+[0-9a-f]{32}\/+[0-9a-f]{16}-[0-9a-f]{2}\/+s[0-9]+x[0-9]+u?(?:_c[0-9]+)?\/+[0-9a-f]{20,}\./.test(src)) {
+			// thanks to anonymous for reporting:
+			// https://44.media.tumblr.com/a415b30327591b1233ec0c9783b7b3bb/8876be95cf21457f-55/s400x600_f1/195209414c3eeede4e1a577c7ae527e4c279db53.gif
+			if (options.do_request && options.cb && /:\/\/[^/]+\/+[0-9a-f]{32}\/+[0-9a-f]{16}-[0-9a-f]{2}\/+s[0-9]+x[0-9]+u?(?:_[fc][0-9]+)?\/+[0-9a-f]{20,}\./.test(src)) {
 				var get_initialstate_from_text = function(text) {
 					var match = text.match(/window\['___INITIAL_STATE___'\]\s*=\s*({.*?"ImageUrlPage":.*?})\s*;\s*(?:<\/script>[\s\S]*)?$/);
 					if (match) {
@@ -36043,7 +36045,7 @@ var $$IMU_EXPORT$$;
 				};
 
 				var url_to_tumblr_imageinfo = function(url) {
-					var match = url.match(/:\/\/[^/]+\/+([0-9a-f]{32})\/+([0-9a-f]{16}-[0-9a-f]{2})\/+s([0-9]+)x([0-9]+)u?(?:_c[0-9]+)?\/+[0-9a-f]{20,}\.([^/.?#]+)(?:[?#].*)?$/);
+					var match = url.match(/:\/\/[^/]+\/+([0-9a-f]{32})\/+([0-9a-f]{16}-[0-9a-f]{2})\/+s([0-9]+)x([0-9]+)u?(?:_[a-z][0-9]+)?\/+[0-9a-f]{20,}\.([^/.?#]+)(?:[?#].*)?$/);
 					if (match) {
 						return {
 							mediaKey: match[1] + ":" + match[2],
@@ -111804,7 +111806,6 @@ var $$IMU_EXPORT$$;
 		}
 
 		if (domain_nowww === "bilibili.com") {
-			// https://www.bilibili.com/video/BV11t421H7bz/?spm_id_from=333.1073.high_energy.content.click
 			newsrc = website_query({
 				website_regex: /^[a-z]+:\/\/[^/]+\/+video\/+([A-Za-z0-9]+)\/*(?:[?#].*)?$/,
 				query_for_id: "https://www.bilibili.com/video/${id}/",
@@ -111866,6 +111867,36 @@ var $$IMU_EXPORT$$;
 			if (newsrc) return newsrc;
 		}
 
+		if (domain_nowww === "parismatch.com") {
+			// thanks to anonymous for reporting:
+			// https://www.parismatch.com/lmnr/f/webp/r/960,640,FFFFFF,forcex,center-middle/img/var/pm/public/styles/paysage/public/media/image/2022/03/02/08/Margot-Robbie-Je-fais-partie-d-une-generation-de-femmes-qui-veulent-tout-avoir-dans-la-vie.jpg
+			//   https://www.parismatch.com/lmnr/img/var/pm/public/styles/paysage/public/media/image/2022/03/02/08/Margot-Robbie-Je-fais-partie-d-une-generation-de-femmes-qui-veulent-tout-avoir-dans-la-vie.jpg
+			return src.replace(/(\/lmnr\/+)(?:[fr]\/+[^/]+\/+)+(img\/+)/, "$1$2");
+		}
+
+		if (digitalocean_container === "ostagram1") {
+			// thanks to happysurf on github for reporting: https://github.com/qsniyg/maxurl/issues/1272
+			// https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/content/image/2922200/thumb_img_aaa0f64068.jpg
+			//   https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/content/image/2922200/img_aaa0f64068.jpg
+			// https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/pimage/imageurl/5624305/thumb_img5416824_4dfad540c009da9e.jpg
+			//   https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/pimage/imageurl/5624305/thumb_img5416824_4dfad540c009da9e.jpg
+			// https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/client/avatar/162973/avatar100_img.jpg
+			//   https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/client/avatar/162973/img.jpg
+			return src
+				.replace(/(\/image\/+[0-9]+\/+)thumb_/, "$1")
+				.replace(/(\/client\/+avatar\/+[0-9]+\/+)avatar[0-9]+_/, "$1");
+		}
+
+		if (domain_nowww === "ostagram.me") {
+			// thanks to happysurf on github for reporting: https://github.com/qsniyg/maxurl/issues/1272
+			// https://www.ostagram.me/assets/lightbox/next-15b869b02c6fbaa8c6c26445a2dd2d9bad80fd27b1409f8179e5dd89dc89d90a.png
+			if (/\/assets\/+lightbox\/+[^/]+\.png(?:[?#].*)?$/.test(src))
+				return {
+					url: src,
+					bad: "mask"
+				};
+		}
+
 
 
 
@@ -119396,7 +119427,7 @@ var $$IMU_EXPORT$$;
 
 	var is_probably_video = function(obj) {
 		//console_log(obj);
-		if (obj.media_info.type === "video")
+		if (obj.media_info && obj.media_info.type === "video")
 			return true;
 
 		if (/\.(?:mp4|webm|mkv|mpg|ogv|wmv|m3u8|mpd)(?:[?#].*)?$/i.test(obj.url))
@@ -119407,7 +119438,7 @@ var $$IMU_EXPORT$$;
 
 	var is_probably_audio = function(obj) {
 		//console_log(obj);
-		if (obj.media_info.type === "audio")
+		if (obj.media_info && obj.media_info.type === "audio")
 			return true;
 
 		if (/\.(?:mp3|m4a|oga|mkv|wma|mp4|ogg)(?:[?#].*)?$/i.test(obj.url))
diff --git a/userscript.user.js b/userscript.user.js
index 0f075e86..4b7c1128 100644
--- a/userscript.user.js
+++ b/userscript.user.js
@@ -32992,7 +32992,9 @@ var $$IMU_EXPORT$$;
 			// https://66.media.tumblr.com/2f1e06be02fe7b7cac4c7f1634a9fcc5/0117045da5da2818-ab/s1280x1920/c2e312c7c204a31974c1a45472a929e5ddc2b7de.jpg
 			// thanks to modelfe on github: https://github.com/qsniyg/maxurl/issues/88#issuecomment-637202663
 			// https://66.media.tumblr.com/7378b1813629aa8b841f6079ab9303a4/e24e926459952d1b-b1/s64x64u_c1/c7acf4139f2981e5d3ddaa6686e9240f3cf6f98d.jpg
-			if (options.do_request && options.cb && /:\/\/[^/]+\/+[0-9a-f]{32}\/+[0-9a-f]{16}-[0-9a-f]{2}\/+s[0-9]+x[0-9]+u?(?:_c[0-9]+)?\/+[0-9a-f]{20,}\./.test(src)) {
+			// thanks to anonymous for reporting:
+			// https://44.media.tumblr.com/a415b30327591b1233ec0c9783b7b3bb/8876be95cf21457f-55/s400x600_f1/195209414c3eeede4e1a577c7ae527e4c279db53.gif
+			if (options.do_request && options.cb && /:\/\/[^/]+\/+[0-9a-f]{32}\/+[0-9a-f]{16}-[0-9a-f]{2}\/+s[0-9]+x[0-9]+u?(?:_[fc][0-9]+)?\/+[0-9a-f]{20,}\./.test(src)) {
 				var get_initialstate_from_text = function(text) {
 					var match = text.match(/window\['___INITIAL_STATE___'\]\s*=\s*({.*?"ImageUrlPage":.*?})\s*;\s*(?:<\/script>[\s\S]*)?$/);
 					if (match) {
@@ -33012,7 +33014,7 @@ var $$IMU_EXPORT$$;
 					return null;
 				};
 				var url_to_tumblr_imageinfo = function(url) {
-					var match = url.match(/:\/\/[^/]+\/+([0-9a-f]{32})\/+([0-9a-f]{16}-[0-9a-f]{2})\/+s([0-9]+)x([0-9]+)u?(?:_c[0-9]+)?\/+[0-9a-f]{20,}\.([^/.?#]+)(?:[?#].*)?$/);
+					var match = url.match(/:\/\/[^/]+\/+([0-9a-f]{32})\/+([0-9a-f]{16}-[0-9a-f]{2})\/+s([0-9]+)x([0-9]+)u?(?:_[a-z][0-9]+)?\/+[0-9a-f]{20,}\.([^/.?#]+)(?:[?#].*)?$/);
 					if (match) {
 						return {
 							mediaKey: match[1] + ":" + match[2],
@@ -100350,7 +100352,6 @@ var $$IMU_EXPORT$$;
 			return src.replace(/^[a-z]+:\/\/[^/]+\/+cache\/+sites\/+.\/+.\/+([^/]+\.[^/]+\/.*?)\/[0-9]+x[0-9]*(?:\([^/]+\)|-[a-z]+)?\/+([^/]+)(?:[?#].*)?$/, "http://$1/$2");
 		}
 		if (domain_nowww === "bilibili.com") {
-			// https://www.bilibili.com/video/BV11t421H7bz/?spm_id_from=333.1073.high_energy.content.click
 			newsrc = website_query({
 				website_regex: /^[a-z]+:\/\/[^/]+\/+video\/+([A-Za-z0-9]+)\/*(?:[?#].*)?$/,
 				query_for_id: "https://www.bilibili.com/video/${id}/",
@@ -100404,6 +100405,33 @@ var $$IMU_EXPORT$$;
 			if (newsrc)
 				return newsrc;
 		}
+		if (domain_nowww === "parismatch.com") {
+			// thanks to anonymous for reporting:
+			// https://www.parismatch.com/lmnr/f/webp/r/960,640,FFFFFF,forcex,center-middle/img/var/pm/public/styles/paysage/public/media/image/2022/03/02/08/Margot-Robbie-Je-fais-partie-d-une-generation-de-femmes-qui-veulent-tout-avoir-dans-la-vie.jpg
+			//   https://www.parismatch.com/lmnr/img/var/pm/public/styles/paysage/public/media/image/2022/03/02/08/Margot-Robbie-Je-fais-partie-d-une-generation-de-femmes-qui-veulent-tout-avoir-dans-la-vie.jpg
+			return src.replace(/(\/lmnr\/+)(?:[fr]\/+[^/]+\/+)+(img\/+)/, "$1$2");
+		}
+		if (digitalocean_container === "ostagram1") {
+			// thanks to happysurf on github for reporting: https://github.com/qsniyg/maxurl/issues/1272
+			// https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/content/image/2922200/thumb_img_aaa0f64068.jpg
+			//   https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/content/image/2922200/img_aaa0f64068.jpg
+			// https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/pimage/imageurl/5624305/thumb_img5416824_4dfad540c009da9e.jpg
+			//   https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/pimage/imageurl/5624305/thumb_img5416824_4dfad540c009da9e.jpg
+			// https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/client/avatar/162973/avatar100_img.jpg
+			//   https://ostagram1.ams3.cdn.digitaloceanspaces.com/uploads/client/avatar/162973/img.jpg
+			return src
+				.replace(/(\/image\/+[0-9]+\/+)thumb_/, "$1")
+				.replace(/(\/client\/+avatar\/+[0-9]+\/+)avatar[0-9]+_/, "$1");
+		}
+		if (domain_nowww === "ostagram.me") {
+			// thanks to happysurf on github for reporting: https://github.com/qsniyg/maxurl/issues/1272
+			// https://www.ostagram.me/assets/lightbox/next-15b869b02c6fbaa8c6c26445a2dd2d9bad80fd27b1409f8179e5dd89dc89d90a.png
+			if (/\/assets\/+lightbox\/+[^/]+\.png(?:[?#].*)?$/.test(src))
+				return {
+					url: src,
+					bad: "mask"
+				};
+		}
 		// -- general rules --
 		if (src.match(/\/ImageGen\.ashx\?/)) {
 			// http://www.lookalikes.info/umbraco/ImageGen.ashx?image=/media/97522/nick%20hewer%20-%20mark%20brown.jpeg&width=250&constrain=true
@@ -106554,7 +106582,7 @@ var $$IMU_EXPORT$$;
 	var mediadelivery_support = {};
 	var is_probably_video = function(obj) {
 		//console_log(obj);
-		if (obj.media_info.type === "video")
+		if (obj.media_info && obj.media_info.type === "video")
 			return true;
 		if (/\.(?:mp4|webm|mkv|mpg|ogv|wmv|m3u8|mpd)(?:[?#].*)?$/i.test(obj.url))
 			return true;
@@ -106562,7 +106590,7 @@ var $$IMU_EXPORT$$;
 	};
 	var is_probably_audio = function(obj) {
 		//console_log(obj);
-		if (obj.media_info.type === "audio")
+		if (obj.media_info && obj.media_info.type === "audio")
 			return true;
 		if (/\.(?:mp3|m4a|oga|mkv|wma|mp4|ogg)(?:[?#].*)?$/i.test(obj.url))
 			return true;