Compare commits

..
7 Commits
3 changed files with 190 additions and 70 deletions
+167 -69
View File
@@ -2,6 +2,10 @@ try {
(function () {
if (window.__YAKTUBE_ENGINE_LOADED__) return;
window.__YAKTUBE_ENGINE_LOADED__ = true;
try {
localStorage.setItem('hide-mobile-msg', 'true');
sessionStorage.setItem('hide-mobile-msg', 'true');
} catch (e) {}
console.log('[YakTube] YakNet SSO, Custom Branding, A11y & On-Demand Engine Active');
// Dynamic Instance Name Helper
@@ -50,6 +54,52 @@ try {
}, 50);
}
// Load official YakNet Web Component definition
if (
typeof customElements !== 'undefined' &&
!customElements.get('yaknet-account') &&
!document.getElementById('yaknet-account-script')
) {
var s = document.createElement('script');
s.id = 'yaknet-account-script';
s.src = 'https://auth.yakhub.com.tr/js/yaknet-account.js';
s.async = true;
document.head.appendChild(s);
}
// Silent background SSO Probe Engine
function initSilentSSOProbe() {
var token = localStorage.getItem('access_token');
var isManualLogout = sessionStorage.getItem('yaknet_manual_logout');
if (
token ||
isManualLogout ||
window.location.search.includes('local=true') ||
window.location.search.includes('externalAuthError') ||
window.location.pathname.includes('/login')
) {
return;
}
var iframeId = 'yaknet-sso-iframe-instance';
if (!document.getElementById(iframeId)) {
var iframe = document.createElement('iframe');
iframe.id = iframeId;
iframe.src = 'https://auth.yakhub.com.tr/sdk/sso-frame';
iframe.title = 'YakNet Oturum Kontrolü';
iframe.setAttribute('aria-hidden', 'true');
iframe.tabIndex = -1;
iframe.style.cssText =
'display:none!important;width:0!important;height:0!important;border:0!important;position:absolute!important;pointer-events:none!important;';
document.body.appendChild(iframe);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initSilentSSOProbe);
} else {
initSilentSSOProbe();
}
function triggerYakNetOAuth() {
sessionStorage.removeItem('yaknet_manual_logout');
var callbackUrl = 'https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback';
@@ -287,78 +337,104 @@ try {
var defaultLoginLink = headerRight.querySelector('my-login-link, a[href*="/login"], .login-button');
var liveWidget = headerRight.querySelector('#yaknet-header-account-widget');
// Always hide duplicate native login link in favor of unified YakNet component
if (defaultLoginLink) {
defaultLoginLink.style.display = 'none';
defaultLoginLink.setAttribute('aria-hidden', 'true');
}
if (!liveWidget) {
var widgetWrap = document.createElement('div');
widgetWrap.id = 'yaknet-header-account-widget';
widgetWrap.className = 'yaknet-header-widget';
widgetWrap.style.display = 'inline-flex';
widgetWrap.style.alignItems = 'center';
widgetWrap.style.marginRight = '8px';
widgetWrap.innerHTML =
'<yaknet-account ' +
'client-id="01a03c41-f758-721e-b927-619bffde5c23" ' +
'redirect-uri="https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback" ' +
'base-url="https://auth.yakhub.com.tr" ' +
'login-url="https://auth.yakhub.com.tr/oauth/authorize?client_id=01a03c41-f758-721e-b927-619bffde5c23&redirect_uri=https%3A%2F%2Fyaktube.yakhub.com.tr%2Fplugins%2Fpeertube-plugin-auth-yaknet%2Frouter%2Fauth-callback&response_type=code&scope=" ' +
(isAuth ? 'authenticated="true" ' : 'authenticated="false" ') +
'user-name="' +
displayName.replace(/"/g, '&quot;') +
'" ' +
'user-email="' +
emailStr.replace(/"/g, '&quot;') +
'" ' +
'theme="dark">' +
'</yaknet-account>';
var targetSibling =
headerRight.querySelector('my-user-menu') ||
headerRight.querySelector('.user-menu') ||
headerRight.querySelector('.settings-button') ||
headerRight.querySelector('my-user-notifications') ||
headerRight.querySelector('my-notification-bell');
if (targetSibling && targetSibling.parentElement === headerRight) {
headerRight.insertBefore(widgetWrap, targetSibling);
} else {
headerRight.prepend(widgetWrap);
if (isAuth) {
// 1. AUTHENTICATED: Hide native login link, Show YakNet Account Profile Menu
if (defaultLoginLink) {
defaultLoginLink.style.display = 'none';
defaultLoginLink.setAttribute('aria-hidden', 'true');
}
} else {
var el = liveWidget.querySelector('yaknet-account');
if (el) {
var authAttr = isAuth ? 'true' : 'false';
if (el.getAttribute('authenticated') !== authAttr || el.getAttribute('user-name') !== displayName) {
el.setAttribute('authenticated', authAttr);
el.setAttribute('user-name', displayName);
el.setAttribute('user-email', emailStr);
if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes();
el.render();
if (!liveWidget) {
var widgetWrap = document.createElement('div');
widgetWrap.id = 'yaknet-header-account-widget';
widgetWrap.className = 'yaknet-header-widget';
widgetWrap.style.display = 'inline-flex';
widgetWrap.style.alignItems = 'center';
widgetWrap.style.marginRight = '8px';
widgetWrap.innerHTML =
'<yaknet-account ' +
'client-id="01a03c41-f758-721e-b927-619bffde5c23" ' +
'redirect-uri="https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback" ' +
'base-url="https://auth.yakhub.com.tr" ' +
'login-url="/login" ' +
'authenticated="true" ' +
'user-name="' +
displayName.replace(/"/g, '&quot;') +
'" ' +
'user-email="' +
emailStr.replace(/"/g, '&quot;') +
'" ' +
'theme="dark">' +
'</yaknet-account>';
var targetSibling =
headerRight.querySelector('my-user-menu') ||
headerRight.querySelector('.user-menu') ||
headerRight.querySelector('.settings-button') ||
headerRight.querySelector('my-user-notifications') ||
headerRight.querySelector('my-notification-bell');
if (targetSibling && targetSibling.parentElement === headerRight) {
headerRight.insertBefore(widgetWrap, targetSibling);
} else {
headerRight.prepend(widgetWrap);
}
} else {
var el = liveWidget.querySelector('yaknet-account');
if (el) {
if (el.getAttribute('authenticated') !== 'true' || el.getAttribute('user-name') !== displayName) {
el.setAttribute('authenticated', 'true');
el.setAttribute('user-name', displayName);
el.setAttribute('user-email', emailStr);
if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes();
el.render();
}
}
if (el.shadowRoot) {
var shadowLogoutBtn =
el.shadowRoot.getElementById('logoutBtn') ||
el.shadowRoot.querySelector('.yn-logout-btn') ||
el.shadowRoot.querySelector('button[title*="Çıkış"], button[aria-label*="Çıkış"]');
if (shadowLogoutBtn && !shadowLogoutBtn.hasAttribute('data-yaktube-hooked')) {
shadowLogoutBtn.setAttribute('data-yaktube-hooked', 'true');
shadowLogoutBtn.addEventListener(
'click',
function (ev) {
ev.preventDefault();
ev.stopPropagation();
performUnifiedLogout();
},
true
);
}
}
}
}
} else {
// 2. GUEST / NOT LOGGED IN:
// A. Physically remove any <yaknet-account> widget from DOM to guarantee zero shadow DOM duplicate buttons
if (liveWidget) {
liveWidget.remove();
}
if (el.shadowRoot) {
var shadowLogoutBtn =
el.shadowRoot.getElementById('logoutBtn') ||
el.shadowRoot.querySelector('.yn-logout-btn') ||
el.shadowRoot.querySelector('button[title*="Çıkış"], button[aria-label*="Çıkış"]');
if (shadowLogoutBtn && !shadowLogoutBtn.hasAttribute('data-yaktube-hooked')) {
shadowLogoutBtn.setAttribute('data-yaktube-hooked', 'true');
shadowLogoutBtn.addEventListener(
'click',
function (ev) {
ev.preventDefault();
ev.stopPropagation();
performUnifiedLogout();
},
true
);
// B. Ensure PeerTube's native login link is the ONLY single accessible login element
if (defaultLoginLink) {
defaultLoginLink.style.display = '';
defaultLoginLink.removeAttribute('aria-hidden');
var loginAnchor =
defaultLoginLink.tagName.toLowerCase() === 'a' ? defaultLoginLink : defaultLoginLink.querySelector('a');
if (loginAnchor) {
loginAnchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
loginAnchor.setAttribute('title', 'YakNet ile Giriş Yap');
var spanText = loginAnchor.querySelector('span');
if (spanText) {
spanText.textContent = 'YakNet ile Giriş Yap';
} else {
loginAnchor.textContent = 'YakNet ile Giriş Yap';
}
}
}
@@ -491,6 +567,13 @@ try {
});
// Aggressively remove generic Framasoft Open-in-App / Play Store banners
document
.querySelectorAll(
'.mobile-msg, [class*="mobile-msg"], button[title*="Bu mesajı kapat"], button[aria-label*="Bu mesajı kapat"]'
)
.forEach(function (m) {
m.remove();
});
var genericAppBanners = document.querySelectorAll(
'my-open-app, my-client-app-banner, .open-app-container, .app-banner, [class*="open-app"], [class*="open-in-app"], .mobile-app-banner, my-open-in-app, .app-promotion, a[href*="play.google.com/store/apps/details?id=app.joinpeertube"], a[href*="f-droid.org"]'
);
@@ -797,7 +880,22 @@ try {
}
function getVideoElement() {
return document.querySelector('video');
// 1. Direct video tag in DOM
var v = document.querySelector('video');
if (v) return v;
// 2. Video inside iframes (e.g. embed player)
var iframes = document.querySelectorAll('iframe');
for (var i = 0; i < iframes.length; i++) {
try {
var doc = iframes[i].contentDocument || (iframes[i].contentWindow && iframes[i].contentWindow.document);
if (doc) {
var iv = doc.querySelector('video');
if (iv) return iv;
}
} catch (e) {}
}
return null;
}
function formatTime(seconds) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "peertube-plugin-yaktube-ondemand",
"version": "1.4.11",
"version": "1.4.18",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube",
"main": "main.js",
"library": "./main.js",
+22
View File
@@ -1,3 +1,25 @@
/* 100% Elimination of PeerTube Mobile Open-in-App Banner & Close Button */
.mobile-msg,
my-header .mobile-msg,
[class*='mobile-msg'],
button[title*='Bu mesajı kapat'],
button[aria-label*='Bu mesajı kapat'],
button[title*='Dismiss'],
.msg.ellipsis,
.peertube-button-link.secondary-button {
display: none !important;
visibility: hidden !important;
height: 0 !important;
width: 0 !important;
margin: 0 !important;
padding: 0 !important;
pointer-events: none !important;
opacity: 0 !important;
position: absolute !important;
z-index: -99999 !important;
clip: rect(0, 0, 0, 0) !important;
}
/* Permanent Aggressive Suppression of Generic JoinPeerTube / Framasoft Open-in-App Banners */
my-open-app,
my-open-in-app,