Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide logo using stylesheet injection #149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);