diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 6d669cf5f..b558b04dc 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -83,6 +83,9 @@ final class DetailWebViewController: NSViewController { let preferences = WKPreferences() preferences.minimumFontSize = 12.0 preferences.javaScriptCanOpenWindowsAutomatically = false + if #available(macOS 12.3, *) { + preferences.isElementFullscreenEnabled = true + } let webpagePrefs = WKWebpagePreferences() diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index 13f90b638..e485eec5c 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -156,6 +156,78 @@ function removeWpSmiley() { } } +function addYouTubeVideos() { + const titleURL = document.querySelector(".articleTitle A").getAttribute("href") + const youTubeLink = "https://www.youtube.com/watch?v=" + if (!titleURL.startsWith(youTubeLink)) { + return; + } + + // Dynamically add the YouTube frame + const bodyContainer = document.querySelector("#bodyContainer"); + bodyContainer.setAttribute("style", "position: relative; padding-bottom: 56.25%; height: 100%; overflow: hidden;") + + var youTubeFrame = document.createElement("iFrame"); + youTubeFrame.setAttribute("src", "https://www.youtube.com/embed/" + titleURL.substring(youTubeLink.length)); + youTubeFrame.setAttribute("style", "position: absolute; top: 0; left: 0; width: 100%; height: 100%;"); + youTubeFrame.setAttribute("title", "YouTube video player"); + youTubeFrame.setAttribute("frameborder", "0"); + youTubeFrame.setAttribute("allow", "encrypted-media; picture-in-picture; web-share"); + youTubeFrame.setAttribute("allowfullscreen", "true"); + bodyContainer.appendChild(youTubeFrame); + + // No YouTube ADS - YouTube https://github.com/GSRHackZ/No-ADS-YouTube + let ogVolume=1; + let pbRate = 1; + + setInterval(function(){ + if(document.getElementsByClassName("video-stream html5-main-video")[0]!==undefined){ + let ad = document.getElementsByClassName("video-ads ytp-ad-module")[0]; + let vid = document.getElementsByClassName("video-stream html5-main-video")[0]; + if(ad==undefined){ + pbRate = vid.playbackRate; + } + let closeAble = document.getElementsByClassName("ytp-ad-overlay-close-button"); + for(let i=0;i0){ + if(document.getElementsByClassName("ytp-ad-text ytp-ad-preview-text")[0]!==undefined){ + vid.playbackRate=16; + //console.log("Incrementally skipped unskippable ad!") + } + } + } + } + },100) +} + function processPage() { wrapFrames(); wrapTables(); @@ -165,6 +237,7 @@ function processPage() { convertImgSrc(); flattenPreElements(); styleLocalFootnotes(); - removeWpSmiley() + removeWpSmiley(); + addYouTubeVideos(); postRenderProcessing(); }