fix(yaknet-account): adapt hooks and community exceptions for new 2-part menu design (v1.5.12)

This commit is contained in:
Enes Yakıştır
2026-10-17 00:25:48 +03:00
parent f7b6f76bb2
commit 4c91431824
2 changed files with 47 additions and 8 deletions
+46 -7
View File
@@ -176,7 +176,7 @@ try {
document.head.appendChild(s); document.head.appendChild(s);
} }
// Intercept and sanitize YakNet Account Web Component popup menu // Intercept and sanitize YakNet Account Web Component popup menu (v1.5.12)
function hookYakNetAccountComponent() { function hookYakNetAccountComponent() {
if (typeof customElements === 'undefined') return; if (typeof customElements === 'undefined') return;
customElements customElements
@@ -192,18 +192,49 @@ try {
try { try {
if (this.shadowRoot) { if (this.shadowRoot) {
var isOfficial = isOfficialYakTubeServer(); var isOfficial = isOfficialYakTubeServer();
// 1. In YakTube: Suppress redundant/recursive link to YakTube inside services list // 1. In YakTube: Suppress redundant/recursive link to YakTube inside services list
var selfLinks = this.shadowRoot.querySelectorAll('a[href*="yaktube.yakhub.com.tr"]'); var selfLinks = this.shadowRoot.querySelectorAll(
'a[href*="yaktube.yakhub.com.tr"], .yn-app-card.yn-current, a[aria-label="YakTube"]'
);
selfLinks.forEach(function (a) { selfLinks.forEach(function (a) {
a.style.display = 'none'; a.style.display = 'none';
}); });
// 2. In third-party PeerTube instances: Suppress entire external services grid & header to avoid community backlash
// 2. In third-party PeerTube instances: Suppress entire external services grid & 9-dot launcher to avoid community backlash
if (!isOfficial) { if (!isOfficial) {
var appsGrid = this.shadowRoot.querySelector('.yn-apps-grid'); // Hide 9-dot apps button
var appsBtn = this.shadowRoot.querySelector('#appsTriggerBtn, .yn-apps-btn');
if (appsBtn) appsBtn.style.display = 'none';
// Hide apps popover
var appsPopover = this.shadowRoot.querySelector('#yn-apps-popover, .yn-apps-popover');
if (appsPopover) appsPopover.style.display = 'none';
// Legacy selectors for backwards compatibility
var appsGrid = this.shadowRoot.querySelector('.yn-apps-grid, .yn-apps-grid-3col');
if (appsGrid) appsGrid.style.display = 'none'; if (appsGrid) appsGrid.style.display = 'none';
var sectionTitle = this.shadowRoot.querySelector('#yn-services-label, .yn-section-title'); var sectionTitle = this.shadowRoot.querySelector('#yn-services-label, .yn-section-title, .yn-apps-footer');
if (sectionTitle) sectionTitle.style.display = 'none'; if (sectionTitle) sectionTitle.style.display = 'none';
} }
// 3. Ensure Logout Button Hook is attached whenever account menu renders
var shadowLogoutBtn =
this.shadowRoot.getElementById('logoutBtn') ||
this.shadowRoot.querySelector('.yn-logout-btn') ||
this.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
);
}
} }
} catch (e) {} } catch (e) {}
}; };
@@ -564,6 +595,7 @@ try {
'base-url="https://developer-console.yakhub.com.tr" ' + 'base-url="https://developer-console.yakhub.com.tr" ' +
'login-url="/login" ' + 'login-url="/login" ' +
'authenticated="true" ' + 'authenticated="true" ' +
'hide-service="yaktube" ' +
'user-name="' + 'user-name="' +
displayName.replace(/"/g, '"') + displayName.replace(/"/g, '"') +
'" ' + '" ' +
@@ -591,10 +623,15 @@ try {
} else { } else {
var el = liveWidget.querySelector('yaknet-account'); var el = liveWidget.querySelector('yaknet-account');
if (el) { if (el) {
if (el.getAttribute('authenticated') !== 'true' || el.getAttribute('user-name') !== displayName) { if (
el.getAttribute('authenticated') !== 'true' ||
el.getAttribute('user-name') !== displayName ||
el.getAttribute('hide-service') !== 'yaktube'
) {
el.setAttribute('authenticated', 'true'); el.setAttribute('authenticated', 'true');
el.setAttribute('user-name', displayName); el.setAttribute('user-name', displayName);
el.setAttribute('user-email', emailStr); el.setAttribute('user-email', emailStr);
el.setAttribute('hide-service', 'yaktube');
if (typeof el.syncStateFromAttributes === 'function') { if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes(); el.syncStateFromAttributes();
el.render(); el.render();
@@ -603,7 +640,9 @@ try {
if (el.shadowRoot) { if (el.shadowRoot) {
// Direct DOM safety: remove self-link on polling cycle too // Direct DOM safety: remove self-link on polling cycle too
var selfLinks = el.shadowRoot.querySelectorAll('a[href*="yaktube.yakhub.com.tr"]'); var selfLinks = el.shadowRoot.querySelectorAll(
'a[href*="yaktube.yakhub.com.tr"], .yn-app-card.yn-current, a[aria-label="YakTube"]'
);
selfLinks.forEach(function (a) { selfLinks.forEach(function (a) {
a.style.display = 'none'; a.style.display = 'none';
}); });
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.5.11", "version": "1.5.12",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
"main": "main.js", "main": "main.js",
"library": "./main.js", "library": "./main.js",