Compare commits

...
3 Commits
2 changed files with 128 additions and 76 deletions
+70 -22
View File
@@ -283,7 +283,16 @@
var isAuth = !!token && !!uName; var isAuth = !!token && !!uName;
if (headerRight) { if (headerRight) {
var defaultLoginLink = headerRight.querySelector('my-login-link, a[href*="/login"], .login-button');
var liveWidget = headerRight.querySelector('#yaknet-header-account-widget'); var liveWidget = headerRight.querySelector('#yaknet-header-account-widget');
if (isAuth) {
// Logged In: Show YakNet Profile Menu, Hide default login link
if (defaultLoginLink) {
defaultLoginLink.style.display = 'none';
defaultLoginLink.setAttribute('aria-hidden', 'true');
}
if (!liveWidget) { if (!liveWidget) {
var widgetWrap = document.createElement('div'); var widgetWrap = document.createElement('div');
widgetWrap.id = 'yaknet-header-account-widget'; widgetWrap.id = 'yaknet-header-account-widget';
@@ -298,21 +307,18 @@
'redirect-uri="https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback" ' + 'redirect-uri="https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback" ' +
'base-url="https://auth.yakhub.com.tr" ' + 'base-url="https://auth.yakhub.com.tr" ' +
'login-url="/login" ' + 'login-url="/login" ' +
'authenticated="' + 'authenticated="true" ' +
(isAuth ? 'true' : 'false') +
'" ' +
'user-name="' + 'user-name="' +
(isAuth ? displayName.replace(/"/g, '"') : '') + displayName.replace(/"/g, '"') +
'" ' + '" ' +
'user-email="' + 'user-email="' +
(isAuth ? emailStr.replace(/"/g, '"') : '') + emailStr.replace(/"/g, '"') +
'" ' + '" ' +
'theme="dark">' + 'theme="dark">' +
'</yaknet-account>'; '</yaknet-account>';
var targetSibling = var targetSibling =
headerRight.querySelector('my-user-menu') || headerRight.querySelector('my-user-menu') ||
headerRight.querySelector('my-login-link') ||
headerRight.querySelector('.user-menu') || headerRight.querySelector('.user-menu') ||
headerRight.querySelector('.settings-button') || headerRight.querySelector('.settings-button') ||
headerRight.querySelector('my-user-notifications') || headerRight.querySelector('my-user-notifications') ||
@@ -323,15 +329,7 @@
} else { } else {
headerRight.prepend(widgetWrap); headerRight.prepend(widgetWrap);
} }
var defaultLoginLink = headerRight.querySelector('my-login-link');
if (defaultLoginLink) {
defaultLoginLink.setAttribute('aria-hidden', 'true');
defaultLoginLink.setAttribute('tabindex', '-1');
defaultLoginLink.style.display = 'none';
}
} else { } else {
// Sync widget attributes dynamically if auth state changed
var el = liveWidget.querySelector('yaknet-account'); var el = liveWidget.querySelector('yaknet-account');
if (el) { if (el) {
if (el.shadowRoot) { if (el.shadowRoot) {
@@ -353,13 +351,10 @@
} }
} }
var expectedAuth = isAuth ? 'true' : 'false'; if (el.getAttribute('authenticated') !== 'true' || el.getAttribute('user-name') !== displayName) {
var expectedName = isAuth ? displayName : ''; el.setAttribute('authenticated', 'true');
var expectedEmail = isAuth ? emailStr : ''; el.setAttribute('user-name', displayName);
if (el.getAttribute('authenticated') !== expectedAuth || el.getAttribute('user-name') !== expectedName) { el.setAttribute('user-email', emailStr);
el.setAttribute('authenticated', expectedAuth);
el.setAttribute('user-name', expectedName);
el.setAttribute('user-email', expectedEmail);
if (typeof el.syncStateFromAttributes === 'function') { if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes(); el.syncStateFromAttributes();
el.render(); el.render();
@@ -367,6 +362,29 @@
} }
} }
} }
} else {
// Not Logged In: Remove YakNet widget to eliminate duplicate button, keep PeerTube native login button clean
if (liveWidget) {
liveWidget.remove();
}
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 Hesabınız ile Giriş Yapın');
var spanText = loginAnchor.querySelector('span');
if (spanText) {
spanText.textContent = 'YakNet ile Giriş Yap';
} else {
loginAnchor.textContent = 'YakNet ile Giriş Yap';
}
}
}
}
} }
// 2.2 Login Modal / Page // 2.2 Login Modal / Page
@@ -463,6 +481,35 @@
injectYakNetSSO(); injectYakNetSSO();
// Replace all login buttons labels and titles
document
.querySelectorAll(
'my-login-link, a[href*="/login"], a[title*="Giriş sayfasına git"], [aria-label*="Giriş sayfasına git"]'
)
.forEach(function (el) {
if (el.getAttribute('title') && el.getAttribute('title').includes('Giriş sayfasına git')) {
el.setAttribute('title', 'YakNet ile Giriş Yap');
}
if (el.getAttribute('aria-label') && el.getAttribute('aria-label').includes('Giriş sayfasına git')) {
el.setAttribute('aria-label', 'YakNet ile Giriş Yap');
}
var anchor = el.tagName.toLowerCase() === 'a' ? el : el.querySelector('a');
if (anchor) {
anchor.setAttribute('title', 'YakNet ile Giriş Yap');
anchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
var spans = anchor.querySelectorAll('span');
spans.forEach(function (s) {
if (
s.textContent.includes('Giriş sayfasına git') ||
s.textContent.trim() === 'Giriş' ||
s.textContent.trim() === 'Giriş yap'
) {
s.textContent = 'YakNet ile Giriş Yap';
}
});
}
});
// Aggressively remove generic Framasoft Open-in-App / Play Store banners // Aggressively remove generic Framasoft Open-in-App / Play Store banners
var genericAppBanners = document.querySelectorAll( 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"]' '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"]'
@@ -501,7 +548,8 @@
.replace(/PeerTube hakkında/gi, 'YakTube Hakkında') .replace(/PeerTube hakkında/gi, 'YakTube Hakkında')
.replace(/PeerTube'a katılın/gi, "YakTube'a Katılın") .replace(/PeerTube'a katılın/gi, "YakTube'a Katılın")
.replace(/PeerTube örneği/gi, 'YakTube Sunucusu') .replace(/PeerTube örneği/gi, 'YakTube Sunucusu')
.replace(/PeerTube/g, 'YakTube'); .replace(/PeerTube/g, 'YakTube')
.replace(/Giriş sayfasına git/gi, 'YakNet ile Giriş Yap');
} }
} }
} }
+7 -3
View File
@@ -1,14 +1,17 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.4.2", "version": "1.4.5",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube",
"main": "main.js", "main": "main.js",
"library": "./main.js",
"staticDirs": {},
"translations": {},
"clientScripts": [ "clientScripts": [
{ {
"script": "client.js",
"scopes": [ "scopes": [
"common" "common"
], ]
"script": "client.js"
} }
], ],
"css": [ "css": [
@@ -39,5 +42,6 @@
"url": "https://github.com/yakistir98/peertube-plugin-yaktube-ondemand.git" "url": "https://github.com/yakistir98/peertube-plugin-yaktube-ondemand.git"
}, },
"homepage": "https://yaktube.yakhub.com.tr", "homepage": "https://yaktube.yakhub.com.tr",
"bugs": "https://github.com/yakistir98/peertube-plugin-yaktube-ondemand/issues",
"license": "AGPL-3.0-or-later" "license": "AGPL-3.0-or-later"
} }