mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge branch 'youtube-integration' into super-cut
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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;i<closeAble.length;i++){
|
||||
closeAble[i].click();
|
||||
//console.log("ad banner closed!")
|
||||
}
|
||||
if(document.getElementsByClassName("style-scope ytd-watch-next-secondary-results-renderer sparkles-light-cta GoogleActiveViewElement")[0]!==undefined){
|
||||
let sideAd=document.getElementsByClassName("style-scope ytd-watch-next-secondary-results-renderer sparkles-light-cta GoogleActiveViewElement")[0];
|
||||
sideAd.style.display="none";
|
||||
//console.log("side ad removed!")
|
||||
}
|
||||
if(document.getElementsByClassName("style-scope ytd-item-section-renderer sparkles-light-cta")[0]!==undefined){
|
||||
let sideAd_ = document.getElementsByClassName("style-scope ytd-item-section-renderer sparkles-light-cta")[0];
|
||||
sideAd_.style.display="none";
|
||||
//console.log("side ad removed!")
|
||||
}
|
||||
if(document.getElementsByClassName("ytp-ad-text ytp-ad-skip-button-text")[0]!==undefined){
|
||||
let skipBtn=document.getElementsByClassName("ytp-ad-text ytp-ad-skip-button-text")[0];
|
||||
skipBtn.click();
|
||||
//console.log("skippable ad skipped!")
|
||||
}
|
||||
if(document.getElementsByClassName("ytp-ad-message-container")[0]!==undefined){
|
||||
let incomingAd=document.getElementsByClassName("ytp-ad-message-container")[0];
|
||||
incomingAd.style.display="none";
|
||||
//console.log("removed incoming ad alert!")
|
||||
}
|
||||
if(document.getElementsByClassName("style-scope ytd-companion-slot-renderer")[0]!==undefined){
|
||||
document.getElementsByClassName("style-scope ytd-companion-slot-renderer")[0].remove();
|
||||
//console.log("side ad removed!")
|
||||
}
|
||||
if(ad!==undefined){
|
||||
if(ad.children.length>0){
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user