mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various fixes
This commit is contained in:
@@ -182,6 +182,11 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
||||
configuration.mediaPlaybackRequiresUserAction = false
|
||||
}
|
||||
|
||||
let contentController = WKUserContentController()
|
||||
let videoScript = WKUserScript(source: videoSource, injectionTime: .atDocumentStart, forMainFrameOnly: false)
|
||||
contentController.addUserScript(videoScript)
|
||||
configuration.userContentController = contentController
|
||||
|
||||
self.webView = WebView(frame: CGRect(), configuration: configuration)
|
||||
self.webView.allowsLinkPreview = true
|
||||
|
||||
@@ -601,7 +606,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
|
||||
if download {
|
||||
decisionHandler(.download, preferences)
|
||||
} else {
|
||||
decisionHandler(.cancel, preferences)
|
||||
// decisionHandler(.cancel, preferences)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -1147,6 +1152,48 @@ let setupFontFunctions = """
|
||||
})();
|
||||
"""
|
||||
|
||||
private let videoSource = """
|
||||
function disableWebkitEnterFullscreen(videoElement) {
|
||||
if (videoElement && videoElement.webkitEnterFullscreen) {
|
||||
Object.defineProperty(videoElement, 'webkitEnterFullscreen', {
|
||||
value: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function disableFullscreenOnExistingVideos() {
|
||||
document.querySelectorAll('video').forEach(disableWebkitEnterFullscreen);
|
||||
}
|
||||
|
||||
function handleMutations(mutations) {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
||||
mutation.addedNodes.forEach((newNode) => {
|
||||
if (newNode.tagName === 'VIDEO') {
|
||||
disableWebkitEnterFullscreen(newNode);
|
||||
}
|
||||
if (newNode.querySelectorAll) {
|
||||
newNode.querySelectorAll('video').forEach(disableWebkitEnterFullscreen);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
disableFullscreenOnExistingVideos();
|
||||
|
||||
const observer = new MutationObserver(handleMutations);
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
function disconnectObserver() {
|
||||
observer.disconnect();
|
||||
}
|
||||
"""
|
||||
|
||||
@available(iOS 16.0, *)
|
||||
final class BrowserSearchOptions: UITextSearchOptions {
|
||||
override var wordMatchMethod: UITextSearchOptions.WordMatchMethod {
|
||||
|
||||
Reference in New Issue
Block a user