修正: 動画ビューア描画における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 WebImageViewer.Class.Legacy.Models;
|
||||
|
||||
@@ -630,10 +630,10 @@ public static class HtmlRenderer
|
||||
|
||||
<!-- メインビューアー -->
|
||||
<main class="viewer-container">
|
||||
|
||||
|
||||
<!-- 縦スクロールモード表示 -->
|
||||
<div class="scroll-mode-view" id="scrollModeView">
|
||||
|
||||
|
||||
<!-- メタ情報カード -->
|
||||
<div class="info-card">
|
||||
<h2>{{title}}</h2>
|
||||
@@ -665,7 +665,7 @@ public static class HtmlRenderer
|
||||
<div class="slide-mode-view" id="slideModeView">
|
||||
<div class="slide-stage" id="slideStage">
|
||||
<img class="slide-image" id="currentSlideImage" src="" alt="Slide Image" />
|
||||
|
||||
|
||||
<div class="slide-nav-zone slide-nav-prev" id="slidePrevZone" title="前のページへ (← / A)">
|
||||
<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>
|
||||
@@ -1115,7 +1115,7 @@ public static class HtmlRenderer
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
background-image:
|
||||
background-image:
|
||||
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%);
|
||||
}
|
||||
@@ -1720,8 +1720,6 @@ public static class HtmlRenderer
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
""";
|
||||
}
|
||||
|
||||
@@ -1925,7 +1923,7 @@ public static class HtmlRenderer
|
||||
playerUrl ??= $"https://javplayer.cc/v/{safeId}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// サイト別の設定(名称、バッジ、グラデーション、プライマリカラー)
|
||||
string siteDisplayName;
|
||||
string badgeText;
|
||||
@@ -2106,7 +2104,6 @@ public static class HtmlRenderer
|
||||
playerUrl ??= $"https://video.fc2.com/a/embed/player/{safeId}/";
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
siteDisplayName = !string.IsNullOrWhiteSpace(site) ? site.ToUpperInvariant() : "動画プレイヤー";
|
||||
badgeText = "WEB VIDEO";
|
||||
@@ -2117,10 +2114,19 @@ public static class HtmlRenderer
|
||||
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 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 sandboxAttr = is123Av ? """sandbox="allow-scripts allow-same-origin allow-forms allow-presentation" """ : "";
|
||||
|
||||
bool hasStream = !string.IsNullOrEmpty(safeStreamUrl);
|
||||
bool hasPlayer = !string.IsNullOrEmpty(safePlayerUrl);
|
||||
@@ -2158,7 +2164,7 @@ public static class HtmlRenderer
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
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 85% 85%, rgba(236, 72, 153, 0.12), transparent 40%);
|
||||
}
|
||||
@@ -2410,16 +2416,16 @@ public static class HtmlRenderer
|
||||
{{(hasStream ? $$"""
|
||||
<video id="hlsVideo" class="player-video" controls playsinline preload="auto" poster=""></video>
|
||||
""" : (hasPlayer ? $$"""
|
||||
<iframe
|
||||
<iframe
|
||||
id="videoIframe"
|
||||
src="{{safePlayerUrl}}"
|
||||
class="player-iframe"
|
||||
frameborder="0"
|
||||
src="{{safePlayerUrl}}"
|
||||
{{sandboxAttr}}class="player-iframe"
|
||||
frameborder="0"
|
||||
scrolling="no"
|
||||
referrerpolicy="no-referrer-when-downgrade"
|
||||
allowfullscreen="true"
|
||||
webkitallowfullscreen="true"
|
||||
mozallowfullscreen="true"
|
||||
allowfullscreen="true"
|
||||
webkitallowfullscreen="true"
|
||||
mozallowfullscreen="true"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen">
|
||||
</iframe>
|
||||
""" : $$"""
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using WebImageViewer.Class.Unified.Models;
|
||||
using WebImageViewer.Class.Unified.Services;
|
||||
|
||||
namespace WebImageViewer.Class.Unified.Renderers;
|
||||
|
||||
@@ -454,12 +455,12 @@ public static class UnifiedHtmlRenderer
|
||||
|
||||
<div class="hero-form-card">
|
||||
<form id="urlForm" class="hero-input-row" onsubmit="handleFormSubmit(event)">
|
||||
<input
|
||||
type="text"
|
||||
id="urlInput"
|
||||
class="hero-input"
|
||||
placeholder="閲覧・再生したいページのURLを入力 (例: https://missav.ai/..., https://hitomi.la/...)"
|
||||
required
|
||||
<input
|
||||
type="text"
|
||||
id="urlInput"
|
||||
class="hero-input"
|
||||
placeholder="閲覧・再生したいページのURLを入力 (例: https://missav.ai/..., https://hitomi.la/...)"
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
<button type="submit" class="hero-submit-btn">閲覧・再生</button>
|
||||
@@ -565,11 +566,17 @@ public static class UnifiedHtmlRenderer
|
||||
/// </summary>
|
||||
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 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 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 hasEmbed = !string.IsNullOrEmpty(safeEmbedUrl);
|
||||
@@ -726,16 +733,16 @@ public static class UnifiedHtmlRenderer
|
||||
{{(hasStream ? $$"""
|
||||
<video id="hlsVideo" class="player-video" controls playsinline preload="auto" poster="{{safePoster}}"></video>
|
||||
""" : (hasEmbed ? $$"""
|
||||
<iframe
|
||||
<iframe
|
||||
id="videoIframe"
|
||||
src="{{safeEmbedUrl}}"
|
||||
class="player-iframe"
|
||||
frameborder="0"
|
||||
src="{{safeEmbedUrl}}"
|
||||
{{sandboxAttr}}class="player-iframe"
|
||||
frameborder="0"
|
||||
scrolling="no"
|
||||
referrerpolicy="no-referrer-when-downgrade"
|
||||
allowfullscreen="true"
|
||||
webkitallowfullscreen="true"
|
||||
mozallowfullscreen="true"
|
||||
allowfullscreen="true"
|
||||
webkitallowfullscreen="true"
|
||||
mozallowfullscreen="true"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen">
|
||||
</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>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in new issue
Block a user