From 2efef5ec1ce806dff60a87b98b9c8cf9dfd830b8 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 1 Apr 2023 21:00:21 -0500 Subject: [PATCH 1/2] Allow fullscreen video --- Mac/MainWindow/Detail/DetailWebViewController.swift | 3 +++ 1 file changed, 3 insertions(+) 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() From cc499bdbbe5a1d6b77aacde99b2bbbcd2e0ccb5a Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 1 Apr 2023 21:01:09 -0500 Subject: [PATCH 2/2] Automatically add the YouTube embedded video viewer --- Shared/Article Rendering/main.js | 75 +++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) 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(); }