Skip to content

Commit

Permalink
Merge pull request #149 from throwaway96/hide-logo-stylesheet-20240330
Browse files Browse the repository at this point in the history
Hide logo using stylesheet injection
  • Loading branch information
throwaway96 authored Mar 31, 2024
2 parents 6c889ad + 22fd5f1 commit 874f294
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ const configOptions = new Map([
default: true,
desc: 'Skip music and off-topic segments'
}
],
[
'hideLogo',
{
default: false,
desc: 'Hide YouTube logo'
}
]
]);

Expand Down
35 changes: 31 additions & 4 deletions src/ui.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/*global navigate*/
import './spatial-navigation-polyfill.js';
import {
configAddChangeListener,
configRead,
configWrite,
configGetDesc
} from './config.js';
import './ui.css';
import { configRead, configWrite, configGetDesc } from './config.js';

// We handle key events ourselves.
window.__spatialNavigation__.keyMode = 'NONE';
Expand Down Expand Up @@ -115,6 +120,7 @@ function createOptionsPanel() {
elmContainer.appendChild(elmHeading);

elmContainer.appendChild(createConfigCheckbox('enableAdBlock'));
elmContainer.appendChild(createConfigCheckbox('hideLogo'));
elmContainer.appendChild(createConfigCheckbox('enableSponsorBlock'));

const elmBlock = document.createElement('blockquote');
Expand Down Expand Up @@ -218,9 +224,25 @@ export function showNotification(text, time = 3000) {
}, time);
}

setTimeout(() => {
showNotification('Press [GREEN] to open YTAF configuration screen');
}, 2000);
/**
* Initialize ability to hide YouTube logo in top right corner.
*/
function initHideLogo() {
const style = document.createElement('style');
document.head.appendChild(style);

/** @type {(hide: boolean) => void} */
const setHidden = (hide) => {
const visibility = hide ? 'hidden' : 'visible';
style.textContent = `ytlr-redux-connect-ytlr-logo-entity { visibility: ${visibility}; }`;
};

setHidden(configRead('hideLogo'));

configAddChangeListener('hideLogo', (evt) => {
setHidden(evt.detail.newValue);
});
}

function applyUIFixes() {
try {
Expand Down Expand Up @@ -252,3 +274,8 @@ function applyUIFixes() {
}

applyUIFixes();
initHideLogo();

setTimeout(() => {
showNotification('Press [GREEN] to open YTAF configuration screen');
}, 2000);

0 comments on commit 874f294

Please sign in to comment.