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

add feature to toggle on/off sponsorblock with a single key press #101

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 30 additions & 0 deletions src/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,33 @@
padding: 0 1em;
line-height: 0;
}

.ytaf-remote-button {
display: inline-block;
width: 21.34px;
height: 21.34px;
Comment on lines +66 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you get 21.34px?

Copy link
Author

@alyyousuf7 alyyousuf7 Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was the computed height of the text before button. And I wanted to keep the height of the button same as text, so it doesn't look weird.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I think it must have originally been 16pt (21.3333...px).

}

.ytaf-remote-button::before {
content: '\00a0';
}

.ytaf-remote-button.ytaf-remote-button-red {
background-color: #b30000;
color: #b30000;
}

.ytaf-remote-button.ytaf-remote-button-green {
background-color: #006600;
color: #006600;
}

.ytaf-remote-button.ytaf-remote-button-yellow {
background-color: #e0e000;
color: #e0e000;
}

.ytaf-remote-button.ytaf-remote-button-blue {
background-color: #0000cc;
color: #0000cc;
}
17 changes: 14 additions & 3 deletions src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function showNotification(text, time = 3000) {

const elm = document.createElement('div');
const elmInner = document.createElement('div');
elmInner.innerText = text;
elmInner.innerHTML = text;
elmInner.classList.add('message');
elmInner.classList.add('message-hidden');
elm.appendChild(elmInner);
Expand All @@ -214,7 +214,18 @@ export function showNotification(text, time = 3000) {
}, time);
}

function remoteBtnBox(key) {
const el = document.createElement('span');
el.classList.add('ytaf-remote-button', `ytaf-remote-button-${key}`);

return el.outerHTML;
}

setTimeout(() => {
showNotification('Press 🟩 to open YTAF configuration screen');
showNotification('Press 🟥 to toggle on/off SponsorBlock');
showNotification(
`Press ${remoteBtnBox('green')} GREEN to open YTAF configuration screen`
);
showNotification(
`Press ${remoteBtnBox('red')} RED to toggle on/off SponsorBlock`
);
}, 2000);