修正: 動画ビューア描画における123av用サンドボックス保護と透明広告リンク監視を追加
UnifiedHtmlRendererおよびLegacyのHtmlRendererにて、123av関連ドメイン接続時にiframeのsandbox属性(ポップアップ遮断・プレイヤー操作許可)を設定し、Plyrコントローラーに干渉せず外部遷移aタグのみを除去する監視処理を追加
This commit is contained in:
1 parent
0e805184d9
commit
210543ba1f
2 files changed
+80
-33
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using WebImageViewer.Class.Legacy.Models;
|
using WebImageViewer.Class.Legacy.Models;
|
||||||
|
|
||||||
@@ -630,10 +630,10 @@ public static class HtmlRenderer
|
|||||||
|
|
||||||
<!-- メインビューアー -->
|
<!-- メインビューアー -->
|
||||||
<main class="viewer-container">
|
<main class="viewer-container">
|
||||||
|
|
||||||
<!-- 縦スクロールモード表示 -->
|
<!-- 縦スクロールモード表示 -->
|
||||||
<div class="scroll-mode-view" id="scrollModeView">
|
<div class="scroll-mode-view" id="scrollModeView">
|
||||||
|
|
||||||
<!-- メタ情報カード -->
|
<!-- メタ情報カード -->
|
||||||
<div class="info-card">
|
<div class="info-card">
|
||||||
<h2>{{title}}</h2>
|
<h2>{{title}}</h2>
|
||||||
@@ -665,7 +665,7 @@ public static class HtmlRenderer
|
|||||||
<div class="slide-mode-view" id="slideModeView">
|
<div class="slide-mode-view" id="slideModeView">
|
||||||
<div class="slide-stage" id="slideStage">
|
<div class="slide-stage" id="slideStage">
|
||||||
<img class="slide-image" id="currentSlideImage" src="" alt="Slide Image" />
|
<img class="slide-image" id="currentSlideImage" src="" alt="Slide Image" />
|
||||||
|
|
||||||
<div class="slide-nav-zone slide-nav-prev" id="slidePrevZone" title="前のページへ (← / A)">
|
<div class="slide-nav-zone slide-nav-prev" id="slidePrevZone" title="前のページへ (← / A)">
|
||||||
<div class="nav-arrow-icon">
|
<div class="nav-arrow-icon">
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M15 18l-6-6 6-6"/></svg>
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M15 18l-6-6 6-6"/></svg>
|
||||||
@@ -1115,7 +1115,7 @@ public static class HtmlRenderer
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
background-image:
|
background-image:
|
||||||
radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.15), transparent 40%),
|
radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.15), transparent 40%),
|
||||||
radial-gradient(circle at 85% 80%, rgba(236, 72, 153, 0.12), transparent 40%);
|
radial-gradient(circle at 85% 80%, rgba(236, 72, 153, 0.12), transparent 40%);
|
||||||
}
|
}
|
||||||
@@ -1720,8 +1720,6 @@ public static class HtmlRenderer
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
""";
|
""";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1925,7 +1923,7 @@ public static class HtmlRenderer
|
|||||||
playerUrl ??= $"https://javplayer.cc/v/{safeId}";
|
playerUrl ??= $"https://javplayer.cc/v/{safeId}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// サイト別の設定(名称、バッジ、グラデーション、プライマリカラー)
|
// サイト別の設定(名称、バッジ、グラデーション、プライマリカラー)
|
||||||
string siteDisplayName;
|
string siteDisplayName;
|
||||||
string badgeText;
|
string badgeText;
|
||||||
@@ -2106,7 +2104,6 @@ public static class HtmlRenderer
|
|||||||
playerUrl ??= $"https://video.fc2.com/a/embed/player/{safeId}/";
|
playerUrl ??= $"https://video.fc2.com/a/embed/player/{safeId}/";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
siteDisplayName = !string.IsNullOrWhiteSpace(site) ? site.ToUpperInvariant() : "動画プレイヤー";
|
siteDisplayName = !string.IsNullOrWhiteSpace(site) ? site.ToUpperInvariant() : "動画プレイヤー";
|
||||||
badgeText = "WEB VIDEO";
|
badgeText = "WEB VIDEO";
|
||||||
@@ -2117,10 +2114,19 @@ public static class HtmlRenderer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is123Av = string.Equals(normalizedSite, "123av", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
(!string.IsNullOrWhiteSpace(originalUrl) && originalUrl.Contains("123av.", StringComparison.OrdinalIgnoreCase)) ||
|
||||||
|
(!string.IsNullOrWhiteSpace(playerUrl) && (playerUrl.Contains("123av.", StringComparison.OrdinalIgnoreCase) || playerUrl.Contains("jav-master", StringComparison.OrdinalIgnoreCase) || playerUrl.Contains("javplayer.cc", StringComparison.OrdinalIgnoreCase) || playerUrl.Contains("sadie-shop.site", StringComparison.OrdinalIgnoreCase)));
|
||||||
|
|
||||||
|
var effectivePlayerUrl = (!string.IsNullOrWhiteSpace(playerUrl) && is123Av && !playerUrl.StartsWith("/api/clean-embed", StringComparison.OrdinalIgnoreCase))
|
||||||
|
? $"/api/clean-embed?url={Uri.EscapeDataString(playerUrl.Trim())}&referer={Uri.EscapeDataString(!string.IsNullOrWhiteSpace(originalUrl) ? originalUrl.Trim() : defaultOrigUrl)}"
|
||||||
|
: (playerUrl ?? "");
|
||||||
|
|
||||||
var safeTitle = !string.IsNullOrWhiteSpace(title) ? Encoder.Encode(title) : $"{siteDisplayName} 動画プレイヤー ({safeId})";
|
var safeTitle = !string.IsNullOrWhiteSpace(title) ? Encoder.Encode(title) : $"{siteDisplayName} 動画プレイヤー ({safeId})";
|
||||||
var safeOriginalUrl = !string.IsNullOrWhiteSpace(originalUrl) ? Encoder.Encode(originalUrl) : defaultOrigUrl;
|
var safeOriginalUrl = !string.IsNullOrWhiteSpace(originalUrl) ? Encoder.Encode(originalUrl) : defaultOrigUrl;
|
||||||
var safePlayerUrl = !string.IsNullOrWhiteSpace(playerUrl) ? Encoder.Encode(playerUrl) : "";
|
var safePlayerUrl = !string.IsNullOrWhiteSpace(effectivePlayerUrl) ? Encoder.Encode(effectivePlayerUrl) : "";
|
||||||
var safeStreamUrl = !string.IsNullOrWhiteSpace(streamUrl) ? Encoder.Encode(streamUrl) : "";
|
var safeStreamUrl = !string.IsNullOrWhiteSpace(streamUrl) ? Encoder.Encode(streamUrl) : "";
|
||||||
|
var sandboxAttr = is123Av ? """sandbox="allow-scripts allow-same-origin allow-forms allow-presentation" """ : "";
|
||||||
|
|
||||||
bool hasStream = !string.IsNullOrEmpty(safeStreamUrl);
|
bool hasStream = !string.IsNullOrEmpty(safeStreamUrl);
|
||||||
bool hasPlayer = !string.IsNullOrEmpty(safePlayerUrl);
|
bool hasPlayer = !string.IsNullOrEmpty(safePlayerUrl);
|
||||||
@@ -2158,7 +2164,7 @@ public static class HtmlRenderer
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-image:
|
background-image:
|
||||||
radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12), transparent 40%),
|
radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12), transparent 40%),
|
||||||
radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.12), transparent 40%);
|
radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.12), transparent 40%);
|
||||||
}
|
}
|
||||||
@@ -2410,16 +2416,16 @@ public static class HtmlRenderer
|
|||||||
{{(hasStream ? $$"""
|
{{(hasStream ? $$"""
|
||||||
<video id="hlsVideo" class="player-video" controls playsinline preload="auto" poster=""></video>
|
<video id="hlsVideo" class="player-video" controls playsinline preload="auto" poster=""></video>
|
||||||
""" : (hasPlayer ? $$"""
|
""" : (hasPlayer ? $$"""
|
||||||
<iframe
|
<iframe
|
||||||
id="videoIframe"
|
id="videoIframe"
|
||||||
src="{{safePlayerUrl}}"
|
src="{{safePlayerUrl}}"
|
||||||
class="player-iframe"
|
{{sandboxAttr}}class="player-iframe"
|
||||||
frameborder="0"
|
frameborder="0"
|
||||||
scrolling="no"
|
scrolling="no"
|
||||||
referrerpolicy="no-referrer-when-downgrade"
|
referrerpolicy="no-referrer-when-downgrade"
|
||||||
allowfullscreen="true"
|
allowfullscreen="true"
|
||||||
webkitallowfullscreen="true"
|
webkitallowfullscreen="true"
|
||||||
mozallowfullscreen="true"
|
mozallowfullscreen="true"
|
||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen">
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen">
|
||||||
</iframe>
|
</iframe>
|
||||||
""" : $$"""
|
""" : $$"""
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using WebImageViewer.Class.Unified.Models;
|
using WebImageViewer.Class.Unified.Models;
|
||||||
|
using WebImageViewer.Class.Unified.Services;
|
||||||
|
|
||||||
namespace WebImageViewer.Class.Unified.Renderers;
|
namespace WebImageViewer.Class.Unified.Renderers;
|
||||||
|
|
||||||
@@ -454,12 +455,12 @@ public static class UnifiedHtmlRenderer
|
|||||||
|
|
||||||
<div class="hero-form-card">
|
<div class="hero-form-card">
|
||||||
<form id="urlForm" class="hero-input-row" onsubmit="handleFormSubmit(event)">
|
<form id="urlForm" class="hero-input-row" onsubmit="handleFormSubmit(event)">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="urlInput"
|
id="urlInput"
|
||||||
class="hero-input"
|
class="hero-input"
|
||||||
placeholder="閲覧・再生したいページのURLを入力 (例: https://missav.ai/..., https://hitomi.la/...)"
|
placeholder="閲覧・再生したいページのURLを入力 (例: https://missav.ai/..., https://hitomi.la/...)"
|
||||||
required
|
required
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
<button type="submit" class="hero-submit-btn">閲覧・再生</button>
|
<button type="submit" class="hero-submit-btn">閲覧・再生</button>
|
||||||
@@ -565,11 +566,17 @@ public static class UnifiedHtmlRenderer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string RenderVideoViewer(UnifiedVideoItem video)
|
public static string RenderVideoViewer(UnifiedVideoItem video)
|
||||||
{
|
{
|
||||||
|
bool is123Av = UnifiedEmbedSanitizer.Is123AvDomain(video.Site, video.OriginalUrl, video.EmbedUrl);
|
||||||
|
var effectiveEmbedUrl = (!string.IsNullOrWhiteSpace(video.EmbedUrl) && is123Av)
|
||||||
|
? UnifiedEmbedSanitizer.ToCleanEmbedUrl(video.EmbedUrl, video.OriginalUrl)
|
||||||
|
: (video.EmbedUrl ?? "");
|
||||||
|
|
||||||
var safeTitle = Encoder.Encode(video.Title);
|
var safeTitle = Encoder.Encode(video.Title);
|
||||||
var safeOrigUrl = Encoder.Encode(video.OriginalUrl);
|
var safeOrigUrl = Encoder.Encode(video.OriginalUrl);
|
||||||
var safeEmbedUrl = !string.IsNullOrWhiteSpace(video.EmbedUrl) ? Encoder.Encode(video.EmbedUrl) : "";
|
var safeEmbedUrl = !string.IsNullOrWhiteSpace(effectiveEmbedUrl) ? Encoder.Encode(effectiveEmbedUrl) : "";
|
||||||
var safeStreamUrl = !string.IsNullOrWhiteSpace(video.StreamUrl) ? Encoder.Encode(video.StreamUrl) : "";
|
var safeStreamUrl = !string.IsNullOrWhiteSpace(video.StreamUrl) ? Encoder.Encode(video.StreamUrl) : "";
|
||||||
var safePoster = !string.IsNullOrWhiteSpace(video.PosterUrl) ? Encoder.Encode(video.PosterUrl) : "";
|
var safePoster = !string.IsNullOrWhiteSpace(video.PosterUrl) ? Encoder.Encode(video.PosterUrl) : "";
|
||||||
|
var sandboxAttr = is123Av ? """sandbox="allow-scripts allow-same-origin allow-forms allow-presentation" """ : "";
|
||||||
|
|
||||||
bool hasStream = !string.IsNullOrEmpty(safeStreamUrl);
|
bool hasStream = !string.IsNullOrEmpty(safeStreamUrl);
|
||||||
bool hasEmbed = !string.IsNullOrEmpty(safeEmbedUrl);
|
bool hasEmbed = !string.IsNullOrEmpty(safeEmbedUrl);
|
||||||
@@ -726,16 +733,16 @@ public static class UnifiedHtmlRenderer
|
|||||||
{{(hasStream ? $$"""
|
{{(hasStream ? $$"""
|
||||||
<video id="hlsVideo" class="player-video" controls playsinline preload="auto" poster="{{safePoster}}"></video>
|
<video id="hlsVideo" class="player-video" controls playsinline preload="auto" poster="{{safePoster}}"></video>
|
||||||
""" : (hasEmbed ? $$"""
|
""" : (hasEmbed ? $$"""
|
||||||
<iframe
|
<iframe
|
||||||
id="videoIframe"
|
id="videoIframe"
|
||||||
src="{{safeEmbedUrl}}"
|
src="{{safeEmbedUrl}}"
|
||||||
class="player-iframe"
|
{{sandboxAttr}}class="player-iframe"
|
||||||
frameborder="0"
|
frameborder="0"
|
||||||
scrolling="no"
|
scrolling="no"
|
||||||
referrerpolicy="no-referrer-when-downgrade"
|
referrerpolicy="no-referrer-when-downgrade"
|
||||||
allowfullscreen="true"
|
allowfullscreen="true"
|
||||||
webkitallowfullscreen="true"
|
webkitallowfullscreen="true"
|
||||||
mozallowfullscreen="true"
|
mozallowfullscreen="true"
|
||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen">
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen">
|
||||||
</iframe>
|
</iframe>
|
||||||
""" : $$"""
|
""" : $$"""
|
||||||
@@ -808,6 +815,40 @@ public static class UnifiedHtmlRenderer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 123av ドメイン接続時の透明リンクエリア・外部リンク除去バックアップ監視
|
||||||
|
const is123AvDomain = {{(is123Av ? "true" : "false")}};
|
||||||
|
const videoIframe = document.getElementById('videoIframe');
|
||||||
|
if (is123AvDomain) {
|
||||||
|
try {
|
||||||
|
Object.defineProperty(window, 'open', {
|
||||||
|
value: function() { return null; },
|
||||||
|
writable: false,
|
||||||
|
configurable: false
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
window.open = function() { return null; };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoIframe) {
|
||||||
|
const cleanIframeOverlays = () => {
|
||||||
|
try {
|
||||||
|
const doc = videoIframe.contentDocument || (videoIframe.contentWindow && videoIframe.contentWindow.document);
|
||||||
|
if (!doc) return;
|
||||||
|
const links = doc.querySelectorAll('body > a, a[target="_blank"], a[style*="999999"], ins');
|
||||||
|
links.forEach(el => {
|
||||||
|
el.removeAttribute('href');
|
||||||
|
el.removeAttribute('target');
|
||||||
|
el.style.setProperty('pointer-events', 'none', 'important');
|
||||||
|
el.style.setProperty('display', 'none', 'important');
|
||||||
|
el.remove();
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
};
|
||||||
|
videoIframe.addEventListener('load', cleanIframeOverlays);
|
||||||
|
setInterval(cleanIframeOverlays, 250);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in new issue
Block a user