From 8445e3d1d878c29cf1b28b4aa68371f9bcde9b24 Mon Sep 17 00:00:00 2001 From: qsniyg Date: Fri, 8 Nov 2024 08:00:48 +0000 Subject: [PATCH] Update userscript --- userscript_smaller.user.js | 307 ++++++++++++++++++++++++++++--------- 1 file changed, 234 insertions(+), 73 deletions(-) diff --git a/userscript_smaller.user.js b/userscript_smaller.user.js index 3bb5707f..b23ae845 100644 --- a/userscript_smaller.user.js +++ b/userscript_smaller.user.js @@ -11776,6 +11776,18 @@ var $$IMU_EXPORT$$; // https://www.test.com./ -> https://www.test.com/ .replace(/^([a-z]+:\/\/[^/]+\.[^/]+)\.([?#/].*)?$/, "$1$2"); }; + var get_base = function(document, url) { + if (typeof document === "string") { + var match = document.match(/]*href=["']([^'"]+)["']/); + if (match) { + return decode_entities(match[1]); + } else { + return url; + } + } else { + return document.baseURI || url; + } + }; function urljoin(a, b, browser) { if (b.length === 0) return a; @@ -11795,6 +11807,11 @@ var $$IMU_EXPORT$$; // urljoin("http://site.com/index.html", "file.png") = "http://site.com/index.html/file.png" return a.replace(/\/*$/, "") + "/" + b.replace(/^\/*/, ""); } else { + if (browser === "real") { + if (is_interactive && !is_extension_bg && typeof document === "object") { + a = get_base(document, a); + } + } if (b.length >= 2 && b.slice(0, 2) === "//") return protocol + ":" + b; if (b.length >= 1 && b.slice(0, 1) === "/") @@ -11831,7 +11848,7 @@ var $$IMU_EXPORT$$; var match; if (options.known_ext) { // todo: factor out? - match = basename.match(/(.*?)\.(mp4|mpe?g|jpe?g|jfif|png|tiff|og[agv]|m4[av]|web[pm]|mkv|avi|gif|mpd|m3u8|zip)$/i); + match = basename.match(/(.*?)\.(mp4|mpe?g|jpe?g|jfif|png|tiff|og[agv]|m4[av]|web[pm]|mkv|mov|avi|gif|mpd|m3u8|zip)$/i); } else { match = basename.match(/(.*)\.([^.]*)$/); } @@ -12690,7 +12707,8 @@ var $$IMU_EXPORT$$; }; var contenttype_map = { "image/jpeg": "jpg", - "application/dash+xml": "mpd" + "application/dash+xml": "mpd", + "video/quicktime": "mov" }; var get_ext_from_contenttype = function(contenttype) { contenttype = contenttype.replace(/^\s*\[?([^/]+)\/([^/]+?)\]?\s*$/, "$1/$2"); @@ -15124,14 +15142,20 @@ var $$IMU_EXPORT$$; maxsize = 0; maxobj = null; var videos = img.video_versions; + var video_hevc = null; for (var i = 0; i < videos.length; i++) { videos[i].corrected_height = get_corrected_height(img, videos[i]); var size = videos[i].width * videos[i].corrected_height; - // >= because for some reason, in stories, type 102==103, but higher quality than 101 (all same dimensions) - // thanks to remlap on discord for reporting - if (size >= maxsize) { - maxsize = size; - maxobj = videos[i]; + // 104 > 101, but 104/_ptProgressive.mp4 is HEVC + if (string_indexof(videos[i].url, "_ptProgressive.mp4") >= 0) { + video_hevc = videos[i]; + } else { + // >= because for some reason, in stories, type 102==103, but higher quality than 101 (all same dimensions) + // thanks to remlap on discord for reporting + if (size >= maxsize) { + maxsize = size; + maxobj = videos[i]; + } } } if (maxobj !== null) { @@ -15142,6 +15166,9 @@ var $$IMU_EXPORT$$; if (img.video_dash_manifest) { image.video_dash = img.video_dash_manifest; } + if (video_hevc) { + image.video_hevc = video_hevc.url; + } } if (image !== null) { images.push(image); @@ -15271,6 +15298,17 @@ var $$IMU_EXPORT$$; }); } } + if (image.video_hevc) { + preobj.push({ + url: common_functions["instagram_norm_url"](image.video_hevc), + media_info: { + type: "video", + codec: "hevc" + }, + extra: deepcopy(extra), + album_info: deepcopy(album_info) + }); + } if (image.video_dash) { var dashurl = "data:application/dash+xml," + encodeURIComponent(image.video_dash); preobj.push(common_functions["set_cdninstagram_obj"]({ @@ -17293,7 +17331,7 @@ var $$IMU_EXPORT$$; return null; } var add_source = function(parsed) { - parsed.name = parsed.args.title || null; + parsed.name = parsed.args.res || parsed.args.title || parsed.args.label || null; parsed.url = parsed.args.src; sources.video.push(parsed); }; @@ -17428,6 +17466,7 @@ var $$IMU_EXPORT$$; page = urljoin(resp.finalUrl, page, true); else page = resp.finalUrl; + var baseurl = get_base(resp.responseText, page); var obj = { headers: { Referer: page @@ -17448,7 +17487,7 @@ var $$IMU_EXPORT$$; }); var video_urls = []; array_foreach(sources.video, function(source) { - video_urls.push(urljoin(page, source.url, true)); + video_urls.push(urljoin(baseurl, source.url, true)); }); var subs = null; if (sources.subtitles && sources.subtitles.length) { @@ -17456,24 +17495,24 @@ var $$IMU_EXPORT$$; for (var _i = 0, _a = sources.subtitles; _i < _a.length; _i++) { var subtitle = _a[_i]; var baseobj = deepcopy(subtitle); - baseobj.url = urljoin(page, subtitle.url, true); + baseobj.url = urljoin(baseurl, subtitle.url, true); subs.push(baseobj); } } if (options.ogvideo) { var ogvideo = get_meta(resp.responseText, "og:video"); if (ogvideo) { - array_upush(video_urls, urljoin(page, ogvideo, true)); + array_upush(video_urls, urljoin(baseurl, ogvideo, true)); } } var image_urls = []; array_foreach(sources.image, function(image) { - image_urls.push(urljoin(page, image, true)); + image_urls.push(urljoin(baseurl, image, true)); }); if (options.ogimage) { var ogimage = get_meta(resp.responseText, "og:image"); if (ogimage) { - array_upush(image_urls, urljoin(page, ogimage, true)); + array_upush(image_urls, urljoin(baseurl, ogimage, true)); } } var urls = []; @@ -22412,7 +22451,8 @@ var $$IMU_EXPORT$$; (domain_nosub === "sunderlandafc.news" && /^cdn[0-9]*\./.test(domain) && /\/uploads\//.test(src)) || (domain === "cdn.cherrynudes.com" && /\/app\/+uploads\//.test(src)) || (domain === "cdn.bunnylust.com" && /\/app\/+uploads\//.test(src)) || - domain === "wp-assets.futurism.com") { + domain === "wp-assets.futurism.com" || + domain === "cdn.entameclip.com") { src = src.replace(/-[0-9]+x[0-9]+\.([^/]*(?:[?#].*)?)$/, ".$1"); } if ((domain === "store.pinseyun.com" && string_indexof(src, "/uploads/") >= 0) || @@ -27184,7 +27224,8 @@ var $$IMU_EXPORT$$; if (newsrc !== src) return newsrc; } - if (domain_nowww === "tnaflix.com") { + if (domain_nowww === "tnaflix.com" || + domain_nowww === "empflix.com") { newsrc = website_query({ website_regex: /^[a-z]+:\/\/[^/]+\/+[^/]+\/+[^/]+\/+video([0-9]+)(?:[?#].*)?$/, query_for_id: function(id) { @@ -27198,14 +27239,14 @@ var $$IMU_EXPORT$$; json: true }; }, - process: function(done, resp, cache_key) { + process: function(done, resp, cache_key, match) { if (!resp.html) { console_error(cache_key, "Unable to find html from", resp); return done(null, false); } var fakeresp = { responseText: resp.html, - finalUrl: "https://www.tnaflix.com/" + finalUrl: "https://" + domain_nosub + "/a/a/video" + match[1] }; var obj = common_functions["get_videotag_obj"](fakeresp); if (!obj) @@ -27238,10 +27279,18 @@ var $$IMU_EXPORT$$; is_pagelink = false; match = src.match(/^[a-z]+:\/\/img[0-9]*\.[^/]+\/+[^/]+\/+thumbs\/+[0-9a-f]{2}\/+([0-9]+)-[0-9]+l\./); } + if (!match) { + is_pagelink = false; + match = src.match(/^[a-z]+:\/\/img[0-9]*\.[^/]+\/+[^/]+\/+.*\/([0-9]+)\/+thumbs\/+[0-9]+\./); + } if (!match) { is_pagelink = false; match = src.match(/^[a-z]+:\/\/mosaic\.[^/]+\/+([0-9]+)\/+a[0-9]+(?::[^/]+)?\/+/); } + if (!match) { + is_pagelink = false; + match = src.match(/^[a-z]+:\/\/[^/]+\/+(?:[0-9]+\/+)+([0-9]+)\/+trailer\.mp4(?:[?#].*)?$/); + } if (!match) { is_pagelink = false; match = src.match(/\/trailer\/+empflix\/+(?:[0-9a-f]\/+){3}([0-9a-f]+)\./); @@ -27327,6 +27376,12 @@ var $$IMU_EXPORT$$; url: "https://www." + base_domain + "/view_video.php?viewkey=" + vkey }, cb, process_tnaflix_site); }; + if (!is_vkey) { + return { + url: "https://www." + base_domain + "/a/a/video" + id, + is_pagelink: true + }; + } if (options.do_request && options.cb) { var final = function(data) { query_tnaflix_api(data, options.cb); @@ -28457,24 +28512,21 @@ var $$IMU_EXPORT$$; caption: data.video_title } }; - var max = 0; - var maxobj = null; - for (var i = 0; i < data.mediaDefinitions.length; i++) { - var media = data.mediaDefinitions[i]; - var our_quality = parseInt(media.quality); - if (!isNaN(our_quality) && our_quality > max && media.videoUrl) { - max = our_quality; - maxobj = media; - } - } + data.mediaDefinitions.sort(function(a, b) { + return b.height - a.height; + }); var urls = []; - if (maxobj) { + for (var _i = 0, _a = data.mediaDefinitions; _i < _a.length; _i++) { + var md = _a[_i]; + continue; // FIXME: md.videoUrl returns a json urls.push({ - url: maxobj.videoUrl, - video: true, + url: urljoin("https://www.redtube.com/", md.videoUrl, true), + video: md.format === "hls" ? "hls" : true, headers: { Referer: baseobj.extra.page, - Origin: "https://redtube.com" + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-origin" } }); } @@ -30320,8 +30372,9 @@ var $$IMU_EXPORT$$; } if (domain_nowww === "konsolinet.fi") return src.replace(/(:\/\/[^/]*\/[^/]*\/)[0-9]+x[0-9]+\//, "$1"); if ((domain_nosub === "vigbo.com" || + domain_nosub === "vigbo.tech" || domain_nosub === "gophotoweb.com") && - domain.match(/^static[0-9]*\./)) { + domain.match(/^static[0-9]*(?:-cdn[^./]+)?\./)) { return src.replace(/\/[0-9]+-((?:[^/]*-)?[a-f0-9]{20,}\.[^/.]*)$/, "/2000-$1"); } if (domain_nosub === "feelway.com" && domain.match(/img[0-9]*.feelway\.com/)) { @@ -30373,7 +30426,10 @@ var $$IMU_EXPORT$$; .replace(/\/post_img\/([0-9]+)\//, "/post_img/big/$1/") .replace(/\/images\/+previews_comm\/+/, "/images/big_size_comm/"); } - if (domain_nosub === "podium.life") return src.replace(/\/content\/r\/[wh]?[0-9]*(?:x[0-9]+)?\//, "/content/"); + if (domain_nosub === "podium.life" || + domain === "c.podium.im") { + return src.replace(/(:\/\/[^/]+\/+(?:content\/+)?)r\/+[wh]?[0-9]*(?:x[0-9]+)?\/+/, "$1"); + } if (domain_nowww === "lelulove.com") return src.replace(/(\/content\/+photo\/+[0-9a-z]+\/+)thumbs\/+/, "$1full/"); if (domain_nosub === "filesor.com") { return { @@ -32304,6 +32360,7 @@ var $$IMU_EXPORT$$; domain === "cover.read.duokan.com" || (domain_nosub === "asus.com" && /^img(?:-[a-z]+)?[0-9]*\./.test(domain) && /!t[0-9]+x[0-9]+(?:[?#].*)?$/.test(src)) || (domain_nosub === "gitee.com" && /\/avatar\//.test(src)) || + domain === "image-assets.mihuashi.com" || domain === "img.mgpyh.com") { newsrc = src.replace(/!.*/, ""); if (newsrc !== src) @@ -35379,7 +35436,7 @@ var $$IMU_EXPORT$$; if (our_host === "xvideos") { return "https://www.xvideos.com/video." + videoid + "/a"; } else if (our_host === "xnxx") { - return "https://www.xnxx.com/video-" + videoid + "/"; + return "https://www.xnxx.com/video-" + videoid + "/a"; } }; var query_xvideos_page = function(videoid, cb) { @@ -35452,9 +35509,9 @@ var $$IMU_EXPORT$$; ; var videoid_to_videourl = function(videoid) { if (our_host === "xvideos") { - return "https://www.xvideos.com/video" + videoid + "/"; + return "https://www.xvideos.com/video" + videoid + "/a"; } else if (our_host === "xnxx") { - return "https://www.xnxx.com/video-" + videoid + "/"; + return "https://www.xnxx.com/video-" + videoid + "/a"; } }; var get_videoid_from_url = function(url) { @@ -35876,7 +35933,7 @@ var $$IMU_EXPORT$$; domain === "gdb.alhurra.eu" || domain === "gdb.rferl.org" || domain === "gdb.radiosawa.us") { - return src.replace(/(:\/\/[^/]*\/+[-0-9A-Fa-f]+)(?:_c?[a-z][0-9]*){1,}(\.[^/.]*)$/, "$1$2"); + return src.replace(/(:\/\/[^/]*\/+[-0-9A-Fa-f]+)(?:_(?:c?[a-z]|st)[0-9]*){1,}(\.[^/.]*)$/, "$1$2"); } if (domain === "img.nzz.ch") return src.replace(/^[a-z]+:\/\/[^/]+\/+(?:[A-Z]=[^/]+\/+){1,}(https?:\/\/)/, "$1"); if (domain === "images-cdn.impresa.pt" || @@ -36221,6 +36278,7 @@ var $$IMU_EXPORT$$; domain_nowww === "xhomealone.com" || domain_nosub === "porntrex.com" || domain_nosub === "cdntrex.com" || + domain_nowww === "alphavids.cc" || domain_nosub === "mylust.com" || domain_nosub === "yourlust.com" || domain_nowww === "pornrewind.com") { @@ -41142,7 +41200,10 @@ var $$IMU_EXPORT$$; if (domain_nosub === "foap.com" && domain.match(/^images[0-9]*\./)) { return src.replace(/:\/\/images[0-9]*(\.foap\.com\/images\/+[-0-9a-f]+\/+)[^/.]*(\.[^/.?#]*)(?:[?#].*)?$/, "://cdn2$1original$2"); } - if (domain_nowww === "themepack.me") return src.replace(/\/i\/+c\/+[0-9]+x[0-9]+\/+media\/+/, "/media/"); + if (domain_nowww === "themepack.me" || + domain_nowww === "motionbgs.com") { + return src.replace(/\/i\/+c\/+[0-9]+x[0-9]+\/+media\/+/, "/media/"); + } if (domain === "static.mycuteasian.com") return src.replace(/\/cache\/+(content\/+pictures\/+.*)\.[0-9]+x[0-9]+(\.[^/.]*)(?:[?#].*)?$/, "/$1$2"); if (domain_nowww === "jiji.com") return src.replace(/(\/v[0-9]*_photos\/.*)_[sm](\.[^/.]*)(?:[?#].*)?$/, "$1$2"); if (domain === "storage.mantan-web.jp" || @@ -48260,8 +48321,11 @@ var $$IMU_EXPORT$$; return cb(null); }); }; + var get_gfycat_access_token_cache_key_1 = function(site) { + return site + ":access_token_v2"; + }; var get_gfycat_temp_token_v2_1 = function(site, cb) { - var cache_key = site + ":access_token_v2"; + var cache_key = get_gfycat_access_token_cache_key_1(site); get_redgifs_token_localstorage_1(function(token) { if (token && false) return cb(token); @@ -48296,6 +48360,7 @@ var $$IMU_EXPORT$$; url: "https://api." + site + ".com/v2/gifs/" + id_lower + "?views=yes&users=yes&niches=yes", method: "GET", imu_mode: "xhr", + non200_ok: true, headers: { Origin: "https://www." + site + ".com", Referer: "https://www." + site + ".com", @@ -48307,6 +48372,13 @@ var $$IMU_EXPORT$$; }, json: true }, cb, function(done, json, cache_key) { + try { + if (json.error.code === "Unauthorized") { + api_cache.remove(get_gfycat_access_token_cache_key_1(site)); + console_error(cache_key, "Unauthorized, try again", json); + return done(null, false); + } + } catch (e) { } if (!json || !json.gif) { console_error(cache_key, "Unable to find json from", json); return done(null, false); @@ -56916,12 +56988,43 @@ var $$IMU_EXPORT$$; } if (domain === "matrix-client.matrix.org") return src.replace(/(\/_matrix\/+media\/+(?:r[0-9]+|v3)\/+)thumbnail\/+([^/]+\/+[-_a-zA-Z0-9]+)\?.*$/, "$1download/$2"); if (domain_nowww === "pornssd.com") { - match = src.match(/\/wp-content\/+plugins\/+clean-tube-player\/+public\/+player-x.php\?q=([^&]{50,})/); - if (match) { - var decoded = base64_decode(match[1]); - var queries = get_queries("?" + decoded); - return parse_tag_def(decodeURIComponent(queries.tag)).args.src; - } + newsrc = website_query({ + website_regex: /\/wp-content\/+plugins\/+clean-tube-player\/+public\/+player-x\.php\?q=([^&]{50,})/, + run: function(cb, match) { + var decoded = base64_decode(match[1]); + var queries = get_queries("?" + decoded); + var decoded_html = decodeURIComponent(queries.tag); + if (/